@rjsf/chakra-ui 6.1.2 → 6.2.5
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/dist/chakra-ui.esm.js +52 -32
- package/dist/chakra-ui.esm.js.map +4 -4
- package/dist/chakra-ui.umd.js +42 -23
- package/dist/index.cjs +201 -181
- package/dist/index.cjs.map +4 -4
- package/lib/AltDateTimeWidget/AltDateTimeWidget.d.ts +1 -12
- package/lib/AltDateTimeWidget/AltDateTimeWidget.js +2 -7
- package/lib/AltDateTimeWidget/AltDateTimeWidget.js.map +1 -1
- package/lib/AltDateWidget/AltDateWidget.d.ts +1 -12
- package/lib/AltDateWidget/AltDateWidget.js +7 -12
- package/lib/AltDateWidget/AltDateWidget.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +10 -2
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +1 -0
- package/lib/IconButton/IconButton.js +5 -1
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/Templates/Templates.js +2 -1
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -7
- package/src/AltDateTimeWidget/AltDateTimeWidget.tsx +5 -10
- package/src/AltDateWidget/AltDateWidget.tsx +14 -15
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +14 -1
- package/src/IconButton/IconButton.tsx +10 -1
- package/src/Templates/Templates.ts +2 -1
package/dist/chakra-ui.umd.js
CHANGED
|
@@ -142,12 +142,22 @@
|
|
|
142
142
|
autofocus,
|
|
143
143
|
placeholder,
|
|
144
144
|
disabled,
|
|
145
|
-
uiSchema
|
|
145
|
+
uiSchema,
|
|
146
|
+
registry
|
|
146
147
|
} = props;
|
|
147
148
|
const inputProps = utils.getInputProps(schema, type, options);
|
|
149
|
+
const { ClearButton: ClearButton2 } = registry.templates.ButtonTemplates;
|
|
148
150
|
const _onChange = ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2);
|
|
149
151
|
const _onBlur = ({ target }) => onBlur(id, target && target.value);
|
|
150
152
|
const _onFocus = ({ target }) => onFocus(id, target && target.value);
|
|
153
|
+
const onClear = react.useCallback(
|
|
154
|
+
(e) => {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
e.stopPropagation();
|
|
157
|
+
onChange(options.emptyValue ?? "");
|
|
158
|
+
},
|
|
159
|
+
[onChange, options.emptyValue]
|
|
160
|
+
);
|
|
151
161
|
const chakraProps = getChakra({ });
|
|
152
162
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
153
163
|
Field,
|
|
@@ -176,6 +186,7 @@
|
|
|
176
186
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
177
187
|
}
|
|
178
188
|
),
|
|
189
|
+
options.allowClearTextInputs && !readonly && !disabled && value && /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick: onClear }),
|
|
179
190
|
Array.isArray(schema.examples) ? /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: utils.examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
180
191
|
return /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, example);
|
|
181
192
|
}) }) : null
|
|
@@ -262,6 +273,12 @@
|
|
|
262
273
|
}
|
|
263
274
|
);
|
|
264
275
|
}
|
|
276
|
+
function ClearButton(props) {
|
|
277
|
+
const {
|
|
278
|
+
registry: { translateString }
|
|
279
|
+
} = props;
|
|
280
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChakraIconButton_default, { title: translateString(utils.TranslatableString.ClearButton), ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) });
|
|
281
|
+
}
|
|
265
282
|
function FieldErrorTemplate(props) {
|
|
266
283
|
const { errors = [], fieldPathId } = props;
|
|
267
284
|
if (errors.length === 0) {
|
|
@@ -557,7 +574,8 @@
|
|
|
557
574
|
MoveDownButton,
|
|
558
575
|
MoveUpButton,
|
|
559
576
|
RemoveButton,
|
|
560
|
-
SubmitButton
|
|
577
|
+
SubmitButton,
|
|
578
|
+
ClearButton
|
|
561
579
|
},
|
|
562
580
|
DescriptionFieldTemplate: DescriptionField,
|
|
563
581
|
ErrorListTemplate: ErrorList,
|
|
@@ -573,10 +591,29 @@
|
|
|
573
591
|
};
|
|
574
592
|
}
|
|
575
593
|
var Templates_default = generateTemplates();
|
|
576
|
-
function
|
|
577
|
-
|
|
594
|
+
function AltDateTimeWidget({
|
|
595
|
+
time = true,
|
|
596
|
+
...props
|
|
597
|
+
}) {
|
|
598
|
+
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
599
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { ...props, time });
|
|
600
|
+
}
|
|
601
|
+
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
602
|
+
function AltDateWidget({
|
|
603
|
+
autofocus = false,
|
|
604
|
+
disabled = false,
|
|
605
|
+
readonly = false,
|
|
606
|
+
time = false,
|
|
607
|
+
options,
|
|
608
|
+
...props
|
|
609
|
+
}) {
|
|
610
|
+
const { id, onBlur, onFocus, registry } = props;
|
|
578
611
|
const { translateString } = registry;
|
|
579
|
-
const {
|
|
612
|
+
const realOptions = { yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2], ...options };
|
|
613
|
+
const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps({
|
|
614
|
+
...props,
|
|
615
|
+
options: realOptions
|
|
616
|
+
});
|
|
580
617
|
const chakraProps = getChakra({ uiSchema: props.uiSchema });
|
|
581
618
|
return /* @__PURE__ */ jsxRuntime.jsxs(react$1.FieldsetRoot, { ...chakraProps, children: [
|
|
582
619
|
/* @__PURE__ */ jsxRuntime.jsx(react$1.Box, { display: "flex", flexWrap: "wrap", alignItems: "center", children: elements.map((elemProps, i) => {
|
|
@@ -605,25 +642,7 @@
|
|
|
605
642
|
] })
|
|
606
643
|
] });
|
|
607
644
|
}
|
|
608
|
-
AltDateWidget.defaultProps = {
|
|
609
|
-
autofocus: false,
|
|
610
|
-
disabled: false,
|
|
611
|
-
readonly: false,
|
|
612
|
-
time: false,
|
|
613
|
-
options: {
|
|
614
|
-
yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
645
|
var AltDateWidget_default = AltDateWidget;
|
|
618
|
-
function AltDateTimeWidget(props) {
|
|
619
|
-
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
620
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { ...props, time: true });
|
|
621
|
-
}
|
|
622
|
-
AltDateTimeWidget.defaultProps = {
|
|
623
|
-
...AltDateWidget_default.defaultProps,
|
|
624
|
-
time: true
|
|
625
|
-
};
|
|
626
|
-
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
627
646
|
var Checkbox = react.forwardRef(function Checkbox2(props, ref) {
|
|
628
647
|
const { icon, children, inputProps, rootRef, ...rest } = props;
|
|
629
648
|
return /* @__PURE__ */ jsxRuntime.jsxs(react$1.Checkbox.Root, { ref: rootRef, ...rest, children: [
|