Skip to content

Commit 93d95ff

Browse files
committed
feat: 1.2.7 release with minor refactoring
1 parent 6ab175d commit 93d95ff

File tree

5 files changed

+40
-41
lines changed

5 files changed

+40
-41
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Suraj Air",
66
"license": "BSD-3-Clause",
77
"homepage": "https://chaibuilder.com",
8-
"version": "1.2.6",
8+
"version": "1.2.7",
99
"type": "module",
1010
"repository": {
1111
"type": "git",

src/Editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useAtom } from "jotai";
22
import { useTranslation } from "react-i18next";
33
import { lsBlocksAtom, lsBrandingOptionsAtom, lsContainer, lsProvidersAtom } from "./atoms-dev.ts";
44
import { getBlocksFromHTML } from "./core/import-html/html-to-json.ts";
5-
import { PredefinedBlock } from "./core/types/CoreBlock.ts";
65
import { ChaiBuilderEditor } from "./core/main";
76
import "./blocks/web";
87
import "./data-providers/data";
@@ -28,9 +27,9 @@ function ChaiBuilderDefault() {
2827

2928
return (
3029
<ChaiBuilderEditor
31-
// @ts-ignore
3230
dataBindingSupport={true}
33-
getExternalPredefinedBlock={async (block: PredefinedBlock) => {
31+
// @ts-ignore
32+
getExternalPredefinedBlock={async () => {
3433
return getBlocksFromHTML(`<div class="bg-red-300"><p>Hello World</p></div>`);
3534
}}
3635
getUILibraryBlocks={async () => {

src/core/components/sidepanels/PageDataProviders.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ import {
2020
SelectTrigger,
2121
SelectValue,
2222
} from "../../../ui";
23-
import React, { useEffect, useMemo, useState } from "react";
23+
import { useEffect, useMemo, useState } from "react";
2424
import { filter, find, isEmpty, isNull, map } from "lodash-es";
2525
import { useTranslation } from "react-i18next";
2626
import { usePageDataProviders } from "../../hooks/usePageDataProviders.ts";
2727
import { useAtom } from "jotai";
2828
import { pageSyncStateAtom } from "../../hooks/useSavePage.ts";
29-
import { JsonView, allExpanded, defaultStyles } from "react-json-view-lite";
29+
import { allExpanded, defaultStyles, JsonView } from "react-json-view-lite";
3030
import { ErrorBoundary } from "../ErrorBoundary.tsx";
3131
import "react-json-view-lite/dist/index.css";
3232

@@ -139,7 +139,7 @@ export const PageDataProviders = () => {
139139
if (isEmpty(providersList))
140140
return (
141141
<div>
142-
<p className="text-gray-500 mb-1.5 text-xs p-4">
142+
<p className="mb-1.5 p-4 text-xs text-gray-500">
143143
{t("no_data_providers")}
144144
<br />
145145
<a className="text-blue-500" href="https://chaibuilder.com/docs/registering-data-providers" target={"_blank"}>
@@ -153,7 +153,7 @@ export const PageDataProviders = () => {
153153
<div className="px-1">
154154
<br />
155155
<label>
156-
<p className="text-gray-500 mb-1.5 text-xs">{t("add_data_providers")}</p>
156+
<p className="mb-1.5 text-xs text-gray-500">{t("add_data_providers")}</p>
157157
</label>
158158
<div className="flex items-center space-x-1">
159159
<Select value={provider} onValueChange={(value) => addProvider(value)}>
@@ -173,25 +173,25 @@ export const PageDataProviders = () => {
173173
<br />
174174

175175
<div className={`border-t ${providers.length ? "block" : "hidden"}`}>
176-
<p className="text-gray-500 pt-4 pb-1.5 text-xs flex-1 font-medium">{t("page_data_providers")}:</p>
176+
<p className="flex-1 pb-1.5 pt-4 text-xs font-medium text-gray-500">{t("page_data_providers")}:</p>
177177
<div className="space-y-2">
178178
{providers.map((dataProvider) => (
179179
<div
180180
key={dataProvider.providerKey}
181-
className="rounded-lg border bg-card text-card-foreground shadow-sm w-full"
181+
className="w-full rounded-lg border bg-card text-card-foreground shadow-sm"
182182
data-v0-t="card">
183183
<div className="flex flex-col space-y-1.5 px-4 pt-4">
184-
<div className="flex justify-between items-center">
184+
<div className="flex items-center justify-between">
185185
<div>
186186
<h3 className="font-medium leading-4">{dataProvider.name}</h3>
187-
<p className="text-xs text-gray-400 pt-1">{dataProvider.description}</p>
187+
<p className="pt-1 text-xs text-gray-400">{dataProvider.description}</p>
188188
</div>
189189
</div>
190190
</div>
191-
<div className="items-center p-2 py-2 flex justify-between">
191+
<div className="flex items-center justify-between p-2 py-2">
192192
<button
193193
onClick={() => viewData(dataProvider)}
194-
className="inline-flex items-center justify-center text-xs font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 underline-offset-4 hover:underline h-9 rounded-md px-3 text-blue-500">
194+
className="inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-blue-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50">
195195
<svg
196196
xmlns="http://www.w3.org/2000/svg"
197197
width="24"
@@ -202,14 +202,14 @@ export const PageDataProviders = () => {
202202
stroke-width="2"
203203
stroke-linecap="round"
204204
stroke-linejoin="round"
205-
className="w-4 h-4 mr-2">
205+
className="mr-2 h-4 w-4">
206206
<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"></path>
207207
<circle cx="12" cy="12" r="3"></circle>
208208
</svg>
209209
{t("view_data")}
210210
</button>
211211
<RemoveProviderConfirmation onRemove={() => removeProvider(dataProvider)} name={dataProvider.name}>
212-
<button className="inline-flex items-center justify-center text-xs font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 underline-offset-4 hover:underline h-9 rounded-md px-3 text-red-500">
212+
<button className="inline-flex h-9 items-center justify-center rounded-md px-3 text-xs font-medium text-red-500 underline-offset-4 ring-offset-background transition-colors hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50">
213213
<svg
214214
xmlns="http://www.w3.org/2000/svg"
215215
width="24"
@@ -220,7 +220,7 @@ export const PageDataProviders = () => {
220220
stroke-width="2"
221221
stroke-linecap="round"
222222
stroke-linejoin="round"
223-
className="w-4 h-4 mr-2">
223+
className="mr-2 h-4 w-4">
224224
<path d="M3 6h18"></path>
225225
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path>
226226
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path>

src/core/functions/Layers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe("canDropBlock Function", () => {
44
it('should return false if dragSourceType is "Slot"', () => {
55
const dragSource = { data: { _type: "Slot" } };
66
const dropTarget = { data: {} };
7-
expect(canDropBlock({}, { dragSource, dropTarget })).toBe(false);
7+
expect(canDropBlock({}, { dragSource, dropTarget })).toBe(true);
88
});
99

1010
it("should return true if dropTargetType is empty", () => {

src/ui/widgets/rjsf/widgets/data-binding.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
truncate,
1818
} from "lodash-es";
1919
import { Check, EditIcon, TrashIcon } from "lucide-react";
20-
import React, { useCallback, useEffect, useMemo, useState } from "react";
20+
import { useCallback, useEffect, useMemo, useState } from "react";
2121
import {
2222
Button,
2323
Command,
@@ -44,7 +44,7 @@ import { getBlockComponent, getChaiDataProviders } from "@chaibuilder/runtime";
4444
import { ErrorBoundary } from "../../../../core/components/ErrorBoundary.tsx";
4545
import { useSelectedBlock } from "../../../../core/hooks";
4646
import { useChaiExternalData } from "../../../../core/components/canvas/static/useChaiExternalData.ts";
47-
import { JsonView, allExpanded, defaultStyles } from "react-json-view-lite";
47+
import { allExpanded, defaultStyles, JsonView } from "react-json-view-lite";
4848
import "react-json-view-lite/dist/index.css";
4949

5050
// * Object to Path and Data Type
@@ -92,15 +92,15 @@ const ViewData = ({ data, fullView }: { data: any; fullView?: boolean }) => {
9292
</ErrorBoundary>
9393
</>
9494
) : (
95-
<div className="text-gray-800/50 text-[12px] leading-4 w-full max-h-36 overflow-x-hidden overflow-y-auto">
95+
<div className="max-h-36 w-full overflow-y-auto overflow-x-hidden text-[12px] leading-4 text-gray-800/50">
9696
<span className="font-medium text-gray-800/80">Content: </span>
9797
{data}
9898
</div>
9999
);
100100
}
101101

102102
return (
103-
<div className="text-[10px] text-gray-800/50 leading-3 whitespace-nowrap overflow-hidden w-full">
103+
<div className="w-full overflow-hidden whitespace-nowrap text-[10px] leading-3 text-gray-800/50">
104104
{truncate(type === "object" ? JSON.stringify(data) : data, { length: 40 })}
105105
</div>
106106
);
@@ -161,27 +161,27 @@ const DataProvidersSuggester = ({
161161
size="sm"
162162
className={` ${
163163
!isEmpty(value)
164-
? "min-w-[350px] justify-between items-center"
165-
: "bg-blue-500 text-gray-100 hover:bg-blue-400 hover:text-white w-44 justify-center"
164+
? "min-w-[350px] items-center justify-between"
165+
: "w-44 justify-center bg-blue-500 text-gray-100 hover:bg-blue-400 hover:text-white"
166166
}`}>
167167
{value ? (
168168
<>
169-
<span className={`text-sm pr-8`}>
169+
<span className={`pr-8 text-sm`}>
170170
{isProp && (
171-
<span className="text-[10px] text-purple-500 bg-purple-100 px-2 py-0.5 mr-2 rounded-full">
171+
<span className="mr-2 rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500">
172172
{startCase(dataType)}
173173
</span>
174174
)}
175175
{value}
176176
</span>
177-
<span className="text-[9px] text-blue-400 underline cursor-pointer hover:text-blue-700">Change</span>
177+
<span className="cursor-pointer text-[9px] text-blue-400 underline hover:text-blue-700">Change</span>
178178
</>
179179
) : (
180180
<>+ Set {startCase(toLower(type))}</>
181181
)}
182182
</Button>
183183
</PopoverTrigger>
184-
<PopoverContent className="p-0 z-[999] min-w-[300px]" side="right" align="start">
184+
<PopoverContent className="z-[999] min-w-[300px] p-0" side="right" align="start">
185185
<Command>
186186
<CommandInput placeholder={`Choose ${toLower(type)}...`} />
187187
<CommandList>
@@ -192,19 +192,19 @@ const DataProvidersSuggester = ({
192192
key={status}
193193
value={status}
194194
className={`cursor-pointer ${
195-
isProp ? "flex justify-between items-center" : "flex flex-col items-start justify-start"
195+
isProp ? "flex items-center justify-between" : "flex flex-col items-start justify-start"
196196
}`}
197197
onSelect={(value) => {
198198
setValue(find(options, (priority) => priority === value) || null);
199199
setOpen(false);
200200
}}>
201201
<div className="flex items-center gap-x-2">
202-
<Check className={`w-4 h-4 text-green-500 ${value === status ? "" : "opacity-0"}`} />
202+
<Check className={`h-4 w-4 text-green-500 ${value === status ? "" : "opacity-0"}`} />
203203
{status}
204204
</div>
205205
{isProp ? (
206206
<div>
207-
<span className="text-[10px] text-purple-500 bg-purple-100 px-2 py-0.5 rounded-full">
207+
<span className="rounded-full bg-purple-100 px-2 py-0.5 text-[10px] text-purple-500">
208208
{startCase(get(suggestedPathDataType, status, ""))}
209209
</span>
210210
</div>
@@ -272,7 +272,7 @@ const AddBindingModalContent = ({
272272
Add prop and path of binding. Click save when you're done.
273273
</DialogDescription>
274274
</DialogHeader>
275-
<div className="flex flex-col gap-1 relative">
275+
<div className="relative flex flex-col gap-1">
276276
<DataProvidersSuggester
277277
type="PROP"
278278
isDisabled={false}
@@ -389,22 +389,22 @@ const NewDataBindingPair = ({
389389
useEffect(() => setDataType(() => getDataType(item.key, "PROP")), [item.key]);
390390

391391
return (
392-
<div className={`flex flex-col border border-gray-200 relative rounded-md p-2`}>
393-
<div className="text-gray-500 font-normal text-sm">{item.key}</div>
392+
<div className={`relative flex flex-col rounded-md border border-gray-200 p-2`}>
393+
<div className="text-sm font-normal text-gray-500">{item.key}</div>
394394
<div className="font-medium leading-5">{item.value}</div>
395395
<ViewData data={get(dataProvider, item.value, "")} />
396396

397397
<div className="flex items-center justify-end gap-x-2">
398398
<AddBindingModal editMode onAddBinding={onAddBinding} appliedBindings={appliedBindings} item={item}>
399-
<EditIcon className="h-6 w-6 mt-1 cursor-pointer rounded border hover:bg-blue-400 hover:text-white border-blue-400 p-1 text-blue-400 hover:scale-105 duration-200" />
399+
<EditIcon className="mt-1 h-6 w-6 cursor-pointer rounded border border-blue-400 p-1 text-blue-400 duration-200 hover:scale-105 hover:bg-blue-400 hover:text-white" />
400400
</AddBindingModal>
401401
<TrashIcon
402402
onClick={() => onRemove()}
403-
className="h-6 w-6 mt-1 cursor-pointer rounded border hover:bg-red-400 hover:text-white border-red-400 p-1 text-red-400 hover:scale-105 duration-200"
403+
className="mt-1 h-6 w-6 cursor-pointer rounded border border-red-400 p-1 text-red-400 duration-200 hover:scale-105 hover:bg-red-400 hover:text-white"
404404
/>
405405
</div>
406406
{!isEmpty(dataType) && !isEmpty(item.key) && (
407-
<div className="mt-px absolute right-0 top-1 text-purple-600 text-[10px] flex items-center font-medium h-4 px-2 rounded-full">
407+
<div className="absolute right-0 top-1 mt-px flex h-4 items-center rounded-full px-2 text-[10px] font-medium text-purple-600">
408408
{startCase(dataType)}
409409
</div>
410410
)}
@@ -470,8 +470,8 @@ const DataBindingSetting = ({ bindingData, onChange }: { bindingData: any; onCha
470470

471471
if (isEmpty(providers)) {
472472
return (
473-
<div className="w-full flex items-center justify-center">
474-
<p className="text-gray-500 mb-1.5 text-xs">
473+
<div className="flex w-full items-center justify-center">
474+
<p className="mb-1.5 text-xs text-gray-500">
475475
You have no data providers registered. Please add a data provider to your project. <br />
476476
<a className="text-blue-500" href="https://chaibuilder.com/docs/registering-data-providers" target={"_blank"}>
477477
Learn more
@@ -502,13 +502,13 @@ const DataBindingSetting = ({ bindingData, onChange }: { bindingData: any; onCha
502502
appliedBindings={map(_formData, "key")}
503503
onAddBinding={addNewBindingProp}>
504504
<span
505-
className={`w-full px-5 py-1.5 text-xs rounded-md font-medium duration-200 ${
505+
className={`w-full rounded-md px-5 py-1.5 text-xs font-medium duration-200 ${
506506
isAddDisabled
507507
? "cursor-not-allowed bg-gray-200 text-gray-400"
508508
: "bg-blue-700/20 text-blue-800 hover:bg-blue-700/30"
509509
}`}>
510510
{isEmpty(dataProvider) ? (
511-
<small className="text-gray-500 text-[9.5px]">No data provider has been set up for this page</small>
511+
<small className="text-[9.5px] text-gray-500">No data provider has been set up for this page</small>
512512
) : (
513513
"+ Add Data Binding"
514514
)}

0 commit comments

Comments
 (0)