@algodomain/smart-forms 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -0
- package/README.md +243 -0
- package/dist/{SmartFormProvider-DyJoDBjQ.d.cts → SmartFormProvider-BdyRQakk.d.cts} +1 -0
- package/dist/{SmartFormProvider-DyJoDBjQ.d.ts → SmartFormProvider-BdyRQakk.d.ts} +1 -0
- package/dist/{SmartTags-HmvmCJPT.d.cts → SmartTags-DPqw9PG1.d.cts} +12 -1
- package/dist/{SmartTags-HmvmCJPT.d.ts → SmartTags-DPqw9PG1.d.ts} +12 -1
- package/dist/{chunk-5LRBJEZW.js → chunk-3L7TKJIB.js} +15 -6
- package/dist/chunk-3L7TKJIB.js.map +1 -0
- package/dist/{chunk-KDPN4CHW.js → chunk-CT6GW6PK.js} +44 -11
- package/dist/chunk-CT6GW6PK.js.map +1 -0
- package/dist/{chunk-4H5U5IHH.cjs → chunk-MBC5TYXA.cjs} +15 -6
- package/dist/chunk-MBC5TYXA.cjs.map +1 -0
- package/dist/{chunk-CJ55WKPC.cjs → chunk-TJ6EFR2O.cjs} +120 -87
- package/dist/chunk-TJ6EFR2O.cjs.map +1 -0
- package/dist/fields.cjs +172 -124
- package/dist/fields.cjs.map +1 -1
- package/dist/fields.d.cts +14 -2
- package/dist/fields.d.ts +14 -2
- package/dist/fields.js +70 -22
- package/dist/fields.js.map +1 -1
- package/dist/index.cjs +36 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +14 -8
- package/dist/index.js.map +1 -1
- package/dist/opinionated.cjs +18 -18
- package/dist/opinionated.d.cts +1 -1
- package/dist/opinionated.d.ts +1 -1
- package/dist/opinionated.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-4H5U5IHH.cjs.map +0 -1
- package/dist/chunk-5LRBJEZW.js.map +0 -1
- package/dist/chunk-CJ55WKPC.cjs.map +0 -1
- package/dist/chunk-KDPN4CHW.js.map +0 -1
package/dist/fields.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { S as SmartFormProvider, a as useFormField, u as useSmartForm } from './SmartFormProvider-
|
|
2
|
-
export { a as SmartCheckbox, d as SmartDatePicker, S as SmartInput, f as SmartInputProps, b as SmartRadioGroup, c as SmartSelect, e as SmartTags, g as SmartTagsProps } from './SmartTags-
|
|
1
|
+
export { S as SmartFormProvider, a as useFormField, u as useSmartForm } from './SmartFormProvider-BdyRQakk.cjs';
|
|
2
|
+
export { a as SmartCheckbox, d as SmartDatePicker, S as SmartInput, f as SmartInputProps, b as SmartRadioGroup, c as SmartSelect, e as SmartTags, g as SmartTagsProps } from './SmartTags-DPqw9PG1.cjs';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
|
|
5
5
|
interface SmartComboboxOption {
|
|
@@ -18,6 +18,8 @@ interface SmartComboboxProps {
|
|
|
18
18
|
defaultValue?: string;
|
|
19
19
|
info?: string;
|
|
20
20
|
subLabel?: string;
|
|
21
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
22
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
21
23
|
}
|
|
22
24
|
declare const SmartCombobox: React__default.FC<SmartComboboxProps>;
|
|
23
25
|
|
|
@@ -38,6 +40,8 @@ interface SmartFileUploadProps {
|
|
|
38
40
|
defaultValue?: File | File[];
|
|
39
41
|
info?: string;
|
|
40
42
|
subLabel?: string;
|
|
43
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
44
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
41
45
|
}
|
|
42
46
|
declare const SmartFileUpload: React__default.FC<SmartFileUploadProps>;
|
|
43
47
|
|
|
@@ -55,6 +59,8 @@ interface SmartSliderProps {
|
|
|
55
59
|
defaultValue?: number;
|
|
56
60
|
info?: string;
|
|
57
61
|
subLabel?: string;
|
|
62
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
63
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
58
64
|
}
|
|
59
65
|
declare const SmartSlider: React__default.FC<SmartSliderProps>;
|
|
60
66
|
|
|
@@ -77,6 +83,8 @@ interface SmartDualRangeSliderProps {
|
|
|
77
83
|
defaultMaxValue?: number;
|
|
78
84
|
info?: string;
|
|
79
85
|
subLabel?: string;
|
|
86
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
87
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
80
88
|
}
|
|
81
89
|
declare const SmartDualRangeSlider: React__default.FC<SmartDualRangeSliderProps>;
|
|
82
90
|
|
|
@@ -98,6 +106,8 @@ interface SmartAutoSuggestTagsProps {
|
|
|
98
106
|
onTagCreate?: (tag: TagOption) => void;
|
|
99
107
|
info?: string;
|
|
100
108
|
subLabel?: string;
|
|
109
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
110
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
101
111
|
}
|
|
102
112
|
declare const SmartAutoSuggestTags: React__default.FC<SmartAutoSuggestTagsProps>;
|
|
103
113
|
|
|
@@ -113,6 +123,8 @@ interface SmartBasicRichTextboxProps {
|
|
|
113
123
|
maxHeight?: string;
|
|
114
124
|
info?: string;
|
|
115
125
|
subLabel?: string;
|
|
126
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
127
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
116
128
|
}
|
|
117
129
|
declare const SmartBasicRichTextbox: React__default.FC<SmartBasicRichTextboxProps>;
|
|
118
130
|
|
package/dist/fields.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { S as SmartFormProvider, a as useFormField, u as useSmartForm } from './SmartFormProvider-
|
|
2
|
-
export { a as SmartCheckbox, d as SmartDatePicker, S as SmartInput, f as SmartInputProps, b as SmartRadioGroup, c as SmartSelect, e as SmartTags, g as SmartTagsProps } from './SmartTags-
|
|
1
|
+
export { S as SmartFormProvider, a as useFormField, u as useSmartForm } from './SmartFormProvider-BdyRQakk.js';
|
|
2
|
+
export { a as SmartCheckbox, d as SmartDatePicker, S as SmartInput, f as SmartInputProps, b as SmartRadioGroup, c as SmartSelect, e as SmartTags, g as SmartTagsProps } from './SmartTags-DPqw9PG1.js';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
|
|
5
5
|
interface SmartComboboxOption {
|
|
@@ -18,6 +18,8 @@ interface SmartComboboxProps {
|
|
|
18
18
|
defaultValue?: string;
|
|
19
19
|
info?: string;
|
|
20
20
|
subLabel?: string;
|
|
21
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
22
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
21
23
|
}
|
|
22
24
|
declare const SmartCombobox: React__default.FC<SmartComboboxProps>;
|
|
23
25
|
|
|
@@ -38,6 +40,8 @@ interface SmartFileUploadProps {
|
|
|
38
40
|
defaultValue?: File | File[];
|
|
39
41
|
info?: string;
|
|
40
42
|
subLabel?: string;
|
|
43
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
44
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
41
45
|
}
|
|
42
46
|
declare const SmartFileUpload: React__default.FC<SmartFileUploadProps>;
|
|
43
47
|
|
|
@@ -55,6 +59,8 @@ interface SmartSliderProps {
|
|
|
55
59
|
defaultValue?: number;
|
|
56
60
|
info?: string;
|
|
57
61
|
subLabel?: string;
|
|
62
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
63
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
58
64
|
}
|
|
59
65
|
declare const SmartSlider: React__default.FC<SmartSliderProps>;
|
|
60
66
|
|
|
@@ -77,6 +83,8 @@ interface SmartDualRangeSliderProps {
|
|
|
77
83
|
defaultMaxValue?: number;
|
|
78
84
|
info?: string;
|
|
79
85
|
subLabel?: string;
|
|
86
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
87
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
80
88
|
}
|
|
81
89
|
declare const SmartDualRangeSlider: React__default.FC<SmartDualRangeSliderProps>;
|
|
82
90
|
|
|
@@ -98,6 +106,8 @@ interface SmartAutoSuggestTagsProps {
|
|
|
98
106
|
onTagCreate?: (tag: TagOption) => void;
|
|
99
107
|
info?: string;
|
|
100
108
|
subLabel?: string;
|
|
109
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
110
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
101
111
|
}
|
|
102
112
|
declare const SmartAutoSuggestTags: React__default.FC<SmartAutoSuggestTagsProps>;
|
|
103
113
|
|
|
@@ -113,6 +123,8 @@ interface SmartBasicRichTextboxProps {
|
|
|
113
123
|
maxHeight?: string;
|
|
114
124
|
info?: string;
|
|
115
125
|
subLabel?: string;
|
|
126
|
+
disabled?: boolean | ((formData: any) => boolean);
|
|
127
|
+
hidden?: boolean | ((formData: any) => boolean);
|
|
116
128
|
}
|
|
117
129
|
declare const SmartBasicRichTextbox: React__default.FC<SmartBasicRichTextboxProps>;
|
|
118
130
|
|
package/dist/fields.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Button, Popover, PopoverTrigger, PopoverContent } from './chunk-
|
|
2
|
-
export { SmartCheckbox, SmartDatePicker, SmartRadioGroup, SmartSelect, SmartTags } from './chunk-
|
|
3
|
-
import { useFormField, useFieldDetection, Label, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent,
|
|
4
|
-
export { SmartFormProvider, SmartInput, useFormField, useSmartForm } from './chunk-
|
|
1
|
+
import { Button, Popover, PopoverTrigger, PopoverContent } from './chunk-CT6GW6PK.js';
|
|
2
|
+
export { SmartCheckbox, SmartDatePicker, SmartRadioGroup, SmartSelect, SmartTags } from './chunk-CT6GW6PK.js';
|
|
3
|
+
import { useSmartForm, useFormField, useFieldDetection, Label, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, cn, Input } from './chunk-3L7TKJIB.js';
|
|
4
|
+
export { SmartFormProvider, SmartInput, useFormField, useSmartForm } from './chunk-3L7TKJIB.js';
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import React__default, { createContext, useRef, useEffect, useMemo, useState, useCallback, useContext } from 'react';
|
|
7
7
|
import { InfoIcon, PlusIcon, CheckIcon, Bold, Italic, Underline, List, ListOrdered, ChevronsUpDown, Check, Plus, XIcon, SearchIcon } from 'lucide-react';
|
|
@@ -270,12 +270,18 @@ var SmartCombobox = ({
|
|
|
270
270
|
required = false,
|
|
271
271
|
defaultValue,
|
|
272
272
|
info,
|
|
273
|
-
subLabel
|
|
273
|
+
subLabel,
|
|
274
|
+
disabled,
|
|
275
|
+
hidden
|
|
274
276
|
}) => {
|
|
277
|
+
const { formData } = useSmartForm();
|
|
275
278
|
const { value, error, onChange, fieldRef, registerValidation } = useFormField(field);
|
|
276
279
|
const fieldDetection = useFieldDetection();
|
|
277
280
|
const hasRegistered = useRef(false);
|
|
278
281
|
const hasSetDefault = useRef(false);
|
|
282
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
283
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
284
|
+
if (isHidden) return null;
|
|
279
285
|
useEffect(() => {
|
|
280
286
|
if (validation && !hasRegistered.current) {
|
|
281
287
|
hasRegistered.current = true;
|
|
@@ -315,7 +321,8 @@ var SmartCombobox = ({
|
|
|
315
321
|
value: value || "",
|
|
316
322
|
onChange: (newValue) => onChange(newValue),
|
|
317
323
|
placeholder: placeholder || (label ? `Select ${label.toLowerCase()}` : `Select ${field}`),
|
|
318
|
-
allowCustom
|
|
324
|
+
allowCustom,
|
|
325
|
+
isDisabled
|
|
319
326
|
}
|
|
320
327
|
) }),
|
|
321
328
|
error && /* @__PURE__ */ jsx("p", { className: "text-destructive text-sm mt-1", children: error })
|
|
@@ -337,14 +344,19 @@ var SmartFileUpload = ({
|
|
|
337
344
|
onError,
|
|
338
345
|
defaultValue,
|
|
339
346
|
info,
|
|
340
|
-
subLabel
|
|
347
|
+
subLabel,
|
|
348
|
+
disabled,
|
|
349
|
+
hidden
|
|
341
350
|
}) => {
|
|
351
|
+
const { formData, registerSubmitHook, unregisterSubmitHook } = useSmartForm();
|
|
342
352
|
const { value, error, onChange, fieldRef, registerValidation } = useFormField(field);
|
|
343
|
-
const { registerSubmitHook, unregisterSubmitHook } = useSmartForm();
|
|
344
353
|
const fieldDetection = useFieldDetection();
|
|
345
354
|
const hasRegistered = useRef(false);
|
|
346
355
|
const hasSetDefault = useRef(false);
|
|
347
356
|
const inputRef = useRef(null);
|
|
357
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
358
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
359
|
+
if (isHidden) return null;
|
|
348
360
|
useEffect(() => {
|
|
349
361
|
if (validation && !hasRegistered.current) {
|
|
350
362
|
hasRegistered.current = true;
|
|
@@ -502,10 +514,11 @@ var SmartFileUpload = ({
|
|
|
502
514
|
multiple,
|
|
503
515
|
onChange: onInputChange,
|
|
504
516
|
className: cn(error && "border-destructive"),
|
|
505
|
-
"data-field": field
|
|
517
|
+
"data-field": field,
|
|
518
|
+
disabled: isDisabled
|
|
506
519
|
}
|
|
507
520
|
),
|
|
508
|
-
(Array.isArray(value) ? value.length > 0 : !!value) && /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", onClick: clearSelection, children: "Clear" })
|
|
521
|
+
(Array.isArray(value) ? value.length > 0 : !!value) && /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", onClick: clearSelection, disabled: isDisabled, children: "Clear" })
|
|
509
522
|
] }),
|
|
510
523
|
normalizedFiles.length === 0 ? /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-muted-foreground", children: "No file selected" }) : /* @__PURE__ */ jsx("ul", { className: "mt-2 space-y-1", children: normalizedFiles.map((f, idx) => {
|
|
511
524
|
const isImage = f.type.startsWith("image/");
|
|
@@ -537,6 +550,7 @@ var SmartFileUpload = ({
|
|
|
537
550
|
size: "sm",
|
|
538
551
|
onClick: () => removeFileAt(idx),
|
|
539
552
|
"aria-label": `Remove ${f.name}`,
|
|
553
|
+
disabled: isDisabled,
|
|
540
554
|
children: "\u2715"
|
|
541
555
|
}
|
|
542
556
|
)
|
|
@@ -614,12 +628,18 @@ var SmartSlider = ({
|
|
|
614
628
|
valueFormatter = (value) => value.toString(),
|
|
615
629
|
defaultValue,
|
|
616
630
|
info,
|
|
617
|
-
subLabel
|
|
631
|
+
subLabel,
|
|
632
|
+
disabled,
|
|
633
|
+
hidden
|
|
618
634
|
}) => {
|
|
635
|
+
const { formData } = useSmartForm();
|
|
619
636
|
const { value, error, onChange, fieldRef, registerValidation } = useFormField(field);
|
|
620
637
|
const fieldDetection = useFieldDetection();
|
|
621
638
|
const hasRegistered = useRef(false);
|
|
622
639
|
const hasSetDefault = useRef(false);
|
|
640
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
641
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
642
|
+
if (isHidden) return null;
|
|
623
643
|
useEffect(() => {
|
|
624
644
|
if (validation && !hasRegistered.current) {
|
|
625
645
|
hasRegistered.current = true;
|
|
@@ -673,7 +693,8 @@ var SmartSlider = ({
|
|
|
673
693
|
max,
|
|
674
694
|
step,
|
|
675
695
|
className: `w-full ${error ? "border-destructive" : ""}`,
|
|
676
|
-
"data-field": field
|
|
696
|
+
"data-field": field,
|
|
697
|
+
disabled: isDisabled
|
|
677
698
|
}
|
|
678
699
|
),
|
|
679
700
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-between text-sm text-muted-foreground", children: [
|
|
@@ -702,8 +723,11 @@ var SmartDualRangeSlider = ({
|
|
|
702
723
|
defaultMinValue,
|
|
703
724
|
defaultMaxValue,
|
|
704
725
|
info,
|
|
705
|
-
subLabel
|
|
726
|
+
subLabel,
|
|
727
|
+
disabled,
|
|
728
|
+
hidden
|
|
706
729
|
}) => {
|
|
730
|
+
const { formData } = useSmartForm();
|
|
707
731
|
const minFormField = useFormField(minField);
|
|
708
732
|
const maxFormField = useFormField(maxField);
|
|
709
733
|
const fieldDetection = useFieldDetection();
|
|
@@ -711,6 +735,9 @@ var SmartDualRangeSlider = ({
|
|
|
711
735
|
const hasRegisteredMax = useRef(false);
|
|
712
736
|
const hasSetDefaultMin = useRef(false);
|
|
713
737
|
const hasSetDefaultMax = useRef(false);
|
|
738
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
739
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
740
|
+
if (isHidden) return null;
|
|
714
741
|
useEffect(() => {
|
|
715
742
|
if (minValidation && !hasRegisteredMin.current) {
|
|
716
743
|
hasRegisteredMin.current = true;
|
|
@@ -776,7 +803,8 @@ var SmartDualRangeSlider = ({
|
|
|
776
803
|
step,
|
|
777
804
|
className: `w-full ${combinedError ? "border-destructive" : ""}`,
|
|
778
805
|
"data-min-field": minField,
|
|
779
|
-
"data-max-field": maxField
|
|
806
|
+
"data-max-field": maxField,
|
|
807
|
+
disabled: isDisabled
|
|
780
808
|
}
|
|
781
809
|
),
|
|
782
810
|
showValues && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center text-sm", children: [
|
|
@@ -930,12 +958,18 @@ var SmartAutoSuggestTags = ({
|
|
|
930
958
|
defaultValue,
|
|
931
959
|
onTagCreate,
|
|
932
960
|
info,
|
|
933
|
-
subLabel
|
|
961
|
+
subLabel,
|
|
962
|
+
disabled,
|
|
963
|
+
hidden
|
|
934
964
|
}) => {
|
|
965
|
+
const { formData } = useSmartForm();
|
|
935
966
|
const { value, error, onChange, fieldRef, registerValidation } = useFormField(field);
|
|
936
967
|
const fieldDetection = useFieldDetection();
|
|
937
968
|
const hasRegistered = useRef(false);
|
|
938
969
|
const hasSetDefault = useRef(false);
|
|
970
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
971
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
972
|
+
if (isHidden) return null;
|
|
939
973
|
const [tags, setTags] = useState(initialOptions);
|
|
940
974
|
const [newTag, setNewTag] = useState("");
|
|
941
975
|
const selected = Array.isArray(value) ? value : [];
|
|
@@ -1021,9 +1055,10 @@ var SmartAutoSuggestTags = ({
|
|
|
1021
1055
|
/* @__PURE__ */ jsx("div", { ref: fieldRef, "data-field": field, children: /* @__PURE__ */ jsx("div", { className: cn(
|
|
1022
1056
|
"w-full rounded-md border border-input bg-background text-sm ring-offset-background",
|
|
1023
1057
|
"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
1024
|
-
error && "border-destructive focus-within:ring-destructive"
|
|
1058
|
+
error && "border-destructive focus-within:ring-destructive",
|
|
1059
|
+
isDisabled && "cursor-not-allowed opacity-50"
|
|
1025
1060
|
), children: /* @__PURE__ */ jsxs(Tags, { className: "w-full", children: [
|
|
1026
|
-
/* @__PURE__ */ jsxs(TagsTrigger, { className: "w-full px-3 py-2 border-0 bg-transparent", children: [
|
|
1061
|
+
/* @__PURE__ */ jsxs(TagsTrigger, { className: "w-full px-3 py-2 border-0 bg-transparent", disabled: isDisabled, children: [
|
|
1027
1062
|
selected.length === 0 && placeholder && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-sm", children: placeholder }),
|
|
1028
1063
|
selected.map((tagId) => {
|
|
1029
1064
|
const tag = tags.find((t) => t.id === tagId);
|
|
@@ -1044,7 +1079,8 @@ var SmartAutoSuggestTags = ({
|
|
|
1044
1079
|
{
|
|
1045
1080
|
onValueChange: setNewTag,
|
|
1046
1081
|
placeholder: `Search ${placeholder.toLowerCase()}...`,
|
|
1047
|
-
value: newTag
|
|
1082
|
+
value: newTag,
|
|
1083
|
+
disabled: isDisabled
|
|
1048
1084
|
}
|
|
1049
1085
|
),
|
|
1050
1086
|
/* @__PURE__ */ jsxs(TagsList, { children: [
|
|
@@ -1135,14 +1171,20 @@ var SmartBasicRichTextbox = ({
|
|
|
1135
1171
|
minHeight = "150px",
|
|
1136
1172
|
maxHeight = "400px",
|
|
1137
1173
|
info,
|
|
1138
|
-
subLabel
|
|
1174
|
+
subLabel,
|
|
1175
|
+
disabled,
|
|
1176
|
+
hidden
|
|
1139
1177
|
}) => {
|
|
1178
|
+
const { formData } = useSmartForm();
|
|
1140
1179
|
const { value, error, onChange, fieldRef, registerValidation } = useFormField(field);
|
|
1141
1180
|
const fieldDetection = useFieldDetection();
|
|
1142
1181
|
const hasRegistered = useRef(false);
|
|
1143
1182
|
const hasSetDefault = useRef(false);
|
|
1144
1183
|
const editorRef = useRef(null);
|
|
1145
1184
|
const [isFocused, setIsFocused] = useState(false);
|
|
1185
|
+
const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
|
|
1186
|
+
const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
|
|
1187
|
+
if (isHidden) return null;
|
|
1146
1188
|
useEffect(() => {
|
|
1147
1189
|
if (validation && !hasRegistered.current) {
|
|
1148
1190
|
hasRegistered.current = true;
|
|
@@ -1249,10 +1291,11 @@ var SmartBasicRichTextbox = ({
|
|
|
1249
1291
|
className: cn(
|
|
1250
1292
|
"w-full rounded-md border border-input bg-background",
|
|
1251
1293
|
"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
1252
|
-
error && "border-destructive focus-within:ring-destructive"
|
|
1294
|
+
error && "border-destructive focus-within:ring-destructive",
|
|
1295
|
+
isDisabled && "cursor-not-allowed opacity-50"
|
|
1253
1296
|
),
|
|
1254
1297
|
children: [
|
|
1255
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 p-1.5 border-b border-border bg-muted/30", children: [
|
|
1298
|
+
/* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-0.5 p-1.5 border-b border-border bg-muted/30", isDisabled && "pointer-events-none"), children: [
|
|
1256
1299
|
/* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1257
1300
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1258
1301
|
Button,
|
|
@@ -1265,6 +1308,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1265
1308
|
activeFormats.bold && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
1266
1309
|
),
|
|
1267
1310
|
onClick: toggleBold,
|
|
1311
|
+
disabled: isDisabled,
|
|
1268
1312
|
children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" })
|
|
1269
1313
|
}
|
|
1270
1314
|
) }),
|
|
@@ -1282,6 +1326,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1282
1326
|
activeFormats.italic && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
1283
1327
|
),
|
|
1284
1328
|
onClick: toggleItalic,
|
|
1329
|
+
disabled: isDisabled,
|
|
1285
1330
|
children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" })
|
|
1286
1331
|
}
|
|
1287
1332
|
) }),
|
|
@@ -1299,6 +1344,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1299
1344
|
activeFormats.underline && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
1300
1345
|
),
|
|
1301
1346
|
onClick: toggleUnderline,
|
|
1347
|
+
disabled: isDisabled,
|
|
1302
1348
|
children: /* @__PURE__ */ jsx(Underline, { className: "h-4 w-4" })
|
|
1303
1349
|
}
|
|
1304
1350
|
) }),
|
|
@@ -1317,6 +1363,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1317
1363
|
activeFormats.bulletList && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
1318
1364
|
),
|
|
1319
1365
|
onClick: toggleBulletList,
|
|
1366
|
+
disabled: isDisabled,
|
|
1320
1367
|
children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
|
|
1321
1368
|
}
|
|
1322
1369
|
) }),
|
|
@@ -1334,6 +1381,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1334
1381
|
activeFormats.numberedList && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
1335
1382
|
),
|
|
1336
1383
|
onClick: toggleNumberedList,
|
|
1384
|
+
disabled: isDisabled,
|
|
1337
1385
|
children: /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" })
|
|
1338
1386
|
}
|
|
1339
1387
|
) }),
|
|
@@ -1344,7 +1392,7 @@ var SmartBasicRichTextbox = ({
|
|
|
1344
1392
|
"div",
|
|
1345
1393
|
{
|
|
1346
1394
|
ref: editorRef,
|
|
1347
|
-
contentEditable:
|
|
1395
|
+
contentEditable: !isDisabled,
|
|
1348
1396
|
onInput: handleInput,
|
|
1349
1397
|
onKeyDown: handleKeyDown,
|
|
1350
1398
|
onFocus: handleFocus,
|