@fuf-stack/uniform 0.3.2 → 0.5.0
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/FieldArray/index.cjs +13 -0
- package/dist/FieldArray/index.cjs.map +1 -0
- package/dist/FieldArray/index.d.cts +8 -0
- package/dist/FieldArray/index.d.ts +8 -0
- package/dist/FieldArray/index.js +13 -0
- package/dist/FieldArray/index.js.map +1 -0
- package/dist/FieldArray-DUvn98Fe.d.cts +27 -0
- package/dist/FieldArray-DUvn98Fe.d.ts +27 -0
- package/dist/Form/index.cjs +2 -2
- package/dist/Form/index.js +1 -1
- package/dist/Grid/index.cjs +2 -2
- package/dist/Grid/index.js +1 -1
- package/dist/Input/index.cjs +3 -3
- package/dist/Input/index.d.cts +2 -2
- package/dist/Input/index.d.ts +2 -2
- package/dist/Input/index.js +2 -2
- package/dist/{Input-B_rP1h4X.d.cts → Input-B6dNQiiD.d.cts} +3 -1
- package/dist/{Input-B_rP1h4X.d.ts → Input-B6dNQiiD.d.ts} +3 -1
- package/dist/RadioGroup/index.cjs +13 -0
- package/dist/RadioGroup/index.cjs.map +1 -0
- package/dist/RadioGroup/index.d.cts +7 -0
- package/dist/RadioGroup/index.d.ts +7 -0
- package/dist/RadioGroup/index.js +13 -0
- package/dist/RadioGroup/index.js.map +1 -0
- package/dist/RadioGroup-BU4K9cnS.d.cts +40 -0
- package/dist/RadioGroup-BU4K9cnS.d.ts +40 -0
- package/dist/Select/index.cjs +13 -0
- package/dist/Select/index.cjs.map +1 -0
- package/dist/Select/index.d.cts +8 -0
- package/dist/Select/index.d.ts +8 -0
- package/dist/Select/index.js +13 -0
- package/dist/Select/index.js.map +1 -0
- package/dist/Select-Mp6Y00dT.d.cts +40 -0
- package/dist/Select-Mp6Y00dT.d.ts +40 -0
- package/dist/SubmitButton/index.cjs +2 -2
- package/dist/SubmitButton/index.js +1 -1
- package/dist/Switch/index.cjs +13 -0
- package/dist/Switch/index.cjs.map +1 -0
- package/dist/Switch/index.d.cts +7 -0
- package/dist/Switch/index.d.ts +7 -0
- package/dist/Switch/index.js +13 -0
- package/dist/Switch/index.js.map +1 -0
- package/dist/Switch-DmjDKgKs.d.cts +20 -0
- package/dist/Switch-DmjDKgKs.d.ts +20 -0
- package/dist/TextArea/index.cjs +13 -0
- package/dist/TextArea/index.cjs.map +1 -0
- package/dist/TextArea/index.d.cts +8 -0
- package/dist/TextArea/index.d.ts +8 -0
- package/dist/TextArea/index.js +13 -0
- package/dist/TextArea/index.js.map +1 -0
- package/dist/TextArea-B-sKvTkd.d.cts +25 -0
- package/dist/TextArea-B-sKvTkd.d.ts +25 -0
- package/dist/{chunk-3DMR7T4D.js → chunk-2Z3YMYNN.js} +8 -6
- package/dist/chunk-2Z3YMYNN.js.map +1 -0
- package/dist/chunk-4IT2WVQK.cjs +76 -0
- package/dist/chunk-4IT2WVQK.cjs.map +1 -0
- package/dist/{chunk-TEJGV6NC.js → chunk-5FMJUJ7H.js} +2 -2
- package/dist/chunk-5FMJUJ7H.js.map +1 -0
- package/dist/{chunk-ZPFKVKGV.cjs → chunk-6GN255GP.cjs} +4 -4
- package/dist/chunk-6GN255GP.cjs.map +1 -0
- package/dist/chunk-6NZVSPFX.js +76 -0
- package/dist/chunk-6NZVSPFX.js.map +1 -0
- package/dist/{chunk-XUKBLFTR.cjs → chunk-AGAYQTFD.cjs} +4 -4
- package/dist/chunk-AGAYQTFD.cjs.map +1 -0
- package/dist/chunk-BIJVBXOG.js +205 -0
- package/dist/chunk-BIJVBXOG.js.map +1 -0
- package/dist/{chunk-4BELEHDQ.cjs → chunk-BNTEIMNY.cjs} +5 -5
- package/dist/chunk-BNTEIMNY.cjs.map +1 -0
- package/dist/chunk-CRKMTDKU.js +239 -0
- package/dist/chunk-CRKMTDKU.js.map +1 -0
- package/dist/chunk-EXYTFHEJ.js +81 -0
- package/dist/chunk-EXYTFHEJ.js.map +1 -0
- package/dist/{chunk-22AA557I.cjs → chunk-HT3LKDHX.cjs} +4 -4
- package/dist/chunk-HT3LKDHX.cjs.map +1 -0
- package/dist/chunk-I22ICCUC.cjs +205 -0
- package/dist/chunk-I22ICCUC.cjs.map +1 -0
- package/dist/chunk-I26DVRVR.js +287 -0
- package/dist/chunk-I26DVRVR.js.map +1 -0
- package/dist/{chunk-6XKDXQ4A.js → chunk-KFRKKWZT.js} +3 -3
- package/dist/chunk-KFRKKWZT.js.map +1 -0
- package/dist/chunk-NVJKXQ5W.cjs +239 -0
- package/dist/chunk-NVJKXQ5W.cjs.map +1 -0
- package/dist/chunk-OS4SMYPO.cjs +287 -0
- package/dist/chunk-OS4SMYPO.cjs.map +1 -0
- package/dist/{chunk-FNVT6LS4.js → chunk-OV5RMSYD.js} +2 -2
- package/dist/{chunk-22AA557I.cjs.map → chunk-OV5RMSYD.js.map} +1 -1
- package/dist/{chunk-4MEKDDB2.js → chunk-PDCEKC3G.js} +2 -2
- package/dist/chunk-PDCEKC3G.js.map +1 -0
- package/dist/{chunk-2O53LMR3.cjs → chunk-VO7ZM3KY.cjs} +11 -9
- package/dist/chunk-VO7ZM3KY.cjs.map +1 -0
- package/dist/chunk-XY7ZZARS.cjs +81 -0
- package/dist/chunk-XY7ZZARS.cjs.map +1 -0
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/index.cjs +27 -7
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +29 -9
- package/dist/partials/FieldCopyTestIdButton/index.cjs +2 -2
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -1
- package/package.json +41 -17
- package/dist/chunk-2O53LMR3.cjs.map +0 -1
- package/dist/chunk-3DMR7T4D.js.map +0 -1
- package/dist/chunk-4BELEHDQ.cjs.map +0 -1
- package/dist/chunk-4MEKDDB2.js.map +0 -1
- package/dist/chunk-6XKDXQ4A.js.map +0 -1
- package/dist/chunk-FNVT6LS4.js.map +0 -1
- package/dist/chunk-TEJGV6NC.js.map +0 -1
- package/dist/chunk-XUKBLFTR.cjs.map +0 -1
- package/dist/chunk-ZPFKVKGV.cjs.map +0 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkHT3LKDHXcjs = require('./chunk-HT3LKDHX.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkWQRM7G4Ccjs = require('./chunk-WQRM7G4C.cjs');
|
|
10
|
+
|
|
11
|
+
// src/Select/Select.tsx
|
|
12
|
+
var _reacthookform = require('react-hook-form');
|
|
13
|
+
var _reactselect = require('react-select'); var _reactselect2 = _interopRequireDefault(_reactselect);
|
|
14
|
+
var _select = require('@nextui-org/select');
|
|
15
|
+
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
16
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
17
|
+
var InputComponent = (props) => {
|
|
18
|
+
const testId = `${props.selectProps["data-testid"]}_input`;
|
|
19
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Input, { "data-testid": testId, ...props });
|
|
20
|
+
};
|
|
21
|
+
var OptionComponent = (props) => {
|
|
22
|
+
const testId = `${props.selectProps["data-testid"]}_option_${_nullishCoalesce(_optionalChain([props, 'optionalAccess', _ => _.data, 'optionalAccess', _2 => _2.testId]), () => ( _optionalChain([props, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.value])))}`;
|
|
23
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Option, { ...props }) });
|
|
24
|
+
};
|
|
25
|
+
var DropdownIndicatorComponent = (props) => {
|
|
26
|
+
const testId = _optionalChain([props, 'optionalAccess', _5 => _5.selectProps, 'access', _6 => _6["data-testid"]]);
|
|
27
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": `${testId}_dropdown`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.DropdownIndicator, { ...props }) });
|
|
28
|
+
};
|
|
29
|
+
var selectVariants = _pixelutils.tv.call(void 0, {
|
|
30
|
+
slots: {
|
|
31
|
+
clearIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
|
|
32
|
+
control: "rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400",
|
|
33
|
+
crossIcon: "",
|
|
34
|
+
downChevron: "",
|
|
35
|
+
dropdownIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500",
|
|
36
|
+
group: "",
|
|
37
|
+
groupHeading: "mb-1 ml-3 mt-2 text-sm text-neutral-500",
|
|
38
|
+
indicatorsContainer: "gap-1 p-1",
|
|
39
|
+
indicatorSeparator: "bg-gray-300 dark:bg-default-300",
|
|
40
|
+
input: "py-0.5 pl-1",
|
|
41
|
+
loadingIndicator: "",
|
|
42
|
+
loadingMessage: "",
|
|
43
|
+
menu: "mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50",
|
|
44
|
+
menuList: "",
|
|
45
|
+
// ensure menu has same z-index as modal so it is visible when rendered in modal
|
|
46
|
+
// see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
|
|
47
|
+
menuPortal: "!z-50",
|
|
48
|
+
multiValue: "items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100",
|
|
49
|
+
multiValueContainer: "",
|
|
50
|
+
multiValueLabel: "py-0.5 leading-6",
|
|
51
|
+
multiValueRemove: "rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
|
|
52
|
+
noOptionsMessage: "rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100",
|
|
53
|
+
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
54
|
+
placeholder: "py-0.5 pl-1 text-neutral-500",
|
|
55
|
+
selectContainer: "",
|
|
56
|
+
singleValue: "!ml-1 !leading-7",
|
|
57
|
+
valueContainer: "gap-1 p-1"
|
|
58
|
+
},
|
|
59
|
+
variants: {
|
|
60
|
+
invalid: {
|
|
61
|
+
true: {
|
|
62
|
+
control: "border-danger hover:border-danger dark:border-danger hover:dark:border-danger"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
focused: {
|
|
66
|
+
true: {
|
|
67
|
+
option: "bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
optionSelected: {
|
|
71
|
+
true: { option: "bg-gray-300 dark:bg-default-300" }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
var Select = ({
|
|
76
|
+
className = void 0,
|
|
77
|
+
clearable = true,
|
|
78
|
+
disabled = false,
|
|
79
|
+
filterOption = void 0,
|
|
80
|
+
inputValue = void 0,
|
|
81
|
+
label: _label = void 0,
|
|
82
|
+
loading = false,
|
|
83
|
+
multiSelect = false,
|
|
84
|
+
name,
|
|
85
|
+
onInputChange = void 0,
|
|
86
|
+
options,
|
|
87
|
+
placeholder = void 0,
|
|
88
|
+
testId: _testId = void 0
|
|
89
|
+
}) => {
|
|
90
|
+
const { control, getFieldState } = _chunkWQRM7G4Ccjs.useFormContext.call(void 0, );
|
|
91
|
+
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
92
|
+
const {
|
|
93
|
+
label,
|
|
94
|
+
getLabelProps,
|
|
95
|
+
getTriggerProps,
|
|
96
|
+
getValueProps,
|
|
97
|
+
getHelperWrapperProps,
|
|
98
|
+
getErrorMessageProps
|
|
99
|
+
} = _select.useSelect.call(void 0, {
|
|
100
|
+
isLoading: loading,
|
|
101
|
+
isInvalid: invalid,
|
|
102
|
+
isRequired: required,
|
|
103
|
+
isDisabled: disabled,
|
|
104
|
+
errorMessage: JSON.stringify(error),
|
|
105
|
+
label: _label,
|
|
106
|
+
labelPlacement: "outside",
|
|
107
|
+
children: []
|
|
108
|
+
});
|
|
109
|
+
const {
|
|
110
|
+
clearIndicator: clearIndicatorSlot,
|
|
111
|
+
control: controlSlot,
|
|
112
|
+
dropdownIndicator: dropdownIndicatorSlot,
|
|
113
|
+
groupHeading: groupHeadingSlot,
|
|
114
|
+
indicatorsContainer: indicatorContainerSlot,
|
|
115
|
+
indicatorSeparator: indicatorSeparatorSlot,
|
|
116
|
+
input: inputSlot,
|
|
117
|
+
menu: menuSlot,
|
|
118
|
+
menuPortal: menuPortalSlot,
|
|
119
|
+
multiValue: multiValueSlot,
|
|
120
|
+
multiValueLabel: multiValueLabelSlot,
|
|
121
|
+
multiValueRemove: multiValueRemoveSlot,
|
|
122
|
+
noOptionsMessage: noOptionsMessageSlot,
|
|
123
|
+
option: optionSlot,
|
|
124
|
+
placeholder: placeholderSlot,
|
|
125
|
+
singleValue: singleValueSlot,
|
|
126
|
+
valueContainer: valueContainerSlot
|
|
127
|
+
} = selectVariants({ invalid });
|
|
128
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
129
|
+
_reacthookform.Controller,
|
|
130
|
+
{
|
|
131
|
+
control,
|
|
132
|
+
name,
|
|
133
|
+
render: ({
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
135
|
+
field: { onChange, value, ref, onBlur }
|
|
136
|
+
}) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _pixelutils.cn.call(void 0, className, "mt-2"), "data-testid": `${testId}_select`, children: [
|
|
137
|
+
label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
138
|
+
"label",
|
|
139
|
+
{
|
|
140
|
+
htmlFor: `react-select-${name}-input`,
|
|
141
|
+
className: `${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`,
|
|
142
|
+
children: [
|
|
143
|
+
label,
|
|
144
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHT3LKDHXcjs.FieldCopyTestIdButton_default, { testId })
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
149
|
+
_reactselect2.default,
|
|
150
|
+
{
|
|
151
|
+
"aria-errormessage": "",
|
|
152
|
+
"aria-invalid": invalid,
|
|
153
|
+
"data-testid": `${testId}_select`,
|
|
154
|
+
...() => {
|
|
155
|
+
const { className: _className, ...rest } = getTriggerProps();
|
|
156
|
+
return rest;
|
|
157
|
+
},
|
|
158
|
+
"aria-labelledby": _optionalChain([getTriggerProps, 'call', _7 => _7(), 'access', _8 => _8["aria-labelledby"], 'optionalAccess', _9 => _9.split, 'call', _10 => _10(" "), 'access', _11 => _11[1]]),
|
|
159
|
+
classNames: {
|
|
160
|
+
control: ({ isFocused }) => (
|
|
161
|
+
// border focus style
|
|
162
|
+
controlSlot({
|
|
163
|
+
className: !invalid && isFocused && "!border-primary"
|
|
164
|
+
})
|
|
165
|
+
),
|
|
166
|
+
placeholder: () => placeholderSlot(),
|
|
167
|
+
input: () => inputSlot(),
|
|
168
|
+
valueContainer: () => valueContainerSlot(),
|
|
169
|
+
singleValue: () => singleValueSlot({
|
|
170
|
+
className: `${getValueProps().className}`
|
|
171
|
+
}),
|
|
172
|
+
multiValue: () => multiValueSlot(),
|
|
173
|
+
multiValueLabel: () => multiValueLabelSlot({
|
|
174
|
+
className: `${getValueProps().className}`
|
|
175
|
+
}),
|
|
176
|
+
multiValueRemove: () => multiValueRemoveSlot(),
|
|
177
|
+
indicatorsContainer: () => indicatorContainerSlot(),
|
|
178
|
+
clearIndicator: () => clearIndicatorSlot(),
|
|
179
|
+
indicatorSeparator: () => indicatorSeparatorSlot(),
|
|
180
|
+
dropdownIndicator: () => dropdownIndicatorSlot(),
|
|
181
|
+
menu: () => menuSlot(),
|
|
182
|
+
groupHeading: () => groupHeadingSlot(),
|
|
183
|
+
option: ({ isFocused, isSelected }) => optionSlot({
|
|
184
|
+
focused: isFocused,
|
|
185
|
+
optionSelected: isSelected
|
|
186
|
+
}),
|
|
187
|
+
noOptionsMessage: () => noOptionsMessageSlot(),
|
|
188
|
+
menuPortal: () => menuPortalSlot()
|
|
189
|
+
},
|
|
190
|
+
components: {
|
|
191
|
+
Input: InputComponent,
|
|
192
|
+
Option: OptionComponent,
|
|
193
|
+
DropdownIndicator: DropdownIndicatorComponent
|
|
194
|
+
},
|
|
195
|
+
filterOption,
|
|
196
|
+
instanceId: name,
|
|
197
|
+
inputValue,
|
|
198
|
+
isClearable: clearable,
|
|
199
|
+
isDisabled: disabled,
|
|
200
|
+
isLoading: loading,
|
|
201
|
+
isMulti: multiSelect,
|
|
202
|
+
options,
|
|
203
|
+
placeholder,
|
|
204
|
+
unstyled: true,
|
|
205
|
+
onChange: (option) => {
|
|
206
|
+
if (multiSelect) {
|
|
207
|
+
const transformedOptions = [];
|
|
208
|
+
_optionalChain([option, 'optionalAccess', _12 => _12.forEach, 'call', _13 => _13((o) => {
|
|
209
|
+
transformedOptions.push(o.value);
|
|
210
|
+
})]);
|
|
211
|
+
onChange(transformedOptions);
|
|
212
|
+
} else {
|
|
213
|
+
onChange(option && option.value);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
onInputChange,
|
|
217
|
+
menuPortalTarget: _optionalChain([document, 'access', _14 => _14.getElementById, 'call', _15 => _15("modal_body"), 'optionalAccess', _16 => _16.parentNode, 'optionalAccess', _17 => _17.parentNode]) || document.body,
|
|
218
|
+
value: options.find((option) => option.value === value),
|
|
219
|
+
onBlur,
|
|
220
|
+
name,
|
|
221
|
+
ref
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
error && // eslint-disable-next-line react/jsx-props-no-spreading
|
|
225
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getErrorMessageProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQTL5FREEcjs.FieldValidationError_default, { error }) }) })
|
|
226
|
+
] })
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
};
|
|
230
|
+
var Select_default = Select;
|
|
231
|
+
|
|
232
|
+
// src/Select/index.ts
|
|
233
|
+
var Select_default2 = Select_default;
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
239
|
+
//# sourceMappingURL=chunk-NVJKXQ5W.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":";;;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,UAAU;AAiDd,cAuJG,YAvJH;AALT,IAAM,iBAA0C,CAAC,UAAU;AAG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AAE,WAAW,WAAW,MAC/B,WAAW;AAAA,gBACT,SAAS;AAAA,gBACT,gBAAgB;AAAA,cAClB,CAAC;AAAA,cACH,kBAAkB,MAAM,qBAAqB;AAAA,cAC7C,YAAY,MAAM,eAAe;AAAA,YACnC;AAAA,YACA,YAAY;AAAA,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,mBAAmB;AAAA,YACrB;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ;AAAA,YACA,aAAa;AAAA,YACb,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,UAAQ;AAAA,YACR,UAAU,CAAC,WAAW;AACpB,kBAAI,aAAa;AACf,sBAAM,qBAA+B,CAAC;AAEtC,wBAAQ,QAAQ,CAAC,MAAyB;AACxC,qCAAmB,KAAK,EAAE,KAAK;AAAA,gBACjC,CAAC;AACD,yBAAS,kBAAkB;AAAA,cAC7B,OAAO;AAEL,yBAAS,UAAU,OAAO,KAAK;AAAA,cACjC;AAAA,YACF;AAAA,YACA;AAAA,YAEA,kBACG,SAAS,eAAe,YAAY,GAAG,YACpC,cAA8B,SAAS;AAAA,YAE7C,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA,YACtD;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF;AAAA,QACC;AAAA,QAEC,oBAAC,SAAK,GAAG,sBAAsB,GAE7B,8BAAC,SAAK,GAAG,qBAAqB,GAC5B,8BAAC,gCAAqB,OAAc,GACtC,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;ACtTf,IAAOA,kBAAQ","sourcesContent":["import type { Props } from 'react-select';\n\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\nexport interface SelectProps {\n /** CSS class name */\n className?: string; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_option_${props?.data?.testId ?? props?.data?.value}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\nexport const selectVariants = tv({\n slots: {\n clearIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n control:\n 'rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-neutral-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-gray-300 dark:bg-default-300',\n input: 'py-0.5 pl-1',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue:\n 'items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n noOptionsMessage:\n 'rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-neutral-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control:\n 'border-danger hover:border-danger dark:border-danger hover:dark:border-danger',\n },\n },\n focused: {\n true: {\n option:\n 'bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200',\n },\n },\n optionSelected: {\n true: { option: 'bg-gray-300 dark:bg-default-300' },\n },\n },\n});\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const {\n label,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n getHelperWrapperProps,\n getErrorMessageProps,\n } = useSelect({\n isLoading: loading,\n isInvalid: invalid,\n isRequired: required,\n isDisabled: disabled,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'outside',\n children: [],\n });\n\n const {\n clearIndicator: clearIndicatorSlot,\n control: controlSlot,\n dropdownIndicator: dropdownIndicatorSlot,\n groupHeading: groupHeadingSlot,\n indicatorsContainer: indicatorContainerSlot,\n indicatorSeparator: indicatorSeparatorSlot,\n input: inputSlot,\n menu: menuSlot,\n menuPortal: menuPortalSlot,\n multiValue: multiValueSlot,\n multiValueLabel: multiValueLabelSlot,\n multiValueRemove: multiValueRemoveSlot,\n noOptionsMessage: noOptionsMessageSlot,\n option: optionSlot,\n placeholder: placeholderSlot,\n singleValue: singleValueSlot,\n valueContainer: valueContainerSlot,\n } = selectVariants({ invalid });\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div className={cn(className, 'mt-2')} data-testid={`${testId}_select`}>\n {label && (\n <label\n htmlFor={`react-select-${name}-input`} // {getTriggerProps().id}\n className={`${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n const { className: _className, ...rest } = getTriggerProps();\n return rest;\n }}\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n classNames={{\n control: ({ isFocused }) =>\n // border focus style\n controlSlot({\n className: !invalid && isFocused && '!border-primary',\n }),\n placeholder: () => placeholderSlot(),\n input: () => inputSlot(),\n valueContainer: () => valueContainerSlot(),\n singleValue: () =>\n singleValueSlot({\n className: `${getValueProps().className}`,\n }),\n multiValue: () => multiValueSlot(),\n multiValueLabel: () =>\n multiValueLabelSlot({\n className: `${getValueProps().className}`,\n }),\n multiValueRemove: () => multiValueRemoveSlot(),\n indicatorsContainer: () => indicatorContainerSlot(),\n clearIndicator: () => clearIndicatorSlot(),\n indicatorSeparator: () => indicatorSeparatorSlot(),\n dropdownIndicator: () => dropdownIndicatorSlot(),\n menu: () => menuSlot(),\n groupHeading: () => groupHeadingSlot(),\n option: ({ isFocused, isSelected }) =>\n optionSlot({\n focused: isFocused,\n optionSelected: isSelected,\n }),\n noOptionsMessage: () => noOptionsMessageSlot(),\n menuPortal: () => menuPortalSlot(),\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n filterOption={filterOption}\n instanceId={name}\n inputValue={inputValue}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n options={options}\n placeholder={placeholder}\n unstyled\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onInputChange={onInputChange}\n // attach menu modal or body so it works in card and modal\n menuPortalTarget={\n (document.getElementById('modal_body')?.parentNode\n ?.parentNode as HTMLElement) || document.body\n }\n value={options.find((option) => option.value === value)}\n onBlur={onBlur}\n name={name}\n ref={ref}\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkHT3LKDHXcjs = require('./chunk-HT3LKDHX.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkWQRM7G4Ccjs = require('./chunk-WQRM7G4C.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
13
|
+
|
|
14
|
+
// src/FieldArray/FieldArray.tsx
|
|
15
|
+
var _react = require('react');
|
|
16
|
+
var _reacthookform = require('react-hook-form');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
var _core = require('@dnd-kit/core');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var _modifiers = require('@dnd-kit/modifiers');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
var _sortable = require('@dnd-kit/sortable');
|
|
33
|
+
var _input = require('@nextui-org/input');
|
|
34
|
+
var _pixels = require('@fuf-stack/pixels');
|
|
35
|
+
|
|
36
|
+
// src/FieldArray/FieldArrayField.tsx
|
|
37
|
+
|
|
38
|
+
var _fa = require('react-icons/fa');
|
|
39
|
+
|
|
40
|
+
var _utilities = require('@dnd-kit/utilities');
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
44
|
+
var FieldArrayField = ({
|
|
45
|
+
children,
|
|
46
|
+
className = void 0,
|
|
47
|
+
field,
|
|
48
|
+
fields,
|
|
49
|
+
hideButtons = [],
|
|
50
|
+
id,
|
|
51
|
+
index,
|
|
52
|
+
insert,
|
|
53
|
+
lastNotDeletable = true,
|
|
54
|
+
move,
|
|
55
|
+
moveField,
|
|
56
|
+
name,
|
|
57
|
+
remove,
|
|
58
|
+
testId = void 0
|
|
59
|
+
}) => {
|
|
60
|
+
const { attributes, listeners, setNodeRef, transform, transition } = _sortable.useSortable.call(void 0, { id });
|
|
61
|
+
const style = {
|
|
62
|
+
transform: _utilities.CSS.Translate.toString(transform),
|
|
63
|
+
transition
|
|
64
|
+
};
|
|
65
|
+
const { getFieldState, register, watch, trigger } = _chunkWQRM7G4Ccjs.useFormContext.call(void 0, );
|
|
66
|
+
const { error, invalid } = getFieldState(`${name}`, void 0);
|
|
67
|
+
const { getHelperWrapperProps, getErrorMessageProps } = _input.useInput.call(void 0, {
|
|
68
|
+
isInvalid: invalid,
|
|
69
|
+
errorMessage: JSON.stringify(error),
|
|
70
|
+
labelPlacement: "inside",
|
|
71
|
+
placeholder: " ",
|
|
72
|
+
classNames: { helperWrapper: "block" }
|
|
73
|
+
});
|
|
74
|
+
register(`${name}.${index}._errors`);
|
|
75
|
+
const formValues = watch();
|
|
76
|
+
_react.useEffect.call(void 0, () => {
|
|
77
|
+
trigger(`${name}.${index}._errors`);
|
|
78
|
+
}, [JSON.stringify(formValues)]);
|
|
79
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
80
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { ref: setNodeRef, style, className, children: [
|
|
81
|
+
!hideButtons.includes("move") && !hideButtons.includes("all") && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mr-6 flex flex-row items-center", children: [
|
|
82
|
+
moveField.includes("drag-drop") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: "mr-2 text-base text-xl",
|
|
86
|
+
"data-testid": _chunkBBB4FEY6cjs.slugify.call(void 0, `${name}_${index}_movebutton`),
|
|
87
|
+
...attributes,
|
|
88
|
+
...listeners,
|
|
89
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _fa.FaGripLines, {})
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
moveField.includes("button") && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col", children: [
|
|
93
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
94
|
+
_pixels.Button,
|
|
95
|
+
{
|
|
96
|
+
testId: `${name}.${index}.up`,
|
|
97
|
+
disabled: index === 0,
|
|
98
|
+
onClick: () => move(index, index - 1),
|
|
99
|
+
className: "flex rounded-b-none rounded-t-md border border-gray-300 px-2 py-2 shadow-sm",
|
|
100
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _fa.FaAngleUp, {})
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
104
|
+
_pixels.Button,
|
|
105
|
+
{
|
|
106
|
+
testId: `${name}.${index}.down`,
|
|
107
|
+
disabled: index === fields.length - 1,
|
|
108
|
+
onClick: () => move(index, index + 1),
|
|
109
|
+
className: "flex rounded-b-md rounded-t-none border border-gray-300 px-2 py-2 shadow-sm",
|
|
110
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _fa.FaAngleDown, {})
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] })
|
|
114
|
+
] }),
|
|
115
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "w-full", children: [
|
|
116
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mb-2 flex items-center", children: [
|
|
117
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex-grow", "data-testid": testId, children }),
|
|
118
|
+
!hideButtons.includes("remove") && !hideButtons.includes("all") && (lastNotDeletable && fields.length === 1 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pixels.Button, { onClick: () => remove(index), className: "ml-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
119
|
+
"svg",
|
|
120
|
+
{
|
|
121
|
+
className: "h-4 w-4",
|
|
122
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
123
|
+
viewBox: "0 0 20 20",
|
|
124
|
+
fill: "currentColor",
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
127
|
+
"path",
|
|
128
|
+
{
|
|
129
|
+
fillRule: "evenodd",
|
|
130
|
+
d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
|
|
131
|
+
clipRule: "evenodd"
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
) }))
|
|
136
|
+
] }),
|
|
137
|
+
!hideButtons.includes("insert") && !hideButtons.includes("all") && index !== fields.length - 1 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
138
|
+
_pixels.Button,
|
|
139
|
+
{
|
|
140
|
+
className: "text-xs font-medium",
|
|
141
|
+
testId: `add-harbor-button-${index}`,
|
|
142
|
+
onClick: () => {
|
|
143
|
+
insert(index + 1, {});
|
|
144
|
+
},
|
|
145
|
+
children: "insert"
|
|
146
|
+
}
|
|
147
|
+
) : null
|
|
148
|
+
] }, `rest-${field.id}`)
|
|
149
|
+
] }),
|
|
150
|
+
error && typeof error[index] !== "undefined" && // @ts-expect-error rhf incompatibility
|
|
151
|
+
_optionalChain([error, 'access', _ => _[Number(index)], 'optionalAccess', _2 => _2._errors]) && // TODO: was String(). Check if Number is correct. (same below in FieldValidationError)
|
|
152
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
153
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getErrorMessageProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQTL5FREEcjs.FieldValidationError_default, { error: _optionalChain([error, 'access', _3 => _3[Number(index)], 'optionalAccess', _4 => _4._errors]) }) }) })
|
|
154
|
+
] });
|
|
155
|
+
};
|
|
156
|
+
var FieldArrayField_default = FieldArrayField;
|
|
157
|
+
|
|
158
|
+
// src/FieldArray/FieldArray.tsx
|
|
159
|
+
|
|
160
|
+
var FieldArray = ({
|
|
161
|
+
children,
|
|
162
|
+
hideButtons = [],
|
|
163
|
+
label: _label = void 0,
|
|
164
|
+
lastNotDeletable = true,
|
|
165
|
+
name,
|
|
166
|
+
testId: _testId = void 0,
|
|
167
|
+
moveField = ["button"]
|
|
168
|
+
}) => {
|
|
169
|
+
const { control, getValues, getFieldState, register, trigger, watch } = _chunkWQRM7G4Ccjs.useFormContext.call(void 0, );
|
|
170
|
+
const { fields, append, remove, insert, move } = _reacthookform.useFieldArray.call(void 0, {
|
|
171
|
+
control,
|
|
172
|
+
name
|
|
173
|
+
});
|
|
174
|
+
const { error, testId, invalid, required } = getFieldState(name, _testId);
|
|
175
|
+
register(`${name}._errors`);
|
|
176
|
+
const formValues = watch();
|
|
177
|
+
_react.useEffect.call(void 0, () => {
|
|
178
|
+
trigger(`${name}._errors`);
|
|
179
|
+
}, [JSON.stringify(formValues)]);
|
|
180
|
+
const { label, getLabelProps, getHelperWrapperProps, getErrorMessageProps } = _input.useInput.call(void 0, {
|
|
181
|
+
isInvalid: invalid,
|
|
182
|
+
isRequired: required,
|
|
183
|
+
errorMessage: JSON.stringify(error),
|
|
184
|
+
label: _label,
|
|
185
|
+
labelPlacement: "inside",
|
|
186
|
+
placeholder: " ",
|
|
187
|
+
classNames: { helperWrapper: "block" }
|
|
188
|
+
});
|
|
189
|
+
if (lastNotDeletable && fields.length === 0) {
|
|
190
|
+
append({});
|
|
191
|
+
}
|
|
192
|
+
const sensors = _core.useSensors.call(void 0,
|
|
193
|
+
_core.useSensor.call(void 0, _core.PointerSensor),
|
|
194
|
+
_core.useSensor.call(void 0, _core.KeyboardSensor)
|
|
195
|
+
);
|
|
196
|
+
const handleDragEnd = (event) => {
|
|
197
|
+
const { active, over } = event;
|
|
198
|
+
if (active.id !== _optionalChain([over, 'optionalAccess', _5 => _5.id])) {
|
|
199
|
+
const oldIndex = fields.findIndex((field) => field.id === active.id);
|
|
200
|
+
const newIndex = fields.findIndex((field) => field.id === _optionalChain([over, 'optionalAccess', _6 => _6.id]));
|
|
201
|
+
move(oldIndex, newIndex);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
205
|
+
_core.DndContext,
|
|
206
|
+
{
|
|
207
|
+
sensors,
|
|
208
|
+
collisionDetection: _core.closestCenter,
|
|
209
|
+
onDragEnd: handleDragEnd,
|
|
210
|
+
modifiers: [_modifiers.restrictToVerticalAxis, _modifiers.restrictToWindowEdges],
|
|
211
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
212
|
+
_sortable.SortableContext,
|
|
213
|
+
{
|
|
214
|
+
items: fields.map((field) => field.id),
|
|
215
|
+
strategy: _sortable.verticalListSortingStrategy,
|
|
216
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "ul", { "data-testid": testId, children: [
|
|
217
|
+
label && // eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
218
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
219
|
+
"label",
|
|
220
|
+
{
|
|
221
|
+
...getLabelProps(),
|
|
222
|
+
className: `${getLabelProps().className} !pointer-events-auto !static !z-0 -mb-1 ml-1 !inline-block`,
|
|
223
|
+
children: label
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHT3LKDHXcjs.FieldCopyTestIdButton_default, { testId }),
|
|
227
|
+
fields.map((field, index) => {
|
|
228
|
+
const duplicate = (i) => {
|
|
229
|
+
const values = getValues(name);
|
|
230
|
+
insert(i + 1, { ...values[i], id: null });
|
|
231
|
+
};
|
|
232
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
233
|
+
FieldArrayField_default,
|
|
234
|
+
{
|
|
235
|
+
id: field.id,
|
|
236
|
+
testId: `${testId}_${index}`,
|
|
237
|
+
className: "mb-3 mt-5 flex flex-row items-center",
|
|
238
|
+
field,
|
|
239
|
+
fields,
|
|
240
|
+
hideButtons,
|
|
241
|
+
index,
|
|
242
|
+
insert,
|
|
243
|
+
lastNotDeletable,
|
|
244
|
+
move,
|
|
245
|
+
moveField,
|
|
246
|
+
name,
|
|
247
|
+
remove,
|
|
248
|
+
children: children(
|
|
249
|
+
`${name}[${index}]`,
|
|
250
|
+
index,
|
|
251
|
+
fields.length,
|
|
252
|
+
move,
|
|
253
|
+
insert,
|
|
254
|
+
remove,
|
|
255
|
+
duplicate
|
|
256
|
+
)
|
|
257
|
+
},
|
|
258
|
+
field.id
|
|
259
|
+
);
|
|
260
|
+
}),
|
|
261
|
+
!hideButtons.includes("add") && !hideButtons.includes("all") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
262
|
+
_pixels.Button,
|
|
263
|
+
{
|
|
264
|
+
testId: `${testId}_append`,
|
|
265
|
+
size: "sm",
|
|
266
|
+
onClick: () => append({}),
|
|
267
|
+
children: "Add"
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
_optionalChain([error, 'optionalAccess', _7 => _7._errors]) && // eslint-disable-next-line react/jsx-props-no-spreading
|
|
271
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getErrorMessageProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQTL5FREEcjs.FieldValidationError_default, { error: _optionalChain([error, 'optionalAccess', _8 => _8._errors]) }) }) })
|
|
272
|
+
] })
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
var FieldArray_default = FieldArray;
|
|
279
|
+
|
|
280
|
+
// src/FieldArray/index.ts
|
|
281
|
+
var FieldArray_default2 = FieldArray_default;
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
exports.FieldArray_default = FieldArray_default; exports.FieldArray_default2 = FieldArray_default2;
|
|
287
|
+
//# sourceMappingURL=chunk-OS4SMYPO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FieldArray/FieldArray.tsx","../src/FieldArray/FieldArrayField.tsx","../src/FieldArray/index.ts"],"names":["useEffect","useInput","Button","jsx","jsxs","FieldArray_default"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AAAA,aAEJ;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,qBAAQ;;;AE3Mf,IAAOE,sBAAQ","sourcesContent":["import type { DragEndEvent } from '@dnd-kit/core';\nimport type {\n FieldValues,\n UseFieldArrayInsert,\n UseFieldArrayMove,\n UseFieldArrayRemove,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\nimport { useFieldArray } from 'react-hook-form';\n\nimport {\n closestCenter,\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport { useInput } from '@nextui-org/input';\n\nimport { Button } from '@fuf-stack/pixels';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\nimport FieldArrayField from './FieldArrayField';\n\nexport type FieldArrayHideOption = 'add' | 'remove' | 'move' | 'insert' | 'all';\nexport type FieldArrayFieldChildren = (\n name: string,\n index: number,\n length: number,\n move: UseFieldArrayMove,\n insert: UseFieldArrayInsert<FieldValues, string>,\n remove: UseFieldArrayRemove,\n duplicate: (i: number) => void,\n) => JSX.Element;\n\nexport type MoveField = 'drag-drop' | 'button';\n\nexport interface FieldArrayProps {\n /** function that renders the children with provided Properties. */\n children: FieldArrayFieldChildren;\n /** Hide a set of buttons. */\n hideButtons?: FieldArrayHideOption[];\n /** label of the FieldArray. */\n label?: React.ReactNode;\n /** stops user from deleting all items. */\n lastNotDeletable?: boolean;\n /** name the FieldArray is registered in RHF */\n name: string;\n /** ID for test purposes. */\n testId?: string;\n /* how the fields can be moved */\n moveField: MoveField[];\n}\n\n/**\n * FieldArray component using react-hook-form\n */\nconst FieldArray = ({\n children,\n hideButtons = [],\n label: _label = undefined,\n lastNotDeletable = true,\n name,\n testId: _testId = undefined,\n moveField = ['button'],\n}: FieldArrayProps) => {\n const { control, getValues, getFieldState, register, trigger, watch } =\n useFormContext();\n\n const { fields, append, remove, insert, move } = useFieldArray({\n control,\n name,\n });\n\n const { error, testId, invalid, required } = getFieldState(name, _testId);\n\n register(`${name}._errors`);\n\n const formValues = watch();\n\n useEffect(() => {\n trigger(`${name}._errors`);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(formValues)]);\n\n // TODO: what about input props?\n const { label, getLabelProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n isInvalid: invalid,\n isRequired: required,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'inside',\n placeholder: ' ',\n classNames: { helperWrapper: 'block' },\n });\n\n if (lastNotDeletable && fields.length === 0) {\n append({});\n }\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\n );\n\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n if (active.id !== over?.id) {\n const oldIndex = fields.findIndex((field) => field.id === active.id);\n const newIndex = fields.findIndex((field) => field.id === over?.id);\n move(oldIndex, newIndex);\n }\n };\n return (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragEnd={handleDragEnd}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n >\n <SortableContext\n items={fields.map((field) => field.id)}\n strategy={verticalListSortingStrategy}\n >\n <ul data-testid={testId}>\n {label && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getLabelProps()}\n className={`${getLabelProps().className} !pointer-events-auto !static !z-0 -mb-1 ml-1 !inline-block`}\n >\n {label}\n </label>\n )}\n <FieldCopyTestIdButton testId={testId} />\n\n {fields.map((field, index) => {\n const duplicate = (i: number) => {\n const values = getValues(name);\n insert(i + 1, { ...values[i], id: null });\n };\n\n return (\n <FieldArrayField\n id={field.id}\n key={field.id}\n testId={`${testId}_${index}`}\n className=\"mb-3 mt-5 flex flex-row items-center\"\n field={field}\n fields={fields}\n hideButtons={hideButtons}\n index={index}\n insert={insert}\n lastNotDeletable={lastNotDeletable}\n move={move}\n moveField={moveField}\n name={name}\n remove={remove}\n >\n {children(\n `${name}[${index}]`,\n index,\n fields.length,\n move,\n insert,\n remove,\n duplicate,\n )}\n </FieldArrayField>\n );\n })}\n\n {!hideButtons.includes('add') && !hideButtons.includes('all') && (\n <Button\n testId={`${testId}_append`}\n size=\"sm\"\n onClick={() => append({})}\n >\n Add\n </Button>\n )}\n {/* @ts-expect-error rhf incompatibility */}\n {error?._errors && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n {/* @ts-expect-error rhf incompatibility */}\n <FieldValidationError error={error?._errors} />\n </div>\n </div>\n )}\n </ul>\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default FieldArray;\n","import type {\n FieldValues,\n UseFieldArrayInsert,\n UseFieldArrayMove,\n UseFieldArrayRemove,\n} from 'react-hook-form';\nimport type { FieldArrayHideOption, MoveField } from './FieldArray';\n\nimport { useEffect } from 'react';\nimport { FaAngleDown, FaAngleUp, FaGripLines } from 'react-icons/fa';\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { useInput } from '@nextui-org/input';\n\nimport { Button } from '@fuf-stack/pixels';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ninterface FieldArrayFieldProps {\n children: React.ReactNode;\n className?: string;\n field: Record<'id', string>;\n fields: Record<'id', string>[];\n hideButtons?: FieldArrayHideOption[];\n id: string | number;\n index: number;\n insert: UseFieldArrayInsert<FieldValues, string>;\n lastNotDeletable?: boolean;\n move: UseFieldArrayMove;\n moveField: MoveField[];\n testId?: string;\n name: string;\n remove: UseFieldArrayRemove;\n}\n\n/**\n * FieldArrayField component using react-hook-form\n */\nconst FieldArrayField = ({\n children,\n className = undefined,\n field,\n fields,\n hideButtons = [],\n id,\n index,\n insert,\n lastNotDeletable = true,\n move,\n moveField,\n name,\n remove,\n testId = undefined,\n}: FieldArrayFieldProps) => {\n const { attributes, listeners, setNodeRef, transform, transition } =\n useSortable({ id });\n\n const style = {\n transform: CSS.Translate.toString(transform),\n transition,\n };\n\n const { getFieldState, register, watch, trigger } = useFormContext();\n const { error, invalid } = getFieldState(`${name}`, undefined);\n\n // TODO: what about input props? and label props? Do we need a label?\n const { getHelperWrapperProps, getErrorMessageProps } = useInput({\n isInvalid: invalid,\n errorMessage: JSON.stringify(error),\n labelPlacement: 'inside',\n placeholder: ' ',\n classNames: { helperWrapper: 'block' },\n });\n\n // TODO: Check if this is a current issue: _error gets kicked out of the formValidation if no other errors exist. validationError exists, but the structure changes.\n register(`${name}.${index}._errors`);\n\n const formValues = watch();\n useEffect(() => {\n trigger(`${name}.${index}._errors`);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(formValues)]);\n\n return (\n <>\n <li ref={setNodeRef} style={style} className={className}>\n {/** Start Button up/down */}\n {!hideButtons.includes('move') && !hideButtons.includes('all') && (\n <div className=\"mr-6 flex flex-row items-center\">\n {moveField.includes('drag-drop') && (\n <div\n className=\"mr-2 text-base text-xl\"\n data-testid={slugify(`${name}_${index}_movebutton`)}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...attributes}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...listeners}\n >\n <FaGripLines />\n </div>\n )}\n {moveField.includes('button') && (\n <div className=\"flex flex-col\">\n <Button\n testId={`${name}.${index}.up`}\n disabled={index === 0}\n onClick={() => move(index, index - 1)}\n className=\"flex rounded-b-none rounded-t-md border border-gray-300 px-2 py-2 shadow-sm\"\n >\n <FaAngleUp />\n </Button>\n <Button\n testId={`${name}.${index}.down`}\n disabled={index === fields.length - 1}\n onClick={() => move(index, index + 1)}\n className=\"flex rounded-b-md rounded-t-none border border-gray-300 px-2 py-2 shadow-sm\"\n >\n <FaAngleDown />\n </Button>\n </div>\n )}\n </div>\n )}\n {/** End Button up/down */}\n <div key={`rest-${field.id}`} className=\"w-full\">\n <div className=\"mb-2 flex items-center\">\n {/** RENDER CHILDREN */}\n <div className=\"flex-grow\" data-testid={testId}>\n {children}\n </div>\n {!hideButtons.includes('remove') &&\n !hideButtons.includes('all') &&\n (lastNotDeletable && fields.length === 1 ? null : (\n <Button onClick={() => remove(index)} className=\"ml-1\">\n <svg\n className=\"h-4 w-4\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </Button>\n ))}\n </div>\n\n {!hideButtons.includes('insert') &&\n !hideButtons.includes('all') &&\n index !== fields.length - 1 ? (\n <Button\n className=\"text-xs font-medium\"\n testId={`add-harbor-button-${index}`}\n onClick={() => {\n insert(index + 1, {});\n }}\n >\n insert\n </Button>\n ) : null}\n </div>\n </li>\n {error &&\n typeof error[index] !== 'undefined' &&\n // @ts-expect-error rhf incompatibility\n error[Number(index)]?._errors && ( // TODO: was String(). Check if Number is correct. (same below in FieldValidationError)\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n {/* @ts-expect-error rhf incompatibility */}\n <FieldValidationError error={error[Number(index)]?._errors} />\n </div>\n </div>\n )}\n </>\n );\n};\nexport default FieldArrayField;\n","import FieldArray from './FieldArray';\n\nexport type {\n FieldArrayProps,\n FieldArrayHideOption,\n FieldArrayFieldChildren,\n} from './FieldArray';\n\nexport { FieldArray };\n\nexport default FieldArray;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx
|
|
2
2
|
import { FaBullseye } from "react-icons/fa6";
|
|
3
|
-
import cn from "
|
|
3
|
+
import { cn } from "@fuf-stack/pixel-utils";
|
|
4
4
|
import { Button, useLocalStorage } from "@fuf-stack/pixels";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
var LOCALSTORAGE_DEBUG_KEY = "uniform:form-debug-enabled";
|
|
@@ -37,4 +37,4 @@ export {
|
|
|
37
37
|
FieldCopyTestIdButton_default,
|
|
38
38
|
FieldCopyTestIdButton_default2
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-OV5RMSYD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../src/partials/FieldCopyTestIdButton/index.ts"],"
|
|
1
|
+
{"version":3,"sources":["../src/partials/FieldCopyTestIdButton/FieldCopyTestIdButton.tsx","../src/partials/FieldCopyTestIdButton/index.ts"],"sourcesContent":["import { FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button, useLocalStorage } from '@fuf-stack/pixels';\n\nexport interface FieldCopyTestIdButtonProps {\n className?: string;\n testId: string;\n}\n\nconst LOCALSTORAGE_DEBUG_KEY = 'uniform:form-debug-enabled';\n\nconst FieldCopyTestIdButton = ({\n className = undefined,\n testId,\n}: FieldCopyTestIdButtonProps) => {\n const [debug] = useLocalStorage(LOCALSTORAGE_DEBUG_KEY, false);\n\n const copyToClipboard = () => {\n navigator.clipboard.writeText(testId).catch((err) => {\n console.error('Error copying TestId to clipboard', err);\n });\n };\n\n if (!debug) {\n return null;\n }\n\n return (\n <Button\n className={cn(className, 'pointer-events-auto')}\n variant=\"light\"\n onClick={copyToClipboard}\n icon={<FaBullseye />}\n size=\"sm\"\n />\n );\n};\nexport default FieldCopyTestIdButton;\n","import FieldCopyTestIdButton from './FieldCopyTestIdButton';\n\nexport type { FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton';\n\nexport { FieldCopyTestIdButton };\n\nexport default FieldCopyTestIdButton;\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,UAAU;AACnB,SAAS,QAAQ,uBAAuB;AA8B5B;AAvBZ,IAAM,yBAAyB;AAE/B,IAAM,wBAAwB,CAAC;AAAA,EAC7B,YAAY;AAAA,EACZ;AACF,MAAkC;AAChC,QAAM,CAAC,KAAK,IAAI,gBAAgB,wBAAwB,KAAK;AAE7D,QAAM,kBAAkB,MAAM;AAC5B,cAAU,UAAU,UAAU,MAAM,EAAE,MAAM,CAAC,QAAQ;AACnD,cAAQ,MAAM,qCAAqC,GAAG;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,WAAW,qBAAqB;AAAA,MAC9C,SAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM,oBAAC,cAAW;AAAA,MAClB,MAAK;AAAA;AAAA,EACP;AAEJ;AACA,IAAO,gCAAQ;;;AChCf,IAAOA,iCAAQ;","names":["FieldCopyTestIdButton_default"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Grid/Grid.tsx
|
|
2
|
-
import cn from "
|
|
2
|
+
import { cn } from "@fuf-stack/pixel-utils";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var Grid = ({
|
|
5
5
|
children = null,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
Grid_default,
|
|
18
18
|
Grid_default2
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-PDCEKC3G.js.map
|