dynamic-mui 2.2.0 → 2.3.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/README.md +142 -5
- package/dist/accordion-DqBdGRim.mjs +23 -0
- package/dist/accordion-lvbD_BpX.js +1 -0
- package/dist/addressfield-CGX3UppE.mjs +152 -0
- package/dist/addressfield-DDG15fqJ.js +1 -0
- package/dist/asyncautocomplete-BAfBR9P7.mjs +89 -0
- package/dist/asyncautocomplete-w9q_1DWt.js +1 -0
- package/dist/bar-BzO7tvYJ.mjs +20 -0
- package/dist/bar-DEVxyUVS.js +1 -0
- package/dist/cascadeselect-C3QVfoig.mjs +64 -0
- package/dist/cascadeselect-DzbhK9en.js +1 -0
- package/dist/colorpicker-5qmEq7ZI.js +1 -0
- package/dist/colorpicker-DhNZulJY.mjs +98 -0
- package/dist/components/DynamicComponent.d.ts +2 -0
- package/dist/components/FormGenerator.d.ts +99 -10
- package/dist/components/controls/index.d.ts +45 -79
- package/dist/consentfield-B7Rm8d3U.js +1 -0
- package/dist/consentfield-CBQUR4J5.mjs +78 -0
- package/dist/datatable-BIQznwQe.mjs +20 -0
- package/dist/datatable-BWlcUP0M.js +1 -0
- package/dist/dynamic-mui.cjs +1 -0
- package/dist/dynamic-mui.mjs +32 -0
- package/dist/editabletable-DCoRmsEO.js +1 -0
- package/dist/editabletable-DRlBV8lk.mjs +126 -0
- package/dist/fileupload-ByBv1UjT.mjs +172 -0
- package/dist/fileupload-Cze3Oc_2.js +1 -0
- package/dist/formrepeater-BBkKGLFJ.mjs +71 -0
- package/dist/formrepeater-BxJzXoHx.js +1 -0
- package/dist/formwizard-BDZE1UDD.js +1 -0
- package/dist/formwizard-D2u1bMvK.mjs +83 -0
- package/dist/geofield-8WTeZk0Z.mjs +104 -0
- package/dist/geofield-Bw3p4NLJ.js +1 -0
- package/dist/group-B2mSylHd.mjs +23 -0
- package/dist/group-BlfO3ZZf.js +1 -0
- package/dist/imagelist-Bn9QhIv7.js +1 -0
- package/dist/imagelist-rqmJajHt.mjs +18 -0
- package/dist/index-CddjLTWF.mjs +12499 -0
- package/dist/index-D08GIfqF.js +43 -0
- package/dist/index.d.ts +9 -1
- package/dist/intlphone-B_Xn98pU.js +1 -0
- package/dist/intlphone-DtQZ12xk.mjs +140 -0
- package/dist/keyvaluefield-B_1NeGuP.mjs +125 -0
- package/dist/keyvaluefield-DyKCGd32.js +1 -0
- package/dist/line-B-DwR1hm.mjs +20 -0
- package/dist/line-BkymZu31.js +1 -0
- package/dist/lineitemlist-DGo8UOZC.js +1 -0
- package/dist/lineitemlist-vGKzJlQx.mjs +166 -0
- package/dist/list-7uNWrepS.mjs +20 -0
- package/dist/list-C0FgmtQw.js +1 -0
- package/dist/locationfield-CeUgxLkQ.mjs +119 -0
- package/dist/locationfield-Duyw1ZEz.js +1 -0
- package/dist/markdowneditor-B1y-hfny.mjs +90 -0
- package/dist/markdowneditor-Db0Un1_Z.js +2 -0
- package/dist/matrixfield-C7Sc-YpI.mjs +117 -0
- package/dist/matrixfield-CckODuPn.js +1 -0
- package/dist/mixChart-C3o184UT.js +1 -0
- package/dist/mixChart-ISf3Kbr-.mjs +75 -0
- package/dist/multitextbox-BYazIAeG.js +1 -0
- package/dist/multitextbox-ide2lvJ6.mjs +78 -0
- package/dist/npsscale-C2e88qk_.js +1 -0
- package/dist/npsscale-lndz7GEq.mjs +87 -0
- package/dist/numberstepper-DitbcvV9.mjs +128 -0
- package/dist/numberstepper-DyRjQM_K.js +1 -0
- package/dist/pie-CJSL8Sv5.js +1 -0
- package/dist/pie-CL29dlh5.mjs +20 -0
- package/dist/richtexteditor-CVg-MnKp.js +1 -0
- package/dist/richtexteditor-DsC1XC7h.mjs +141 -0
- package/dist/s3Upload-B0JeoLkS.js +1 -0
- package/dist/s3Upload-dpioZ2c8.mjs +51 -0
- package/dist/signature-14OrZriO.mjs +1225 -0
- package/dist/signature-D582X6tB.js +2 -0
- package/dist/stepper-B-FpcZvT.js +1 -0
- package/dist/stepper-CDfEy_C6.mjs +140 -0
- package/dist/summaryfield-B08ZmVHh.js +1 -0
- package/dist/summaryfield-CTpPlZBG.mjs +96 -0
- package/dist/tabs-BIliqFOs.js +1 -0
- package/dist/tabs-DDeJCFt8.mjs +39 -0
- package/dist/tagsinput-D-q6rRZS.mjs +58 -0
- package/dist/tagsinput-qh_lhdFb.js +1 -0
- package/dist/util/registry.d.ts +29 -0
- package/dist/util/resolvers.d.ts +45 -0
- package/dist/util/useFormEngine.d.ts +74 -0
- package/dist/util/validateSchema.d.ts +23 -0
- package/dist/v4-BysszJq8.mjs +30 -0
- package/dist/v4-CqdK_b8Y.js +1 -0
- package/package.json +36 -11
- package/dist/AxisSharedComponents-BbsKw1BT.js +0 -3
- package/dist/AxisSharedComponents-xLtpOLH_.mjs +0 -605
- package/dist/ChartsAxis-CANvBdY9.mjs +0 -47
- package/dist/ChartsAxis-EZ7m_KrU.js +0 -1
- package/dist/ChartsGrid-BCRTvNTr.js +0 -3
- package/dist/ChartsGrid-C_HT7qpL.mjs +0 -381
- package/dist/ChartsWrapper-CM7EDyAK.js +0 -5
- package/dist/ChartsWrapper-CO5_Z6BD.mjs +0 -1878
- package/dist/ChartsXAxis-CPmuCRhq.mjs +0 -487
- package/dist/ChartsXAxis-DFFY1sPg.js +0 -3
- package/dist/ChartsYAxis-DLUMr9vG.mjs +0 -392
- package/dist/ChartsYAxis-fpevi1sP.js +0 -1
- package/dist/XmlShapeDeserializer-3yQdm0b0.mjs +0 -237
- package/dist/XmlShapeDeserializer-XKJAoqLc.js +0 -1
- package/dist/clampAngle-BvZjnf53.mjs +0 -11
- package/dist/clampAngle-DpAsDoeT.js +0 -1
- package/dist/createSelector-B-9FwV16.mjs +0 -430
- package/dist/createSelector-f0oqn8Lr.js +0 -7
- package/dist/date-utils-CFUUt6NL.js +0 -4
- package/dist/date-utils-pGzaKb0p.mjs +0 -477
- package/dist/dynamic-mui.cjs.js +0 -1
- package/dist/dynamic-mui.es.js +0 -22
- package/dist/index--8Zky9Oh.js +0 -299
- package/dist/index-6WTs1Xy_.js +0 -1
- package/dist/index-B1R1akM2.js +0 -1
- package/dist/index-BW8_rRff.js +0 -7
- package/dist/index-BXFVK_GX.js +0 -1
- package/dist/index-B_KNUTjy.js +0 -1
- package/dist/index-BhaKvHkU.mjs +0 -62051
- package/dist/index-Bif92ima.js +0 -1
- package/dist/index-BnZOu8CL.js +0 -1
- package/dist/index-CDxpgRlR.mjs +0 -7
- package/dist/index-CThMfvtJ.mjs +0 -2555
- package/dist/index-CVqLvm8B.js +0 -1
- package/dist/index-CodJBIn6.mjs +0 -1665
- package/dist/index-Cr6Wp_S-.mjs +0 -3141
- package/dist/index-CslPwsrf.mjs +0 -4
- package/dist/index-CuV0MQzZ.mjs +0 -1173
- package/dist/index-DA0XouZs.mjs +0 -153
- package/dist/index-DKS5Sz9e.js +0 -14
- package/dist/index-DSkYYZuW.mjs +0 -4
- package/dist/index-DU78_FiA.js +0 -1
- package/dist/index-D_mYhgJ0.js +0 -10
- package/dist/index-DcWfyXJp.mjs +0 -92
- package/dist/index-Dlimbnxj.mjs +0 -2965
- package/dist/index-MllWgTJ5.mjs +0 -9372
- package/dist/index-in5z9hUb.js +0 -133
- package/dist/index-qUW7FnZ-.mjs +0 -20540
- package/dist/index.browser-BSu11T_q.mjs +0 -363
- package/dist/index.browser-By7-GABP.js +0 -4
- package/dist/isDeepEqual-BHfPvf9U.mjs +0 -393
- package/dist/isDeepEqual-CqxZGVRk.js +0 -1
- package/dist/loadCognitoIdentity-DtYTy-DW.js +0 -1
- package/dist/loadCognitoIdentity-DzdR91GB.mjs +0 -872
- package/dist/loadSts-Cic6UToN.mjs +0 -593
- package/dist/loadSts-csbFP6zX.js +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/noAuth-B8ui2kBg.mjs +0 -71
- package/dist/noAuth-JPA2o4dt.js +0 -1
- package/dist/playground/AIContext.d.ts +0 -18
- package/dist/playground/AIPanel.d.ts +0 -10
- package/dist/playground/Builder.d.ts +0 -1
- package/dist/playground/Canvas.d.ts +0 -9
- package/dist/playground/DemoGallery.d.ts +0 -6
- package/dist/playground/PropertiesEditor.d.ts +0 -10
- package/dist/playground/Sidebar.d.ts +0 -9
- package/dist/playground/demoForms.d.ts +0 -3
- package/dist/playground/demoRecipes.d.ts +0 -15
- package/dist/playground/demoVariants.d.ts +0 -11
- package/dist/playground/documentation.d.ts +0 -6
- package/dist/playground/templates.d.ts +0 -7
- package/dist/playground/testData.d.ts +0 -2
- package/dist/test/setup.d.ts +0 -0
- package/dist/theme/theme.d.ts +0 -6
- package/dist/useAxis-DSbfEtO7.js +0 -3
- package/dist/useAxis-SiNBMMWq.mjs +0 -3010
- package/dist/useChartContainerProps-Bl3hO-r1.mjs +0 -5418
- package/dist/useChartContainerProps-C_C_PZoi.js +0 -12
- package/dist/useItemHighlightedGetter-9CIwqsGj.js +0 -1
- package/dist/useItemHighlightedGetter-CTISrNdV.mjs +0 -88
package/README.md
CHANGED
|
@@ -94,10 +94,74 @@ api.current?.validate(); // boolean — runs validation, shows errors
|
|
|
94
94
|
api.current?.getErrors(); // array of { id, rule, message }
|
|
95
95
|
api.current?.reset(); // clear values
|
|
96
96
|
api.current?.submit(); // trigger the submit flow
|
|
97
|
+
|
|
98
|
+
// Dirty tracking
|
|
99
|
+
api.current?.isDirty(); // changed since it loaded?
|
|
100
|
+
api.current?.getInitialValues(); // the starting snapshot
|
|
101
|
+
api.current?.resetToInitial(); // undo all edits
|
|
102
|
+
api.current?.markPristine(); // adopt current values as the new baseline (after save)
|
|
103
|
+
|
|
104
|
+
// Print & PDF (see below)
|
|
105
|
+
api.current?.print({ title: 'Report' });
|
|
106
|
+
await api.current?.exportPdf({ title: 'Report', filename: 'report.pdf' });
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Set `warnOnUnsavedChanges` to prompt the user before they leave the page while
|
|
110
|
+
the form is dirty.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Review, read-only, print & PDF
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
// Read-only: full layout, every control disabled
|
|
118
|
+
<FormGenerator guid="f" data={schema} patch={values} readOnly />
|
|
119
|
+
|
|
120
|
+
// Review: a clean label → value summary instead of inputs
|
|
121
|
+
<FormGenerator guid="f" data={schema} patch={values} reviewMode />
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The review summary resolves option labels (not raw values), Yes/No for booleans,
|
|
125
|
+
joins multi-values, skips hidden and display-only fields, and follows matching
|
|
126
|
+
subforms — ideal for a "confirm before submit" step.
|
|
127
|
+
|
|
128
|
+
`print()` opens the browser dialog for that same summary (users can Save as PDF)
|
|
129
|
+
— **no dependencies**. `exportPdf()` downloads a real PDF and needs the optional
|
|
130
|
+
`pdfmake` package (lazy-loaded, never bundled into the core):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npm i pdfmake # only if you use exportPdf()
|
|
97
134
|
```
|
|
98
135
|
|
|
99
136
|
---
|
|
100
137
|
|
|
138
|
+
## Submit bar
|
|
139
|
+
|
|
140
|
+
Render a visible (optionally sticky) submit button, fully configurable:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<FormGenerator
|
|
144
|
+
guid="wo" data={schema}
|
|
145
|
+
stickySubmit // pins to the bottom of the scroll area
|
|
146
|
+
cancelLabel="Cancel" onCancel={...}
|
|
147
|
+
submitButton={{
|
|
148
|
+
label: 'Dispatch work order',
|
|
149
|
+
color: 'success', // MUI palette name or any CSS color
|
|
150
|
+
gradient: ['#f59e0b', '#ef4444'],// optional gradient fill (overrides color)
|
|
151
|
+
icon: 'engineering', // leading Material icon; also `endIcon`
|
|
152
|
+
variant: 'contained', // contained | outlined | text
|
|
153
|
+
loadingLabel: 'Dispatching…',
|
|
154
|
+
}}
|
|
155
|
+
onSubmit={async (values, errors) => { if (!errors.length) await save(values); }}
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
If `onSubmit` returns a Promise, the button shows a **spinner automatically**
|
|
160
|
+
until it settles (or drive it yourself with `submitButton.loading`).
|
|
161
|
+
`submitLabel="Save"` is a shortcut for `submitButton={{ label: 'Save' }}`.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
101
165
|
## Dynamic rule engine
|
|
102
166
|
|
|
103
167
|
Add these keys to any field to make the form reactive. All conditions run
|
|
@@ -190,16 +254,89 @@ const schema = defineForm([
|
|
|
190
254
|
|
|
191
255
|
---
|
|
192
256
|
|
|
257
|
+
## Extensibility & DX
|
|
258
|
+
|
|
259
|
+
- **Custom controls** — register your own field types; they get the same
|
|
260
|
+
`ControlProps` as built-ins and participate fully in the engine:
|
|
261
|
+
```ts
|
|
262
|
+
import { registerControl } from 'dynamic-mui';
|
|
263
|
+
registerControl('color-swatch', ({ attributes, onChange }) => /* your component */);
|
|
264
|
+
// then: { type: 'color-swatch', props: { id: 'brand' } }
|
|
265
|
+
```
|
|
266
|
+
- **Zod / Yup validation** — validate the whole form against an existing schema
|
|
267
|
+
(`zod`/`yup` are never bundled — the resolvers duck-type the object you pass):
|
|
268
|
+
```ts
|
|
269
|
+
import { zodResolver } from 'dynamic-mui';
|
|
270
|
+
<FormGenerator data={fields} resolver={zodResolver(z.object({ email: z.string().email() }))} />
|
|
271
|
+
```
|
|
272
|
+
- **Async / remote validation** — per-field server checks (debounced, race-safe,
|
|
273
|
+
gates submit): `asyncValidators={{ username: async (v) => taken(v) ? 'Taken' : null }}`.
|
|
274
|
+
- **Typed values** — `FormApi<T>`, `FormData<T>(guid)`, `useForm<T>(guid)` give
|
|
275
|
+
autocompleted, type-checked values.
|
|
276
|
+
|
|
277
|
+
### Headless engine — `useFormEngine`
|
|
278
|
+
|
|
279
|
+
The whole dynamic engine (rules, validation, dynamic options, subforms) with **no
|
|
280
|
+
UI** — render your own components:
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
import { useFormEngine, zodResolver } from 'dynamic-mui';
|
|
284
|
+
|
|
285
|
+
function MyForm() {
|
|
286
|
+
const form = useFormEngine(schema, { resolver: zodResolver(mySchema) });
|
|
287
|
+
return (
|
|
288
|
+
<form onSubmit={(e) => { e.preventDefault(); form.submit(save); }}>
|
|
289
|
+
{form.visibleFields.map((f) => (
|
|
290
|
+
<MyInput key={f.id} value={f.value} required={f.required}
|
|
291
|
+
disabled={f.disabled} options={f.options} error={f.error}
|
|
292
|
+
onChange={(v) => form.setValue(f.id, v)} />
|
|
293
|
+
))}
|
|
294
|
+
</form>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Exposes `values`, `errors`, `fields`/`visibleFields`, `setValue`/`setValues`,
|
|
300
|
+
`validate()`, `submit(onValid)`, `isValid`, `isDirty`, `reset()`, `getFieldState(id)`.
|
|
301
|
+
|
|
302
|
+
### Schema linter — `validateSchema`
|
|
303
|
+
|
|
304
|
+
Catch config mistakes before runtime (great in a test or build step):
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
import { validateSchema } from 'dynamic-mui';
|
|
308
|
+
|
|
309
|
+
const issues = validateSchema(mySchema); // SchemaIssue[]; [] = clean
|
|
310
|
+
// flags duplicate ids, dependsOn → missing field, orphan optionsMap,
|
|
311
|
+
// rule/cross-field references to unknown fields, subform conditions
|
|
312
|
+
// that aren't real options, …
|
|
313
|
+
if (issues.some((i) => i.level === 'error')) throw new Error('Bad form schema');
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
193
318
|
## Internationalisation
|
|
194
319
|
|
|
320
|
+
Override the built-in strings:
|
|
321
|
+
|
|
195
322
|
```tsx
|
|
196
|
-
<FormGenerator
|
|
197
|
-
|
|
198
|
-
data={schema}
|
|
199
|
-
messages={{ required: 'Champ obligatoire', errorSummary: '{n} champ(s) à corriger' }}
|
|
200
|
-
/>
|
|
323
|
+
<FormGenerator guid="fr" data={schema}
|
|
324
|
+
messages={{ required: 'Champ obligatoire', errorSummary: '{n} champ(s) à corriger' }} />
|
|
201
325
|
```
|
|
202
326
|
|
|
327
|
+
Or plug in **any** i18n system with a `translate` function — it localizes every
|
|
328
|
+
user-facing string (labels, placeholders, helper text, option labels, validation
|
|
329
|
+
messages, typography, submit/cancel labels), keeping the schema in one language:
|
|
330
|
+
|
|
331
|
+
```tsx
|
|
332
|
+
// works with i18next, react-intl, or a plain dictionary
|
|
333
|
+
const t = (s) => dictionary[s] ?? s;
|
|
334
|
+
|
|
335
|
+
<FormGenerator guid="form" data={schema} translate={t} />
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Switching the language re-renders the form translated while preserving values.
|
|
339
|
+
|
|
203
340
|
---
|
|
204
341
|
|
|
205
342
|
## Controls
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import m from "react";
|
|
3
|
+
import { Accordion as s, AccordionSummary as l, Typography as p, Icon as u, AccordionDetails as f } from "@mui/material";
|
|
4
|
+
import { F as A } from "./index-CddjLTWF.mjs";
|
|
5
|
+
import { v as h } from "./v4-BysszJq8.mjs";
|
|
6
|
+
function j({ attributes: r = {}, patch: c, onChange: i }) {
|
|
7
|
+
const { MuiAttributes: n = {}, label: e = "Accordion", subFields: t = [] } = r, d = m.useMemo(() => h(), []);
|
|
8
|
+
return /* @__PURE__ */ a(s, { ...n, children: [
|
|
9
|
+
/* @__PURE__ */ o(l, { expandIcon: /* @__PURE__ */ o(u, { children: "expand_more" }), children: /* @__PURE__ */ o(p, { children: e }) }),
|
|
10
|
+
/* @__PURE__ */ o(f, { children: /* @__PURE__ */ o(
|
|
11
|
+
A,
|
|
12
|
+
{
|
|
13
|
+
guid: d,
|
|
14
|
+
data: t,
|
|
15
|
+
patch: c,
|
|
16
|
+
onChange: i
|
|
17
|
+
}
|
|
18
|
+
) })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
j as default
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),r=require("@mui/material"),a=require("./index-D08GIfqF.js"),l=require("./v4-CqdK_b8Y.js");function x({attributes:n={},patch:o,onChange:c}){const{MuiAttributes:i={},label:t="Accordion",subFields:s=[]}=n,d=u.useMemo(()=>l.v4(),[]);return e.jsxs(r.Accordion,{...i,children:[e.jsx(r.AccordionSummary,{expandIcon:e.jsx(r.Icon,{children:"expand_more"}),children:e.jsx(r.Typography,{children:t})}),e.jsx(r.AccordionDetails,{children:e.jsx(a.FormGenerator,{guid:d,data:s,patch:o,onChange:c})})]})}exports.default=x;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import S, { useCallback as A } from "react";
|
|
3
|
+
import r from "@mui/material/Grid";
|
|
4
|
+
import i from "@mui/material/TextField";
|
|
5
|
+
import g from "@mui/material/MenuItem";
|
|
6
|
+
import { u as E, m as P, a as I } from "./index-CddjLTWF.mjs";
|
|
7
|
+
const N = [
|
|
8
|
+
{ value: "US", label: "United States" },
|
|
9
|
+
{ value: "CA", label: "Canada" },
|
|
10
|
+
{ value: "MX", label: "Mexico" },
|
|
11
|
+
{ value: "GB", label: "United Kingdom" },
|
|
12
|
+
{ value: "IE", label: "Ireland" },
|
|
13
|
+
{ value: "FR", label: "France" },
|
|
14
|
+
{ value: "DE", label: "Germany" },
|
|
15
|
+
{ value: "ES", label: "Spain" },
|
|
16
|
+
{ value: "IT", label: "Italy" },
|
|
17
|
+
{ value: "NL", label: "Netherlands" },
|
|
18
|
+
{ value: "BE", label: "Belgium" },
|
|
19
|
+
{ value: "CH", label: "Switzerland" },
|
|
20
|
+
{ value: "SE", label: "Sweden" },
|
|
21
|
+
{ value: "NO", label: "Norway" },
|
|
22
|
+
{ value: "DK", label: "Denmark" },
|
|
23
|
+
{ value: "PT", label: "Portugal" },
|
|
24
|
+
{ value: "AU", label: "Australia" },
|
|
25
|
+
{ value: "NZ", label: "New Zealand" },
|
|
26
|
+
{ value: "IN", label: "India" },
|
|
27
|
+
{ value: "CN", label: "China" },
|
|
28
|
+
{ value: "JP", label: "Japan" },
|
|
29
|
+
{ value: "SG", label: "Singapore" },
|
|
30
|
+
{ value: "AE", label: "United Arab Emirates" },
|
|
31
|
+
{ value: "BR", label: "Brazil" },
|
|
32
|
+
{ value: "ZA", label: "South Africa" }
|
|
33
|
+
], U = {
|
|
34
|
+
street1: "Street address",
|
|
35
|
+
street2: "Apt, suite, etc. (optional)",
|
|
36
|
+
city: "City",
|
|
37
|
+
state: "State / Province",
|
|
38
|
+
postalCode: "Postal code",
|
|
39
|
+
country: "Country"
|
|
40
|
+
};
|
|
41
|
+
function D({ attributes: n = {}, rules: h = {}, onChange: c }) {
|
|
42
|
+
const {
|
|
43
|
+
id: b = "",
|
|
44
|
+
MuiAttributes: v = {},
|
|
45
|
+
countries: o,
|
|
46
|
+
labels: y = {}
|
|
47
|
+
} = n, x = Array.isArray(o) && o.length ? o : N, l = { ...U, ...y }, d = h?.validation?.some(
|
|
48
|
+
(t) => t.rule === "mandatory" || t.rule === "mandatoryselect"
|
|
49
|
+
) || !1, [a, p] = S.useState(() => ({
|
|
50
|
+
street1: "",
|
|
51
|
+
street2: "",
|
|
52
|
+
city: "",
|
|
53
|
+
state: "",
|
|
54
|
+
postalCode: "",
|
|
55
|
+
country: "",
|
|
56
|
+
...n?.value || {}
|
|
57
|
+
}));
|
|
58
|
+
E(() => {
|
|
59
|
+
p({
|
|
60
|
+
street1: "",
|
|
61
|
+
street2: "",
|
|
62
|
+
city: "",
|
|
63
|
+
state: "",
|
|
64
|
+
postalCode: "",
|
|
65
|
+
country: "",
|
|
66
|
+
...n?.value || {}
|
|
67
|
+
});
|
|
68
|
+
}, [n?.value]);
|
|
69
|
+
const s = A(
|
|
70
|
+
(t) => (C) => {
|
|
71
|
+
const m = { ...a, [t]: C.target.value };
|
|
72
|
+
p(m), c?.({ id: b, value: m });
|
|
73
|
+
},
|
|
74
|
+
[a, b, c]
|
|
75
|
+
), u = P(I, v?.sx);
|
|
76
|
+
return /* @__PURE__ */ f(r, { container: !0, spacing: 2, ...v, children: [
|
|
77
|
+
/* @__PURE__ */ e(r, { size: { xs: 12 }, children: /* @__PURE__ */ e(
|
|
78
|
+
i,
|
|
79
|
+
{
|
|
80
|
+
fullWidth: !0,
|
|
81
|
+
label: l.street1,
|
|
82
|
+
required: d,
|
|
83
|
+
value: a.street1 || "",
|
|
84
|
+
onChange: s("street1"),
|
|
85
|
+
inputProps: { "aria-label": l.street1 },
|
|
86
|
+
sx: u
|
|
87
|
+
}
|
|
88
|
+
) }),
|
|
89
|
+
/* @__PURE__ */ e(r, { size: { xs: 12 }, children: /* @__PURE__ */ e(
|
|
90
|
+
i,
|
|
91
|
+
{
|
|
92
|
+
fullWidth: !0,
|
|
93
|
+
label: l.street2,
|
|
94
|
+
value: a.street2 || "",
|
|
95
|
+
onChange: s("street2"),
|
|
96
|
+
inputProps: { "aria-label": l.street2 },
|
|
97
|
+
sx: u
|
|
98
|
+
}
|
|
99
|
+
) }),
|
|
100
|
+
/* @__PURE__ */ e(r, { size: { xs: 12, sm: 6, md: 5 }, children: /* @__PURE__ */ e(
|
|
101
|
+
i,
|
|
102
|
+
{
|
|
103
|
+
fullWidth: !0,
|
|
104
|
+
label: l.city,
|
|
105
|
+
required: d,
|
|
106
|
+
value: a.city || "",
|
|
107
|
+
onChange: s("city"),
|
|
108
|
+
inputProps: { "aria-label": l.city },
|
|
109
|
+
sx: u
|
|
110
|
+
}
|
|
111
|
+
) }),
|
|
112
|
+
/* @__PURE__ */ e(r, { size: { xs: 12, sm: 6, md: 4 }, children: /* @__PURE__ */ e(
|
|
113
|
+
i,
|
|
114
|
+
{
|
|
115
|
+
fullWidth: !0,
|
|
116
|
+
label: l.state,
|
|
117
|
+
value: a.state || "",
|
|
118
|
+
onChange: s("state"),
|
|
119
|
+
inputProps: { "aria-label": l.state },
|
|
120
|
+
sx: u
|
|
121
|
+
}
|
|
122
|
+
) }),
|
|
123
|
+
/* @__PURE__ */ e(r, { size: { xs: 12, sm: 6, md: 3 }, children: /* @__PURE__ */ e(
|
|
124
|
+
i,
|
|
125
|
+
{
|
|
126
|
+
fullWidth: !0,
|
|
127
|
+
label: l.postalCode,
|
|
128
|
+
value: a.postalCode || "",
|
|
129
|
+
onChange: s("postalCode"),
|
|
130
|
+
inputProps: { "aria-label": l.postalCode },
|
|
131
|
+
sx: u
|
|
132
|
+
}
|
|
133
|
+
) }),
|
|
134
|
+
/* @__PURE__ */ e(r, { size: { xs: 12, sm: 6 }, children: /* @__PURE__ */ e(
|
|
135
|
+
i,
|
|
136
|
+
{
|
|
137
|
+
select: !0,
|
|
138
|
+
fullWidth: !0,
|
|
139
|
+
label: l.country,
|
|
140
|
+
required: d,
|
|
141
|
+
value: a.country || "",
|
|
142
|
+
onChange: s("country"),
|
|
143
|
+
SelectProps: { inputProps: { "aria-label": l.country } },
|
|
144
|
+
sx: u,
|
|
145
|
+
children: x.map((t) => /* @__PURE__ */ e(g, { value: t.value, children: t.label }, t.value))
|
|
146
|
+
}
|
|
147
|
+
) })
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
D as default
|
|
152
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("react"),s=require("@mui/material/Grid"),n=require("@mui/material/TextField"),A=require("@mui/material/MenuItem"),c=require("./index-D08GIfqF.js"),g=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"MX",label:"Mexico"},{value:"GB",label:"United Kingdom"},{value:"IE",label:"Ireland"},{value:"FR",label:"France"},{value:"DE",label:"Germany"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BE",label:"Belgium"},{value:"CH",label:"Switzerland"},{value:"SE",label:"Sweden"},{value:"NO",label:"Norway"},{value:"DK",label:"Denmark"},{value:"PT",label:"Portugal"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IN",label:"India"},{value:"CN",label:"China"},{value:"JP",label:"Japan"},{value:"SG",label:"Singapore"},{value:"AE",label:"United Arab Emirates"},{value:"BR",label:"Brazil"},{value:"ZA",label:"South Africa"}],f={street1:"Street address",street2:"Apt, suite, etc. (optional)",city:"City",state:"State / Province",postalCode:"Postal code",country:"Country"};function P({attributes:i={},rules:m={},onChange:b}){const{id:v="",MuiAttributes:x={},countries:o,labels:C={}}=i,S=Array.isArray(o)&&o.length?o:g,l={...f,...C},d=m?.validation?.some(t=>t.rule==="mandatory"||t.rule==="mandatoryselect")||!1,[a,p]=h.useState(()=>({street1:"",street2:"",city:"",state:"",postalCode:"",country:"",...i?.value||{}}));c.useUpdateEffect(()=>{p({street1:"",street2:"",city:"",state:"",postalCode:"",country:"",...i?.value||{}})},[i?.value]);const r=h.useCallback(t=>j=>{const y={...a,[t]:j.target.value};p(y),b?.({id:v,value:y})},[a,v,b]),u=c.mergeSx(c.premiumInputSx,x?.sx);return e.jsxs(s,{container:!0,spacing:2,...x,children:[e.jsx(s,{size:{xs:12},children:e.jsx(n,{fullWidth:!0,label:l.street1,required:d,value:a.street1||"",onChange:r("street1"),inputProps:{"aria-label":l.street1},sx:u})}),e.jsx(s,{size:{xs:12},children:e.jsx(n,{fullWidth:!0,label:l.street2,value:a.street2||"",onChange:r("street2"),inputProps:{"aria-label":l.street2},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:5},children:e.jsx(n,{fullWidth:!0,label:l.city,required:d,value:a.city||"",onChange:r("city"),inputProps:{"aria-label":l.city},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:4},children:e.jsx(n,{fullWidth:!0,label:l.state,value:a.state||"",onChange:r("state"),inputProps:{"aria-label":l.state},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:3},children:e.jsx(n,{fullWidth:!0,label:l.postalCode,value:a.postalCode||"",onChange:r("postalCode"),inputProps:{"aria-label":l.postalCode},sx:u})}),e.jsx(s,{size:{xs:12,sm:6},children:e.jsx(n,{select:!0,fullWidth:!0,label:l.country,required:d,value:a.country||"",onChange:r("country"),SelectProps:{inputProps:{"aria-label":l.country}},sx:u,children:S.map(t=>e.jsx(A,{value:t.value,children:t.label},t.value))})})]})}exports.default=P;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as c, jsxs as F, Fragment as K } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as y, useEffect as L, createElement as M } from "react";
|
|
3
|
+
import _ from "@mui/material/Autocomplete";
|
|
4
|
+
import k from "@mui/material/TextField";
|
|
5
|
+
import z from "@mui/material/CircularProgress";
|
|
6
|
+
import { u as V, a as w } from "./index-CddjLTWF.mjs";
|
|
7
|
+
function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
8
|
+
const {
|
|
9
|
+
MuiAttributes: C = {},
|
|
10
|
+
id: x = "",
|
|
11
|
+
label: I = "Search",
|
|
12
|
+
placeholder: O = "",
|
|
13
|
+
minChars: S = 1,
|
|
14
|
+
debounceMs: q = 300,
|
|
15
|
+
labelKey: P = "label",
|
|
16
|
+
valueKey: p = "value",
|
|
17
|
+
loadOptions: m,
|
|
18
|
+
optionsUrl: s
|
|
19
|
+
} = t, [T, d] = f(t.value ?? null), [b, a] = f([]), [h, o] = f(!1), u = y(0), r = y(null);
|
|
20
|
+
V(() => {
|
|
21
|
+
d(t.value ?? null);
|
|
22
|
+
}, [t.value]), L(() => () => {
|
|
23
|
+
r.current && clearTimeout(r.current);
|
|
24
|
+
}, []);
|
|
25
|
+
const j = async (e) => {
|
|
26
|
+
if (typeof m == "function")
|
|
27
|
+
return m(e);
|
|
28
|
+
if (s) {
|
|
29
|
+
const n = `${s}${s.includes("?") ? "&" : "?"}q=${encodeURIComponent(e)}`, g = await (await fetch(n)).json();
|
|
30
|
+
return Array.isArray(g) ? g : [];
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}, E = (e) => {
|
|
34
|
+
const n = ++u.current;
|
|
35
|
+
o(!0), j(e).then((i) => {
|
|
36
|
+
n === u.current && (a(Array.isArray(i) ? i : []), o(!1));
|
|
37
|
+
}).catch(() => {
|
|
38
|
+
n === u.current && (a([]), o(!1));
|
|
39
|
+
});
|
|
40
|
+
}, R = (e, n) => {
|
|
41
|
+
if (r.current && clearTimeout(r.current), !n || n.length < S) {
|
|
42
|
+
u.current++, o(!1), a([]);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
r.current = setTimeout(() => {
|
|
46
|
+
E(n);
|
|
47
|
+
}, q);
|
|
48
|
+
}, U = (e, n) => {
|
|
49
|
+
d(n), A?.({
|
|
50
|
+
id: x,
|
|
51
|
+
value: n != null ? n?.[p] ?? n : n,
|
|
52
|
+
option: n
|
|
53
|
+
});
|
|
54
|
+
}, l = (e) => typeof e == "string" ? e : e?.[P] ?? "", $ = !!v?.validation?.some((e) => e.rule === "mandatory");
|
|
55
|
+
return /* @__PURE__ */ c(
|
|
56
|
+
_,
|
|
57
|
+
{
|
|
58
|
+
value: T,
|
|
59
|
+
onChange: U,
|
|
60
|
+
onInputChange: R,
|
|
61
|
+
options: b,
|
|
62
|
+
loading: h,
|
|
63
|
+
filterOptions: (e) => e,
|
|
64
|
+
getOptionLabel: l,
|
|
65
|
+
renderOption: (e, n) => /* @__PURE__ */ M("li", { ...e, key: (n && n[p]) ?? l(n) }, l(n)),
|
|
66
|
+
...C,
|
|
67
|
+
renderInput: (e) => /* @__PURE__ */ c(
|
|
68
|
+
k,
|
|
69
|
+
{
|
|
70
|
+
...e,
|
|
71
|
+
label: I,
|
|
72
|
+
placeholder: O,
|
|
73
|
+
required: $,
|
|
74
|
+
sx: w,
|
|
75
|
+
InputProps: {
|
|
76
|
+
...e.InputProps,
|
|
77
|
+
endAdornment: /* @__PURE__ */ F(K, { children: [
|
|
78
|
+
h ? /* @__PURE__ */ c(z, { color: "inherit", size: 20 }) : null,
|
|
79
|
+
e.InputProps.endAdornment
|
|
80
|
+
] })
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
Q as default
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),t=require("react"),$=require("@mui/material/Autocomplete"),F=require("@mui/material/TextField"),K=require("@mui/material/CircularProgress"),y=require("./index-D08GIfqF.js");function L({attributes:o={},rules:v={},onChange:q}){const{MuiAttributes:A={},id:x="",label:S="Search",placeholder:j="",minChars:C=1,debounceMs:O=300,labelKey:I="label",valueKey:d="value",loadOptions:p,optionsUrl:a}=o,[R,h]=t.useState(o.value??null),[b,i]=t.useState([]),[m,s]=t.useState(!1),c=t.useRef(0),r=t.useRef(null);y.useUpdateEffect(()=>{h(o.value??null)},[o.value]),t.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const P=async e=>{if(typeof p=="function")return p(e);if(a){const n=`${a}${a.includes("?")?"&":"?"}q=${encodeURIComponent(e)}`,g=await(await fetch(n)).json();return Array.isArray(g)?g:[]}return[]},T=e=>{const n=++c.current;s(!0),P(e).then(f=>{n===c.current&&(i(Array.isArray(f)?f:[]),s(!1))}).catch(()=>{n===c.current&&(i([]),s(!1))})},E=(e,n)=>{if(r.current&&clearTimeout(r.current),!n||n.length<C){c.current++,s(!1),i([]);return}r.current=setTimeout(()=>{T(n)},O)},M=(e,n)=>{h(n),q?.({id:x,value:n!=null?n?.[d]??n:n,option:n})},l=e=>typeof e=="string"?e:e?.[I]??"",U=!!v?.validation?.some(e=>e.rule==="mandatory");return u.jsx($,{value:R,onChange:M,onInputChange:E,options:b,loading:m,filterOptions:e=>e,getOptionLabel:l,renderOption:(e,n)=>t.createElement("li",{...e,key:(n&&n[d])??l(n)},l(n)),...A,renderInput:e=>u.jsx(F,{...e,label:S,placeholder:j,required:U,sx:y.premiumInputSx,InputProps:{...e.InputProps,endAdornment:u.jsxs(u.Fragment,{children:[m?u.jsx(K,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}})})}exports.default=L;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import a, { Suspense as i } from "react";
|
|
3
|
+
import n from "@mui/material/Box";
|
|
4
|
+
import s from "@mui/material/CircularProgress";
|
|
5
|
+
const f = a.lazy(
|
|
6
|
+
() => import("@mui/x-charts/BarChart").then((t) => ({ default: t.BarChart }))
|
|
7
|
+
);
|
|
8
|
+
function u({ attributes: t = {} }) {
|
|
9
|
+
const { MuiChartAttributes: e = {}, id: o = "" } = t;
|
|
10
|
+
return /* @__PURE__ */ r(
|
|
11
|
+
i,
|
|
12
|
+
{
|
|
13
|
+
fallback: /* @__PURE__ */ r(n, { sx: { display: "flex", justifyContent: "center", p: 2 }, children: /* @__PURE__ */ r(s, {}) }),
|
|
14
|
+
children: /* @__PURE__ */ r(f, { height: 300, ...e }, o)
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
u as default
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.create;var u=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var x=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!h.call(e,s)&&s!==r&&u(e,s,{get:()=>t[s],enumerable:!(n=o(t,s))||n.enumerable});return e};var f=(e,t,r)=>(r=e!=null?c(d(e)):{},x(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),j=require("@mui/material/Box"),p=require("@mui/material/CircularProgress"),y=a.lazy(()=>import("@mui/x-charts/BarChart").then(e=>({default:e.BarChart})));function C({attributes:e={}}){const{MuiChartAttributes:t={},id:r=""}=e;return i.jsx(a.Suspense,{fallback:i.jsx(j,{sx:{display:"flex",justifyContent:"center",p:2},children:i.jsx(p,{})}),children:i.jsx(y,{height:300,...t},r)})}exports.default=C;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs as C, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import x, { useCallback as E } from "react";
|
|
3
|
+
import I from "@mui/material/TextField";
|
|
4
|
+
import S from "@mui/material/MenuItem";
|
|
5
|
+
import { u as y, m as O, a as P } from "./index-CddjLTWF.mjs";
|
|
6
|
+
const R = (a) => Array.isArray(a) ? a.map(
|
|
7
|
+
(e) => e != null && typeof e == "object" ? { value: e.value, label: e.label ?? e.title ?? String(e.value) } : { value: e, label: String(e) }
|
|
8
|
+
) : [], h = (a, e, t) => {
|
|
9
|
+
const r = a && e != null && e !== "" ? a[e] : void 0;
|
|
10
|
+
return R(r ?? t ?? []);
|
|
11
|
+
};
|
|
12
|
+
function U({ attributes: a = {}, rules: e = {}, onChange: t }) {
|
|
13
|
+
const {
|
|
14
|
+
id: r = "",
|
|
15
|
+
parentValue: s,
|
|
16
|
+
optionsMap: o,
|
|
17
|
+
options: i,
|
|
18
|
+
label: v = "",
|
|
19
|
+
placeholder: c = "",
|
|
20
|
+
MuiAttributes: f = {}
|
|
21
|
+
} = a, b = e?.validation?.some(
|
|
22
|
+
(l) => l.rule === "mandatory" || l.rule === "mandatoryselect"
|
|
23
|
+
) || !1, [m, g] = x.useState(
|
|
24
|
+
() => h(o, s, i)
|
|
25
|
+
), [n, d] = x.useState(() => a?.value ?? "");
|
|
26
|
+
y(() => {
|
|
27
|
+
d(a?.value ?? "");
|
|
28
|
+
}, [a?.value]), y(() => {
|
|
29
|
+
const l = h(o, s, i);
|
|
30
|
+
g(l), n !== "" && n != null && !l.some((u) => u.value === n) && (d(""), t?.({ id: r, value: "", option: null }));
|
|
31
|
+
}, [s, o, i]);
|
|
32
|
+
const M = E(
|
|
33
|
+
(l) => {
|
|
34
|
+
const u = l.target.value, j = m.find((A) => A.value === u) ?? null;
|
|
35
|
+
d(u), t?.({ id: r, value: u, option: j });
|
|
36
|
+
},
|
|
37
|
+
[m, r, t]
|
|
38
|
+
);
|
|
39
|
+
return /* @__PURE__ */ C(
|
|
40
|
+
I,
|
|
41
|
+
{
|
|
42
|
+
select: !0,
|
|
43
|
+
fullWidth: !0,
|
|
44
|
+
label: v,
|
|
45
|
+
placeholder: c,
|
|
46
|
+
required: b,
|
|
47
|
+
value: n ?? "",
|
|
48
|
+
onChange: M,
|
|
49
|
+
SelectProps: {
|
|
50
|
+
displayEmpty: !0,
|
|
51
|
+
inputProps: { "aria-label": v || "cascade-select" }
|
|
52
|
+
},
|
|
53
|
+
...f,
|
|
54
|
+
sx: O(P, f?.sx),
|
|
55
|
+
children: [
|
|
56
|
+
c ? /* @__PURE__ */ p(S, { value: "", children: /* @__PURE__ */ p("em", { children: c }) }) : null,
|
|
57
|
+
m.map((l) => /* @__PURE__ */ p(S, { value: l.value, children: l.label }, String(l.value)))
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
U as default
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),A=require("@mui/material/TextField"),y=require("@mui/material/MenuItem"),i=require("./index-D08GIfqF.js"),E=t=>Array.isArray(t)?t.map(e=>e!=null&&typeof e=="object"?{value:e.value,label:e.label??e.title??String(e.value)}:{value:e,label:String(e)}):[],b=(t,e,a)=>{const u=t&&e!=null&&e!==""?t[e]:void 0;return E(u??a??[])};function O({attributes:t={},rules:e={},onChange:a}){const{id:u="",parentValue:c,optionsMap:o,options:d,label:x="",placeholder:v="",MuiAttributes:S={}}=t,g=e?.validation?.some(l=>l.rule==="mandatory"||l.rule==="mandatoryselect")||!1,[p,h]=f.useState(()=>b(o,c,d)),[r,m]=f.useState(()=>t?.value??"");i.useUpdateEffect(()=>{m(t?.value??"")},[t?.value]),i.useUpdateEffect(()=>{const l=b(o,c,d);h(l),r!==""&&r!=null&&!l.some(n=>n.value===r)&&(m(""),a?.({id:u,value:"",option:null}))},[c,o,d]);const j=f.useCallback(l=>{const n=l.target.value,q=p.find(M=>M.value===n)??null;m(n),a?.({id:u,value:n,option:q})},[p,u,a]);return s.jsxs(A,{select:!0,fullWidth:!0,label:x,placeholder:v,required:g,value:r??"",onChange:j,SelectProps:{displayEmpty:!0,inputProps:{"aria-label":x||"cascade-select"}},...S,sx:i.mergeSx(i.premiumInputSx,S?.sx),children:[v?s.jsx(y,{value:"",children:s.jsx("em",{children:v})}):null,p.map(l=>s.jsx(y,{value:l.value,children:l.label},String(l.value)))]})}exports.default=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),k=require("react"),p=require("@mui/material/Box"),x=require("@mui/material/Stack"),C=require("@mui/material/TextField"),$=require("@mui/material/FormControl"),A=require("@mui/material/FormLabel"),n=require("@mui/material/styles"),l=require("./index-D08GIfqF.js"),h="#000000";function R({attributes:t={},rules:m={},onChange:b}){const{id:u="",label:o,presets:s=[],MuiAttributes:g={}}=t,{sx:y,...f}=g,[a,d]=k.useState(t.value||h);l.useUpdateEffect(()=>{d(t.value||h)},[t.value]);const v=m?.validation?.some(e=>e.rule==="mandatory"||e.rule==="mandatoryselect")||!1,c=e=>{d(e),b?.({id:u,value:e})},S=e=>{c(e.target.value)},w=e=>{c(e.target.value)},j=e=>{c(e)},q={width:44,height:44,borderRadius:"10px",border:e=>`1px solid ${n.alpha(e.palette.text.primary,.2)}`,boxShadow:e=>`0 2px 8px ${n.alpha(e.palette.common.black,.12)}`,cursor:"pointer",flexShrink:0,position:"relative",overflow:"hidden"};return r.jsxs($,{required:v,component:"fieldset",fullWidth:!0,children:[o&&r.jsx(A,{component:"legend",children:o}),r.jsxs(x,{direction:"row",spacing:1.5,alignItems:"center",sx:{mt:o?1:0},children:[r.jsx(p,{sx:{...q,backgroundColor:a},children:r.jsx("input",{type:"color","aria-label":o?`${o} colour`:"colour",value:a,onChange:S,...f,style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,border:"none",padding:0,cursor:"pointer"}})}),r.jsx(C,{id:u||void 0,value:a,onChange:w,size:"small",label:"Hex",inputProps:{"aria-label":"hex value"},sx:l.mergeSx(l.premiumInputSx,l.mergeSx({maxWidth:160},y))})]}),Array.isArray(s)&&s.length>0&&r.jsx(x,{direction:"row",spacing:1,sx:{mt:1.5,flexWrap:"wrap",rowGap:1},children:s.map(e=>r.jsx(p,{role:"button","aria-label":`preset ${e}`,onClick:()=>j(e),sx:{width:26,height:26,borderRadius:"8px",backgroundColor:e,cursor:"pointer",flexShrink:0,border:i=>a===e?`2px solid ${i.palette.primary.main}`:`1px solid ${n.alpha(i.palette.text.primary,.2)}`,boxShadow:i=>`0 1px 4px ${n.alpha(i.palette.common.black,.12)}`}},e))})]})}exports.default=R;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import $ from "react";
|
|
3
|
+
import m from "@mui/material/Box";
|
|
4
|
+
import u from "@mui/material/Stack";
|
|
5
|
+
import A from "@mui/material/TextField";
|
|
6
|
+
import F from "@mui/material/FormControl";
|
|
7
|
+
import I from "@mui/material/FormLabel";
|
|
8
|
+
import { alpha as l } from "@mui/material/styles";
|
|
9
|
+
import { u as R, m as x, a as B } from "./index-CddjLTWF.mjs";
|
|
10
|
+
const h = "#000000";
|
|
11
|
+
function q({ attributes: t = {}, rules: f = {}, onChange: b }) {
|
|
12
|
+
const { id: p = "", label: r, presets: n = [], MuiAttributes: g = {} } = t, { sx: w, ...v } = g, [a, d] = $.useState(
|
|
13
|
+
t.value || h
|
|
14
|
+
);
|
|
15
|
+
R(() => {
|
|
16
|
+
d(t.value || h);
|
|
17
|
+
}, [t.value]);
|
|
18
|
+
const y = f?.validation?.some(
|
|
19
|
+
(o) => o.rule === "mandatory" || o.rule === "mandatoryselect"
|
|
20
|
+
) || !1, s = (o) => {
|
|
21
|
+
d(o), b?.({ id: p, value: o });
|
|
22
|
+
}, k = (o) => {
|
|
23
|
+
s(o.target.value);
|
|
24
|
+
}, C = (o) => {
|
|
25
|
+
s(o.target.value);
|
|
26
|
+
}, S = (o) => {
|
|
27
|
+
s(o);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ c(F, { required: y, component: "fieldset", fullWidth: !0, children: [
|
|
30
|
+
r && /* @__PURE__ */ e(I, { component: "legend", children: r }),
|
|
31
|
+
/* @__PURE__ */ c(u, { direction: "row", spacing: 1.5, alignItems: "center", sx: { mt: r ? 1 : 0 }, children: [
|
|
32
|
+
/* @__PURE__ */ e(m, { sx: { ...{
|
|
33
|
+
width: 44,
|
|
34
|
+
height: 44,
|
|
35
|
+
borderRadius: "10px",
|
|
36
|
+
border: (o) => `1px solid ${l(o.palette.text.primary, 0.2)}`,
|
|
37
|
+
boxShadow: (o) => `0 2px 8px ${l(o.palette.common.black, 0.12)}`,
|
|
38
|
+
cursor: "pointer",
|
|
39
|
+
flexShrink: 0,
|
|
40
|
+
position: "relative",
|
|
41
|
+
overflow: "hidden"
|
|
42
|
+
}, backgroundColor: a }, children: /* @__PURE__ */ e(
|
|
43
|
+
"input",
|
|
44
|
+
{
|
|
45
|
+
type: "color",
|
|
46
|
+
"aria-label": r ? `${r} colour` : "colour",
|
|
47
|
+
value: a,
|
|
48
|
+
onChange: k,
|
|
49
|
+
...v,
|
|
50
|
+
style: {
|
|
51
|
+
position: "absolute",
|
|
52
|
+
inset: 0,
|
|
53
|
+
width: "100%",
|
|
54
|
+
height: "100%",
|
|
55
|
+
opacity: 0,
|
|
56
|
+
border: "none",
|
|
57
|
+
padding: 0,
|
|
58
|
+
cursor: "pointer"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
) }),
|
|
62
|
+
/* @__PURE__ */ e(
|
|
63
|
+
A,
|
|
64
|
+
{
|
|
65
|
+
id: p || void 0,
|
|
66
|
+
value: a,
|
|
67
|
+
onChange: C,
|
|
68
|
+
size: "small",
|
|
69
|
+
label: "Hex",
|
|
70
|
+
inputProps: { "aria-label": "hex value" },
|
|
71
|
+
sx: x(B, x({ maxWidth: 160 }, w))
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }),
|
|
75
|
+
Array.isArray(n) && n.length > 0 && /* @__PURE__ */ e(u, { direction: "row", spacing: 1, sx: { mt: 1.5, flexWrap: "wrap", rowGap: 1 }, children: n.map((o) => /* @__PURE__ */ e(
|
|
76
|
+
m,
|
|
77
|
+
{
|
|
78
|
+
role: "button",
|
|
79
|
+
"aria-label": `preset ${o}`,
|
|
80
|
+
onClick: () => S(o),
|
|
81
|
+
sx: {
|
|
82
|
+
width: 26,
|
|
83
|
+
height: 26,
|
|
84
|
+
borderRadius: "8px",
|
|
85
|
+
backgroundColor: o,
|
|
86
|
+
cursor: "pointer",
|
|
87
|
+
flexShrink: 0,
|
|
88
|
+
border: (i) => a === o ? `2px solid ${i.palette.primary.main}` : `1px solid ${l(i.palette.text.primary, 0.2)}`,
|
|
89
|
+
boxShadow: (i) => `0 1px 4px ${l(i.palette.common.black, 0.12)}`
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
o
|
|
93
|
+
)) })
|
|
94
|
+
] });
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
q as default
|
|
98
|
+
};
|