@rjsf/daisyui 6.1.2 → 6.2.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/dist/chakra-ui.esm.js +52 -23
- package/dist/chakra-ui.esm.js.map +3 -3
- package/dist/chakra-ui.umd.js +51 -22
- package/dist/index.cjs +51 -22
- package/dist/index.cjs.map +3 -3
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +9 -2
- package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/templates/ButtonTemplates/IconButton.js +5 -1
- package/lib/templates/ButtonTemplates/IconButton.js.map +1 -1
- package/lib/templates/ButtonTemplates/index.d.ts +3 -2
- package/lib/templates/ButtonTemplates/index.js +3 -2
- package/lib/templates/ButtonTemplates/index.js.map +1 -1
- package/lib/templates/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/templates/FieldTemplate/FieldTemplate.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 +8 -8
- package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +34 -18
- package/src/templates/ButtonTemplates/IconButton.tsx +18 -1
- package/src/templates/ButtonTemplates/index.ts +3 -2
- package/src/templates/FieldTemplate/FieldTemplate.tsx +1 -0
- package/src/templates/Templates.tsx +10 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/daisyui",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "Daisy UI components for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -68,19 +68,19 @@
|
|
|
68
68
|
"@fortawesome/react-fontawesome": "^3.1.0",
|
|
69
69
|
"date-fns": "^4.1.0",
|
|
70
70
|
"react-day-picker": "^9.11.1",
|
|
71
|
-
"tailwindcss": "^4.1.
|
|
71
|
+
"tailwindcss": "^4.1.18"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@rjsf/core": "^6.x",
|
|
75
|
-
"@rjsf/utils": "^6.x",
|
|
74
|
+
"@rjsf/core": "^6.2.x",
|
|
75
|
+
"@rjsf/utils": "^6.2.x",
|
|
76
76
|
"daisyui": "^5.0.29",
|
|
77
77
|
"react": ">=18"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@rjsf/core": "^6.
|
|
81
|
-
"@rjsf/snapshot-tests": "^6.
|
|
82
|
-
"@rjsf/utils": "^6.
|
|
83
|
-
"@rjsf/validator-ajv8": "^6.
|
|
80
|
+
"@rjsf/core": "^6.2.0",
|
|
81
|
+
"@rjsf/snapshot-tests": "^6.2.0",
|
|
82
|
+
"@rjsf/utils": "^6.2.0",
|
|
83
|
+
"@rjsf/validator-ajv8": "^6.2.0",
|
|
84
84
|
"@testing-library/dom": "^10.4.1",
|
|
85
85
|
"@testing-library/jest-dom": "^6.9.1",
|
|
86
86
|
"@testing-library/react": "^16.3.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent, useCallback } from 'react';
|
|
1
|
+
import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
WidgetProps,
|
|
4
4
|
StrictRJSFSchema,
|
|
@@ -46,7 +46,9 @@ export default function BaseInputTemplate<
|
|
|
46
46
|
type,
|
|
47
47
|
label,
|
|
48
48
|
placeholder,
|
|
49
|
+
registry,
|
|
49
50
|
} = props;
|
|
51
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
50
52
|
|
|
51
53
|
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
52
54
|
let className = 'input input-bordered w-full';
|
|
@@ -74,29 +76,43 @@ export default function BaseInputTemplate<
|
|
|
74
76
|
[onFocus, id],
|
|
75
77
|
);
|
|
76
78
|
|
|
79
|
+
const _onClear = useCallback(
|
|
80
|
+
(e: MouseEvent) => {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
e.stopPropagation();
|
|
83
|
+
onChange(options.emptyValue ?? '');
|
|
84
|
+
},
|
|
85
|
+
[onChange, options.emptyValue],
|
|
86
|
+
);
|
|
87
|
+
|
|
77
88
|
return (
|
|
78
89
|
<>
|
|
79
90
|
<div className='form-control'>
|
|
80
91
|
<label htmlFor={id} className='label hidden' style={{ display: 'none' }}>
|
|
81
92
|
<span className='label-text'>{label}</span>
|
|
82
93
|
</label>
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
<div style={{ position: 'relative' }}>
|
|
95
|
+
<input
|
|
96
|
+
id={id}
|
|
97
|
+
name={htmlName || id}
|
|
98
|
+
value={value || value === 0 ? value : ''}
|
|
99
|
+
placeholder={placeholder}
|
|
100
|
+
required={required}
|
|
101
|
+
disabled={disabled || readonly}
|
|
102
|
+
autoFocus={autofocus}
|
|
103
|
+
className={className}
|
|
104
|
+
multiple={isMulti}
|
|
105
|
+
{...rest}
|
|
106
|
+
{...htmlInputProps}
|
|
107
|
+
onChange={onChangeOverride || _onChange}
|
|
108
|
+
onBlur={_onBlur}
|
|
109
|
+
onFocus={_onFocus}
|
|
110
|
+
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
111
|
+
/>
|
|
112
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
113
|
+
<ClearButton registry={registry} onClick={_onClear} />
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
100
116
|
</div>
|
|
101
117
|
{Array.isArray(schema.examples) && (
|
|
102
118
|
<datalist id={examplesId(id)}>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
2
|
-
import { faCopy, faArrowDown, faArrowUp, faTrash } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { faCopy, faArrowDown, faArrowUp, faTrash, faXmark } from '@fortawesome/free-solid-svg-icons';
|
|
3
3
|
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
4
4
|
|
|
5
5
|
import DaisyUIButton from './DaisyUIButton';
|
|
@@ -60,3 +60,20 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
60
60
|
/>
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
65
|
+
props: IconButtonProps<T, S, F>,
|
|
66
|
+
) {
|
|
67
|
+
const {
|
|
68
|
+
registry: { translateString },
|
|
69
|
+
} = props;
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<DaisyUIButton
|
|
73
|
+
title={translateString(TranslatableString.ClearButton)}
|
|
74
|
+
{...props}
|
|
75
|
+
iconType='default'
|
|
76
|
+
icon={faXmark as IconDefinition}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import AddButton from './AddButton';
|
|
2
2
|
import SubmitButton from './SubmitButton';
|
|
3
|
-
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton';
|
|
3
|
+
import { ClearButton, CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from './IconButton';
|
|
4
4
|
|
|
5
5
|
export { AddButton };
|
|
6
|
-
export { CopyButton, MoveDownButton, MoveUpButton, RemoveButton };
|
|
6
|
+
export { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton };
|
|
7
7
|
export { SubmitButton };
|
|
8
8
|
|
|
9
9
|
// Create a default export with all button templates
|
|
@@ -14,6 +14,7 @@ const buttonTemplates = {
|
|
|
14
14
|
MoveUpButton,
|
|
15
15
|
RemoveButton,
|
|
16
16
|
SubmitButton,
|
|
17
|
+
ClearButton,
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export default buttonTemplates;
|
|
@@ -4,7 +4,15 @@ import ArrayFieldItemButtonsTemplate from './ArrayFieldItemButtonsTemplate';
|
|
|
4
4
|
import ArrayFieldItemTemplate from './ArrayFieldItemTemplate';
|
|
5
5
|
import ArrayFieldTemplate from './ArrayFieldTemplate/ArrayFieldTemplate';
|
|
6
6
|
import BaseInputTemplate from './BaseInputTemplate/BaseInputTemplate';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
AddButton,
|
|
9
|
+
CopyButton,
|
|
10
|
+
MoveDownButton,
|
|
11
|
+
MoveUpButton,
|
|
12
|
+
RemoveButton,
|
|
13
|
+
SubmitButton,
|
|
14
|
+
ClearButton,
|
|
15
|
+
} from './ButtonTemplates';
|
|
8
16
|
import DescriptionField from './DescriptionField';
|
|
9
17
|
import ErrorList from './ErrorList';
|
|
10
18
|
import FieldErrorTemplate from './FieldErrorTemplate';
|
|
@@ -48,6 +56,7 @@ export function generateTemplates<
|
|
|
48
56
|
MoveDownButton,
|
|
49
57
|
MoveUpButton,
|
|
50
58
|
RemoveButton,
|
|
59
|
+
ClearButton,
|
|
51
60
|
},
|
|
52
61
|
DescriptionFieldTemplate: DescriptionField,
|
|
53
62
|
ErrorListTemplate: ErrorList,
|