@aglyn/shared-ui-jsx-forms 1.0.0-beta.219 → 1.0.0-beta.221
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/package.json +9 -9
- package/src/lib/components/create-artifact-drawer.component.d.ts +5 -0
- package/src/lib/components/create-artifact-drawer.component.js +6 -1
- package/src/lib/components/create-artifact-drawer.component.js.map +1 -1
- package/src/lib/mapper/select.js +7 -2
- package/src/lib/mapper/select.js.map +1 -1
- package/src/lib/mapper/wizard.js +4 -2
- package/src/lib/mapper/wizard.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-ui-jsx-forms",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.221",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-color-picker": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-theme": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-vendor": "1.0.0-beta.
|
|
28
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.221",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.221",
|
|
30
|
+
"@aglyn/shared-ui-color-picker": "1.0.0-beta.221",
|
|
31
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.221",
|
|
32
|
+
"@aglyn/shared-ui-theme": "1.0.0-beta.221",
|
|
33
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.221",
|
|
34
|
+
"@aglyn/shared-util-vendor": "1.0.0-beta.221",
|
|
35
35
|
"@data-driven-forms/common": "^4.2.0",
|
|
36
36
|
"@data-driven-forms/react-form-renderer": "^4.2.0",
|
|
37
37
|
"@swc/helpers": "0.5.23",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@mui/icons-material": "^9.3.1",
|
|
43
43
|
"@mui/material": "^9.3.1",
|
|
44
44
|
"@mui/x-date-pickers": "^9.12.0",
|
|
45
|
-
"next": "16.3.3",
|
|
45
|
+
"next": "^16.3.3",
|
|
46
46
|
"react": "^19.2.8"
|
|
47
47
|
},
|
|
48
48
|
"sideEffects": false,
|
|
@@ -48,6 +48,11 @@ export interface CreateArtifactDrawerProps {
|
|
|
48
48
|
* that lives in the app and depends on the console's session hook. Defaults
|
|
49
49
|
* to {@link ArtifactFormTemplate}, which is the same layout without that
|
|
50
50
|
* dependency.
|
|
51
|
+
*
|
|
52
|
+
* A template reads form state — `submitting`, `valid` — through a
|
|
53
|
+
* `FormSpy`. The form does not draw its template again when that state
|
|
54
|
+
* changes, so the `pristine` and `valid` on `useFormApi()` keep the values
|
|
55
|
+
* they had when the drawer opened.
|
|
51
56
|
*/
|
|
52
57
|
FormTemplate?: any;
|
|
53
58
|
/** Label on the submit button. */
|
|
@@ -48,6 +48,9 @@ import { simpleComponentMapper } from "../constants/component-mappers.js";
|
|
|
48
48
|
children: formFields
|
|
49
49
|
}),
|
|
50
50
|
/*#__PURE__*/ _jsx(FormSpy, {
|
|
51
|
+
subscription: {
|
|
52
|
+
submitting: true
|
|
53
|
+
},
|
|
51
54
|
children: ({ submitting })=>{
|
|
52
55
|
var _schema_submitLabel;
|
|
53
56
|
return /*#__PURE__*/ _jsx(Box, {
|
|
@@ -132,7 +135,9 @@ export function CreateArtifactDrawer(props) {
|
|
|
132
135
|
onSubmit: onSubmit,
|
|
133
136
|
schema: schema,
|
|
134
137
|
subscription: {
|
|
135
|
-
|
|
138
|
+
pristine: false,
|
|
139
|
+
submitting: false,
|
|
140
|
+
valid: false
|
|
136
141
|
},
|
|
137
142
|
clearOnUnmount: true
|
|
138
143
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/components/create-artifact-drawer.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { Container, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport {\n Box,\n Button,\n FormControl,\n Grid,\n IconButton,\n Typography,\n} from '@mui/material'\nimport { forwardRef, type ReactNode } from 'react'\nimport {\n FormRenderer,\n FormSpy,\n type FormTemplateRenderProps,\n useFormApi,\n} from '../vendor/data-driven-forms'\nimport { simpleComponentMapper } from '../constants/component-mappers'\n\n/**\n * THE naming step in front of Create (AGL-700), shared by every console list\n * surface that creates a record.\n *\n * ## Why it lives in a library\n *\n * It began in `apps/console`, which put it out of reach of the console pages\n * that plugins ship — a plugin's console card cannot import from the app that\n * renders it. So a plugin adding a create button had two options, both bad:\n * an inline form stacked above its table, or a second drawer that looks\n * almost but not quite like this one. Both are how a console comes to have\n * three ways of creating a record.\n *\n * The console keeps a thin wrapper at its old path so its four existing call\n * sites are untouched; it passes its own auth form template through\n * {@link CreateArtifactDrawerProps.FormTemplate}.\n *\n * A drawer rather than a dialog on purpose: creating is a drawer, picking is\n * a dialog (AGL-699). Editing is neither — it is the record's own page.\n */\nexport interface CreateArtifactDrawerProps {\n open: boolean\n onClose: () => void\n /** Drawer heading, e.g. \"Create new component\". */\n title: string\n /** Receives the collected field values; closing is the caller's job. */\n onSubmit: (values: Record<string, any>) => void | Promise<void>\n /** Extra fields appended after name and description. */\n extraFields?: any[]\n /** Rendered under the form when a submit fails. */\n errorSlot?: ReactNode\n /**\n * Whether to offer the shared Description box (AGL-2498).\n *\n * True for every artifact whose document stores one. Content collections do\n * not: `/api/hosts/collections` filters `data` through a per-kind allowlist\n * of `displayName` + `slug`, so a description typed here would be dropped\n * without a word. A field the writer silently discards is worse than a field\n * that was never offered.\n */\n includeDescription?: boolean\n /**\n * The form's own chrome — the submit button and how the fields are laid out.\n *\n * Injectable because the console's version renders an auth-aware template\n * that lives in the app and depends on the console's session hook. Defaults\n * to {@link ArtifactFormTemplate}, which is the same layout without that\n * dependency.\n */\n FormTemplate?: any\n /** Label on the submit button. */\n submitLabel?: string\n}\n\n/**\n * The default chrome: the fields in a grid and one submit button.\n *\n * No Cancel button of its own — the drawer's app bar already carries one, and\n * a second Cancel inside the form is the shape a reader has to think about.\n */\nexport const ArtifactFormTemplate = forwardRef<any, FormTemplateRenderProps>(\n (props, ref) => {\n const { formFields, schema, ...rest } = props\n const { handleSubmit } = useFormApi()\n return (\n <form ref={ref} onSubmit={handleSubmit} noValidate {...rest}>\n {schema.title}\n <Grid spacing={2} container>\n {formFields as any}\n </Grid>\n <FormSpy>\n {({ submitting }) => (\n <Box sx={{ mt: 2 }}>\n <FormControl margin=\"normal\" fullWidth>\n <Button\n color=\"primary\"\n disabled={submitting}\n type=\"submit\"\n variant=\"contained\"\n fullWidth\n >\n {(schema as { submitLabel?: string }).submitLabel ?? 'Next'}\n </Button>\n </FormControl>\n </Box>\n )}\n </FormSpy>\n </form>\n )\n },\n)\nArtifactFormTemplate.displayName = 'ArtifactFormTemplate'\n;(ArtifactFormTemplate as any).aglyn = true\n\nexport function CreateArtifactDrawer(props: CreateArtifactDrawerProps) {\n const {\n open,\n onClose,\n title,\n onSubmit,\n extraFields,\n errorSlot,\n includeDescription = true,\n FormTemplate = ArtifactFormTemplate,\n submitLabel,\n } = props\n const schema = {\n fields: [\n ...(includeDescription\n ? BASE_FIELDS\n : BASE_FIELDS.filter((field) => field.name !== 'description')),\n ...(extraFields ?? []),\n ],\n ...(submitLabel ? { submitLabel } : {}),\n }\n return (\n <NavigationDrawerComponent\n open={open}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={onClose}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={onClose}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>close drawer</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {title}\n </Typography>\n </>\n }\n appBarRight={\n <Button variant=\"outlined\" color=\"inherit\" onClick={onClose}>\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n <FormRenderer\n FormTemplate={FormTemplate}\n componentMapper={simpleComponentMapper}\n onSubmit={onSubmit}\n schema={schema}\n subscription={{ values: true }}\n clearOnUnmount\n />\n {errorSlot}\n </Container>\n </NavigationDrawerComponent>\n )\n}\n\n/**\n * Same shape and limits the layouts drawer has used since AGL-473, so the\n * creates across the console validate identically.\n */\nexport const BASE_FIELDS = [\n {\n component: 'text-field',\n name: 'displayName',\n helperText: 'Friendly name for internal reference',\n type: 'text',\n label: 'Display name',\n isRequired: true,\n validate: [\n { type: 'required', message: 'Provide a display name' },\n {\n type: 'max-length',\n threshold: 25,\n message: 'Must not exceed 25 characters',\n },\n ],\n },\n {\n component: 'textarea',\n name: 'description',\n label: 'Description',\n helperText: 'Brief description for internal reference',\n validate: [\n {\n type: 'max-length',\n threshold: 80,\n message: 'Must not exceed 80 characters',\n },\n ],\n },\n]\n\nCreateArtifactDrawer.displayName = 'CreateArtifactDrawer'\n\nexport default CreateArtifactDrawer\n"],"names":["ICON_VARIANT_CLOSE","Container","MdiIcon","SrOnly","NavigationDrawerComponent","Box","Button","FormControl","Grid","IconButton","Typography","forwardRef","FormRenderer","FormSpy","useFormApi","simpleComponentMapper","ArtifactFormTemplate","props","ref","formFields","schema","rest","handleSubmit","form","onSubmit","noValidate","title","spacing","container","submitting","sx","mt","margin","fullWidth","color","disabled","type","variant","submitLabel","displayName","aglyn","CreateArtifactDrawer","open","onClose","extraFields","errorSlot","includeDescription","FormTemplate","fields","BASE_FIELDS","filter","field","name","anchor","AppBarProps","appBarLeft","edge","onClick","mr","path","component","appBarRight","gutterY","componentMapper","subscription","values","clearOnUnmount","helperText","label","isRequired","validate","message","threshold"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SAASA,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,uBAAsB;AACjE,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SACEC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,IAAI,EACJC,UAAU,EACVC,UAAU,QACL,gBAAe;AACtB,SAASC,UAAU,QAAwB,QAAO;AAClD,SACEC,YAAY,EACZC,OAAO,EAEPC,UAAU,QACL,iCAA6B;AACpC,SAASC,qBAAqB,QAAQ,oCAAgC;AAwDtE;;;;;CAKC,GACD,OAAO,MAAMC,qCAAuBL,WAClC,CAACM,OAAOC;IACN,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAW,GAAGH,OAATI,wCAASJ;;;;IACxC,MAAM,EAAEK,YAAY,EAAE,GAAGR;IACzB,qBACE,MAACS;QAAKL,KAAKA;QAAKM,UAAUF;QAAcG,UAAU;OAAKJ;;YACpDD,OAAOM,KAAK;0BACb,KAAClB;gBAAKmB,SAAS;gBAAGC,SAAS;0BACxBT;;0BAEH,KAACN;0BACE,CAAC,EAAEgB,UAAU,EAAE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A;oBACVJ,QAAQA;oBACR4C,cAAc;wBAAEC,QAAQ;oBAAK;oBAC7BC,cAAc;;gBAEfrB;;;;AAIT;AAEA;;;CAGC,GACD,OAAO,MAAMI,cAAc;IACzB;QACEW,WAAW;QACXR,MAAM;QACNe,YAAY;QACZ/B,MAAM;QACNgC,OAAO;QACPC,YAAY;QACZC,UAAU;YACR;gBAAElC,MAAM;gBAAYmC,SAAS;YAAyB;YACtD;gBACEnC,MAAM;gBACNoC,WAAW;gBACXD,SAAS;YACX;SACD;IACH;IACA;QACEX,WAAW;QACXR,MAAM;QACNgB,OAAO;QACPD,YAAY;QACZG,UAAU;YACR;gBACElC,MAAM;gBACNoC,WAAW;gBACXD,SAAS;YACX;SACD;IACH;CACD,CAAA;AAED9B,qBAAqBF,WAAW,GAAG;AAEnC,eAAeE,qBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/components/create-artifact-drawer.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { Container, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport {\n Box,\n Button,\n FormControl,\n Grid,\n IconButton,\n Typography,\n} from '@mui/material'\nimport { forwardRef, type ReactNode } from 'react'\nimport {\n FormRenderer,\n FormSpy,\n type FormTemplateRenderProps,\n useFormApi,\n} from '../vendor/data-driven-forms'\nimport { simpleComponentMapper } from '../constants/component-mappers'\n\n/**\n * THE naming step in front of Create (AGL-700), shared by every console list\n * surface that creates a record.\n *\n * ## Why it lives in a library\n *\n * It began in `apps/console`, which put it out of reach of the console pages\n * that plugins ship — a plugin's console card cannot import from the app that\n * renders it. So a plugin adding a create button had two options, both bad:\n * an inline form stacked above its table, or a second drawer that looks\n * almost but not quite like this one. Both are how a console comes to have\n * three ways of creating a record.\n *\n * The console keeps a thin wrapper at its old path so its four existing call\n * sites are untouched; it passes its own auth form template through\n * {@link CreateArtifactDrawerProps.FormTemplate}.\n *\n * A drawer rather than a dialog on purpose: creating is a drawer, picking is\n * a dialog (AGL-699). Editing is neither — it is the record's own page.\n */\nexport interface CreateArtifactDrawerProps {\n open: boolean\n onClose: () => void\n /** Drawer heading, e.g. \"Create new component\". */\n title: string\n /** Receives the collected field values; closing is the caller's job. */\n onSubmit: (values: Record<string, any>) => void | Promise<void>\n /** Extra fields appended after name and description. */\n extraFields?: any[]\n /** Rendered under the form when a submit fails. */\n errorSlot?: ReactNode\n /**\n * Whether to offer the shared Description box (AGL-2498).\n *\n * True for every artifact whose document stores one. Content collections do\n * not: `/api/hosts/collections` filters `data` through a per-kind allowlist\n * of `displayName` + `slug`, so a description typed here would be dropped\n * without a word. A field the writer silently discards is worse than a field\n * that was never offered.\n */\n includeDescription?: boolean\n /**\n * The form's own chrome — the submit button and how the fields are laid out.\n *\n * Injectable because the console's version renders an auth-aware template\n * that lives in the app and depends on the console's session hook. Defaults\n * to {@link ArtifactFormTemplate}, which is the same layout without that\n * dependency.\n *\n * A template reads form state — `submitting`, `valid` — through a\n * `FormSpy`. The form does not draw its template again when that state\n * changes, so the `pristine` and `valid` on `useFormApi()` keep the values\n * they had when the drawer opened.\n */\n FormTemplate?: any\n /** Label on the submit button. */\n submitLabel?: string\n}\n\n/**\n * The default chrome: the fields in a grid and one submit button.\n *\n * No Cancel button of its own — the drawer's app bar already carries one, and\n * a second Cancel inside the form is the shape a reader has to think about.\n */\nexport const ArtifactFormTemplate = forwardRef<any, FormTemplateRenderProps>(\n (props, ref) => {\n const { formFields, schema, ...rest } = props\n const { handleSubmit } = useFormApi()\n return (\n <form ref={ref} onSubmit={handleSubmit} noValidate {...rest}>\n {schema.title}\n <Grid spacing={2} container>\n {formFields as any}\n </Grid>\n {/* `submitting` alone: it is all the button reads, and a spy with\n no subscription draws the button again on every keystroke. */}\n <FormSpy subscription={{ submitting: true }}>\n {({ submitting }) => (\n <Box sx={{ mt: 2 }}>\n <FormControl margin=\"normal\" fullWidth>\n <Button\n color=\"primary\"\n disabled={submitting}\n type=\"submit\"\n variant=\"contained\"\n fullWidth\n >\n {(schema as { submitLabel?: string }).submitLabel ?? 'Next'}\n </Button>\n </FormControl>\n </Box>\n )}\n </FormSpy>\n </form>\n )\n },\n)\nArtifactFormTemplate.displayName = 'ArtifactFormTemplate'\n;(ArtifactFormTemplate as any).aglyn = true\n\nexport function CreateArtifactDrawer(props: CreateArtifactDrawerProps) {\n const {\n open,\n onClose,\n title,\n onSubmit,\n extraFields,\n errorSlot,\n includeDescription = true,\n FormTemplate = ArtifactFormTemplate,\n submitLabel,\n } = props\n const schema = {\n fields: [\n ...(includeDescription\n ? BASE_FIELDS\n : BASE_FIELDS.filter((field) => field.name !== 'description')),\n ...(extraFields ?? []),\n ],\n ...(submitLabel ? { submitLabel } : {}),\n }\n return (\n <NavigationDrawerComponent\n open={open}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={onClose}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={onClose}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>close drawer</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {title}\n </Typography>\n </>\n }\n appBarRight={\n <Button variant=\"outlined\" color=\"inherit\" onClick={onClose}>\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n {/*\n The form subscribes to nothing, so a keystroke draws the field it\n lands in and no other (AGL-3423). Each field reads its own state, a\n condition watches the fields it names, and the template's button\n watches `submitting` through its own FormSpy: nothing here is drawn\n from the form's state as a whole. The renderer's own defaults —\n pristine, submitting, valid — are switched off too: a change in any\n of them draws every field again, and the first letter of a required\n name changes two of them.\n */}\n <FormRenderer\n FormTemplate={FormTemplate}\n componentMapper={simpleComponentMapper}\n onSubmit={onSubmit}\n schema={schema}\n subscription={{ pristine: false, submitting: false, valid: false }}\n clearOnUnmount\n />\n {errorSlot}\n </Container>\n </NavigationDrawerComponent>\n )\n}\n\n/**\n * Same shape and limits the layouts drawer has used since AGL-473, so the\n * creates across the console validate identically.\n */\nexport const BASE_FIELDS = [\n {\n component: 'text-field',\n name: 'displayName',\n helperText: 'Friendly name for internal reference',\n type: 'text',\n label: 'Display name',\n isRequired: true,\n validate: [\n { type: 'required', message: 'Provide a display name' },\n {\n type: 'max-length',\n threshold: 25,\n message: 'Must not exceed 25 characters',\n },\n ],\n },\n {\n component: 'textarea',\n name: 'description',\n label: 'Description',\n helperText: 'Brief description for internal reference',\n validate: [\n {\n type: 'max-length',\n threshold: 80,\n message: 'Must not exceed 80 characters',\n },\n ],\n },\n]\n\nCreateArtifactDrawer.displayName = 'CreateArtifactDrawer'\n\nexport default CreateArtifactDrawer\n"],"names":["ICON_VARIANT_CLOSE","Container","MdiIcon","SrOnly","NavigationDrawerComponent","Box","Button","FormControl","Grid","IconButton","Typography","forwardRef","FormRenderer","FormSpy","useFormApi","simpleComponentMapper","ArtifactFormTemplate","props","ref","formFields","schema","rest","handleSubmit","form","onSubmit","noValidate","title","spacing","container","subscription","submitting","sx","mt","margin","fullWidth","color","disabled","type","variant","submitLabel","displayName","aglyn","CreateArtifactDrawer","open","onClose","extraFields","errorSlot","includeDescription","FormTemplate","fields","BASE_FIELDS","filter","field","name","anchor","AppBarProps","appBarLeft","edge","onClick","mr","path","component","appBarRight","gutterY","componentMapper","pristine","valid","clearOnUnmount","helperText","label","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AU;YACR;gBACElC,MAAM;gBACNoC,WAAW;gBACXD,SAAS;YACX;SACD;IACH;CACD,CAAA;AAED9B,qBAAqBF,WAAW,GAAG;AAEnC,eAAeE,qBAAoB"}
|
package/src/lib/mapper/select.js
CHANGED
|
@@ -23,8 +23,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
23
23
|
*/ import { memo, useMemo, useRef } from "react";
|
|
24
24
|
import { Autocomplete, CircularProgress, TextField } from "@mui/material";
|
|
25
25
|
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Both from the FOLDER entry, whose `module` field is the ESM build. The deep
|
|
27
|
+
// file `select/parse-internal-value` is CommonJS whose default export sits on
|
|
28
|
+
// `exports.default`, and a bundler reading this package's ESM output under
|
|
29
|
+
// Node's rules hands a default import the whole `exports` object, so the
|
|
30
|
+
// published editor threw "is not a function" the moment a select rendered
|
|
31
|
+
// (AGL-3201).
|
|
32
|
+
import DDFSelectImport, { parseInternalValue } from "@data-driven-forms/common/select";
|
|
28
33
|
import { useFieldApi } from "../vendor/data-driven-forms.js";
|
|
29
34
|
import FormFieldGrid, { buildFieldClear } from "./form-field-grid.js";
|
|
30
35
|
import { validationError } from "./validation-error.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/mapper/select.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Ported from `@data-driven-forms/mui-component-mapper` (Apache-2.0) and\n * updated for the current MUI API (`slotProps`-shaped Autocomplete\n * `renderInput` params instead of `inputProps`).\n */\n\nimport { memo, useMemo, useRef } from 'react'\n\nimport {\n Autocomplete,\n CircularProgress,\n TextField,\n} from '@mui/material'\n\nimport ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'\n\nimport DDFSelectImport from '@data-driven-forms/common/select'\nimport parseInternalValue from '@data-driven-forms/common/select/parse-internal-value'\n\nimport { useFieldApi } from '../vendor/data-driven-forms'\nimport FormFieldGrid, {\n buildFieldClear,\n type FormFieldGridProps,\n} from './form-field-grid'\nimport type { BaseFieldProps, OptionValue, SelectOption, SelectValue } from './types'\nimport { type ExtendedFieldMeta, validationError } from './validation-error'\n\nexport interface SelectProps<T = OptionValue> extends BaseFieldProps {\n options?: SelectOption<T>[]\n loadOptions?: (inputValue: string) => Promise<SelectOption<T>[]>\n isSearchable?: boolean\n isMulti?: boolean\n multiple?: boolean\n isClearable?: boolean\n disableClearable?: boolean\n hideSelectedOptions?: boolean\n closeMenuOnSelect?: boolean\n isFetching?: boolean\n noOptionsMessage?: () => string\n noOptionsText?: () => string\n loadingMessage?: string\n loadingText?: string\n placeholder?: string\n /** Offer the reset-to-unset affordance (AGL-2486). */\n clearable?: boolean\n FormFieldGridProps?: FormFieldGridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TextFieldProps?: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n inputProps?: Record<string, any>\n onInputChange?: (value: string, reason?: string) => void\n /**\n * A schema field's own hook on the search box, beside DDF's.\n *\n * `onInputChange` cannot be one. `@data-driven-forms/common/select` owns\n * that prop for its `loadOptions` support and assigns it AFTER spreading the\n * field's props, so a handler declared on a schema field is overwritten\n * before it reaches this component — silently, since a dropdown with a\n * dropped handler still opens, still filters and still selects. A field\n * whose typing was supposed to fetch more simply fetches nothing.\n *\n * This name is not taken, so it survives the spread. Both are called.\n */\n onSearchInput?: (value: string, reason?: string) => void\n}\n\n/** Returns label of the selected option. */\nexport function getOptionLabel<T = OptionValue>(\n option: T | SelectOption<T> | undefined,\n options: SelectOption<T>[],\n): string {\n if (typeof option === 'undefined') {\n return ''\n }\n\n if ((option as unknown) === '') {\n return ''\n }\n\n if (Array.isArray(option) && option.length === 0) {\n return ''\n }\n\n if (typeof option === 'object' && option !== null) {\n return String((option as SelectOption<T>).label)\n }\n\n const item = options.find(({ value }) => value === option)\n return (item && String(item.label)) || ''\n}\n\n/** Creates the DDF select value format. */\nexport function createValue<T = OptionValue>(\n option: T | SelectOption<T> | (T | SelectOption<T>)[] | null,\n isMulti: boolean,\n): T | SelectOption<T> | (T | SelectOption<T>)[] | null | undefined {\n if (isMulti) {\n return Array.isArray(option)\n ? option.map((item) =>\n typeof item === 'object' ? item : ({ value: item } as SelectOption<T>),\n )\n : option\n }\n\n return option\n}\n\ninterface InternalSelectProps<T = OptionValue> {\n value: SelectValue<T>\n options: SelectOption<T>[]\n label?: string\n helperText?: string\n validateOnMount?: boolean\n meta: ExtendedFieldMeta\n isSearchable?: boolean\n description?: string\n isMulti?: boolean\n placeholder?: string\n onInputChange?: (value: string, reason?: string) => void\n onSearchInput?: (value: string, reason?: string) => void\n isFetching?: boolean\n noOptionsMessage?: () => string\n hideSelectedOptions?: boolean\n closeMenuOnSelect?: boolean\n required?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (value: any) => void\n onFocus?: () => void\n onBlur?: () => void\n FormFieldGridProps?: FormFieldGridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TextFieldProps?: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n inputProps?: Record<string, any>\n isClearable?: boolean\n isDisabled?: boolean\n loadingText?: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nfunction InternalSelectView<T = OptionValue>({\n value,\n options,\n label,\n helperText,\n validateOnMount,\n meta,\n isSearchable,\n description,\n isMulti,\n placeholder = 'Please choose',\n onInputChange,\n onSearchInput,\n isFetching,\n noOptionsText,\n hideSelectedOptions,\n closeMenuOnSelect: _closeMenuOnSelect,\n required,\n onChange,\n onFocus,\n onBlur,\n help,\n FormFieldGridProps = {},\n TextFieldProps: { inputProps: textFieldInputProps, ...TextFieldProps } = {},\n inputProps = {},\n isClearable,\n isDisabled,\n clearable,\n loadingText = 'Loading...',\n // @data-driven-forms/common always injects classNamePrefix (a\n // react-select concern) into its SelectComponent; keep it out of the\n // Autocomplete spread so it never reaches the DOM (AGL-590).\n classNamePrefix: _classNamePrefix,\n ...rest\n}: InternalSelectProps<T>) {\n const invalid = validationError(meta, validateOnMount)\n // When isMulti is true, parseInternalValue always creates a new array; keep\n // the reference stable across renders.\n const internalValue = useMemo(\n () => parseInternalValue(value, isMulti),\n [value, isMulti],\n )\n\n // Selects ship with `disableClearable` on by default here, so the\n // Autocomplete's own ✕ never appears and a chosen option could not be\n // taken back off (AGL-2486). One affordance for every field type beats\n // flipping that default, which would move the control for some fields\n // and not others.\n const clear = buildFieldClear({\n clearable,\n label,\n hasValue: Array.isArray(internalValue)\n ? internalValue.length > 0\n : internalValue !== undefined &&\n internalValue !== null &&\n internalValue !== '',\n locked: Boolean(isDisabled),\n onClear: () => onChange(createValue(null, !!isMulti)),\n })\n\n return (\n <FormFieldGrid help={help} clear={clear} {...FormFieldGridProps}>\n <Autocomplete\n filterSelectedOptions={hideSelectedOptions}\n disabled={isDisabled}\n disableClearable={isClearable}\n popupIcon={\n isFetching ? (\n <CircularProgress size={20} color=\"inherit\" />\n ) : (\n <ArrowDropDownIcon />\n )\n }\n fullWidth\n loadingText={loadingText}\n {...rest}\n renderInput={(params) => (\n <TextField\n onFocus={onFocus}\n onBlur={onBlur}\n {...params}\n required={required}\n error={!!invalid}\n helperText={\n invalid ||\n ((meta.touched || validateOnMount) && meta.warning) ||\n helperText ||\n description\n }\n label={label}\n margin=\"normal\"\n {...TextFieldProps}\n slotProps={{\n ...params.slotProps,\n ...TextFieldProps.slotProps,\n htmlInput: {\n ...params.slotProps?.htmlInput,\n ...textFieldInputProps,\n ...inputProps,\n readOnly: !isSearchable,\n placeholder:\n !internalValue ||\n (internalValue as unknown[]).length === 0\n ? placeholder\n : undefined,\n },\n }}\n />\n )}\n noOptionsText={noOptionsText}\n /*\n * The REASON travels with the text.\n *\n * Autocomplete emits this for a typed character (`input`), for the\n * field taking its own value back (`reset` — which fires on mount and\n * again on every selection) and for the clear button (`clear`). A\n * handler that treats all three alike cannot tell somebody searching\n * from the field describing itself, and one that spends a read per\n * query would spend one on simply opening the panel.\n */\n onInputChange={(_event, value, reason) => {\n onInputChange?.(value, reason)\n onSearchInput?.(value, reason)\n }}\n options={options}\n multiple={isMulti}\n getOptionLabel={(option) =>\n getOptionLabel(option as T | SelectOption<T>, options)\n }\n value={typeof internalValue === 'undefined' ? null : internalValue}\n onChange={(_event, option) =>\n onChange(createValue(option as SelectOption<T> | null, !!isMulti))\n }\n loading={isFetching}\n />\n </FormFieldGrid>\n )\n}\n\n/**\n * Whether the Autocomplete would draw the same thing: every prop the same,\n * except `meta`, which final-form hands over as a new object on every render\n * and which is compared by what it holds.\n */\nfunction drawsTheSame(\n previous: Record<string, unknown>,\n next: Record<string, unknown>,\n): boolean {\n const keys = new Set([...Object.keys(previous), ...Object.keys(next)])\n for (const key of keys) {\n const before = previous[key]\n const after = next[key]\n if (Object.is(before, after)) continue\n if (key === 'meta' && shallowEqual(before, after)) continue\n return false\n }\n return true\n}\n\nfunction shallowEqual(a: unknown, b: unknown): boolean {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false\n const left = a as Record<string, unknown>\n const right = b as Record<string, unknown>\n const keys = Object.keys(left)\n if (keys.length !== Object.keys(right).length) return false\n return keys.every((key) => Object.is(left[key], right[key]))\n}\n\nconst MemoizedSelectView = memo(\n InternalSelectView,\n drawsTheSame,\n) as typeof InternalSelectView\n\n/**\n * The select, drawn only when something it draws has changed (AGL-3423).\n *\n * A multiple select is a multiple Autocomplete, which hands its input a new\n * chip array as `startAdornment` on every render; MUI's `InputBase` copies\n * that into its `FormControl` from a passive effect, a state update left\n * pending after every commit the field takes part in. React 19 counts each\n * such commit as a nested update, and keystrokes delivered back to back\n * commit one after another with nothing to clear the count, so the\n * fifty-first throws \"Maximum update depth exceeded\" (#185). A form that\n * re-renders its fields on every change (a `values` subscription, an owner\n * that keeps the values in state) re-rendered every multi-select with each\n * keystroke in ANY field.\n *\n * So the drawing is memoized, and what defeated a plain `memo` is taken out\n * of the comparison: the handlers, which final-form and the common select\n * rebuild on every render, are called through the latest props instead of\n * compared, and the no-options text is resolved here, where the common\n * select's per-render function for it is called.\n */\nfunction InternalSelect<T = OptionValue>(props: InternalSelectProps<T>) {\n const latest = useRef(props)\n latest.current = props\n const handlers = useMemo(\n () => ({\n onChange: (value: unknown) => latest.current.onChange(value),\n onFocus: (...args: unknown[]) =>\n (latest.current.onFocus as ((...args: unknown[]) => void) | undefined)?.(\n ...args,\n ),\n onBlur: (...args: unknown[]) =>\n (latest.current.onBlur as ((...args: unknown[]) => void) | undefined)?.(\n ...args,\n ),\n onInputChange: (value: string, reason?: string) =>\n latest.current.onInputChange?.(value, reason),\n onSearchInput: (value: string, reason?: string) =>\n latest.current.onSearchInput?.(value, reason),\n }),\n [],\n )\n const { noOptionsMessage, ...drawn } = props\n return (\n <MemoizedSelectView<T>\n {...drawn}\n {...handlers}\n noOptionsText={noOptionsMessage && noOptionsMessage()}\n />\n )\n}\n\n// The common Select's prop types are renderer-version specific; pass through.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DDFSelect = DDFSelectImport as React.ComponentType<any>\n\nexport function Select<T = OptionValue>(props: SelectProps<T>) {\n const {\n input,\n isRequired,\n isDisabled,\n isReadOnly,\n disabled,\n multiple,\n isMulti,\n isClearable,\n disableClearable,\n loadingMessage,\n loadingText,\n noOptionsMessage,\n noOptionsText,\n closeMenuOnSelect,\n ...rest\n } = useFieldApi(props)\n\n return (\n <DDFSelect\n {...input}\n isMulti={multiple || isMulti}\n required={isRequired}\n disabled={isDisabled || isReadOnly || disabled}\n disableClearable={!isClearable || disableClearable}\n loadingText={loadingMessage || loadingText}\n noOptionsMessage={noOptionsMessage || noOptionsText}\n closeMenuOnSelect={closeMenuOnSelect}\n {...rest}\n SelectComponent={InternalSelect}\n />\n )\n}\n\nexport default Select\n"],"names":["memo","useMemo","useRef","Autocomplete","CircularProgress","TextField","ArrowDropDownIcon","DDFSelectImport","parseInternalValue","useFieldApi","FormFieldGrid","buildFieldClear","validationError","getOptionLabel","option","options","Array","isArray","length","String","label","item","find","value","createValue","isMulti","map","InternalSelectView","helperText","validateOnMount","meta","isSearchable","description","placeholder","onInputChange","onSearchInput","isFetching","noOptionsText","hideSelectedOptions","closeMenuOnSelect","_closeMenuOnSelect","required","onChange","onFocus","onBlur","help","FormFieldGridProps","TextFieldProps","inputProps","textFieldInputProps","isClearable","isDisabled","clearable","loadingText","classNamePrefix","_classNamePrefix","rest","invalid","internalValue","clear","hasValue","undefined","locked","Boolean","onClear","filterSelectedOptions","disabled","disableClearable","popupIcon","size","color","fullWidth","renderInput","params","error","touched","warning","margin","slotProps","htmlInput","readOnly","_event","reason","multiple","loading","drawsTheSame","previous","next","keys","Set","Object","key","before","after","is","shallowEqual","a","b","left","right","every","MemoizedSelectView","InternalSelect","props","latest","current","handlers","args","noOptionsMessage","drawn","DDFSelect","Select","input","isRequired","isReadOnly","loadingMessage","SelectComponent"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC,GAED,SAASA,IAAI,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAE7C,SACEC,YAAY,EACZC,gBAAgB,EAChBC,SAAS,QACJ,gBAAe;AAEtB,OAAOC,uBAAuB,oCAAmC;AAEjE,OAAOC,qBAAqB,mCAAkC;AAC9D,OAAOC,wBAAwB,wDAAuD;AAEtF,SAASC,WAAW,QAAQ,iCAA6B;AACzD,OAAOC,iBACLC,eAAe,QAEV,uBAAmB;AAE1B,SAAiCC,eAAe,QAA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B,WAAW,EACXiB,gBAAgB,EAChBgD,cAAc,EACd9D,WAAW,EACXuD,gBAAgB,EAChBvE,aAAa,EACbE,iBAAiB,EAElB,GAAG9B,cADC+C,wCACD/C;;;;;;;;;;;;;;;;IAEJ,qBACE,KAACqG,wBACKE;QACJvF,SAAS0D,YAAY1D;QACrBgB,UAAUwE;QACV/C,UAAUf,cAAc+D,cAAchD;QACtCC,kBAAkB,CAACjB,eAAeiB;QAClCd,aAAa8D,kBAAkB9D;QAC/BuD,kBAAkBA,oBAAoBvE;QACtCE,mBAAmBA;OACfiB;QACJ4D,iBAAiBd;;AAGvB;AAEA,eAAeS,OAAM"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/mapper/select.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Ported from `@data-driven-forms/mui-component-mapper` (Apache-2.0) and\n * updated for the current MUI API (`slotProps`-shaped Autocomplete\n * `renderInput` params instead of `inputProps`).\n */\n\nimport { memo, useMemo, useRef } from 'react'\n\nimport {\n Autocomplete,\n CircularProgress,\n TextField,\n} from '@mui/material'\n\nimport ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'\n\n// Both from the FOLDER entry, whose `module` field is the ESM build. The deep\n// file `select/parse-internal-value` is CommonJS whose default export sits on\n// `exports.default`, and a bundler reading this package's ESM output under\n// Node's rules hands a default import the whole `exports` object, so the\n// published editor threw \"is not a function\" the moment a select rendered\n// (AGL-3201).\nimport DDFSelectImport, { parseInternalValue } from '@data-driven-forms/common/select'\n\nimport { useFieldApi } from '../vendor/data-driven-forms'\nimport FormFieldGrid, {\n buildFieldClear,\n type FormFieldGridProps,\n} from './form-field-grid'\nimport type { BaseFieldProps, OptionValue, SelectOption, SelectValue } from './types'\nimport { type ExtendedFieldMeta, validationError } from './validation-error'\n\nexport interface SelectProps<T = OptionValue> extends BaseFieldProps {\n options?: SelectOption<T>[]\n loadOptions?: (inputValue: string) => Promise<SelectOption<T>[]>\n isSearchable?: boolean\n isMulti?: boolean\n multiple?: boolean\n isClearable?: boolean\n disableClearable?: boolean\n hideSelectedOptions?: boolean\n closeMenuOnSelect?: boolean\n isFetching?: boolean\n noOptionsMessage?: () => string\n noOptionsText?: () => string\n loadingMessage?: string\n loadingText?: string\n placeholder?: string\n /** Offer the reset-to-unset affordance (AGL-2486). */\n clearable?: boolean\n FormFieldGridProps?: FormFieldGridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TextFieldProps?: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n inputProps?: Record<string, any>\n onInputChange?: (value: string, reason?: string) => void\n /**\n * A schema field's own hook on the search box, beside DDF's.\n *\n * `onInputChange` cannot be one. `@data-driven-forms/common/select` owns\n * that prop for its `loadOptions` support and assigns it AFTER spreading the\n * field's props, so a handler declared on a schema field is overwritten\n * before it reaches this component — silently, since a dropdown with a\n * dropped handler still opens, still filters and still selects. A field\n * whose typing was supposed to fetch more simply fetches nothing.\n *\n * This name is not taken, so it survives the spread. Both are called.\n */\n onSearchInput?: (value: string, reason?: string) => void\n}\n\n/** Returns label of the selected option. */\nexport function getOptionLabel<T = OptionValue>(\n option: T | SelectOption<T> | undefined,\n options: SelectOption<T>[],\n): string {\n if (typeof option === 'undefined') {\n return ''\n }\n\n if ((option as unknown) === '') {\n return ''\n }\n\n if (Array.isArray(option) && option.length === 0) {\n return ''\n }\n\n if (typeof option === 'object' && option !== null) {\n return String((option as SelectOption<T>).label)\n }\n\n const item = options.find(({ value }) => value === option)\n return (item && String(item.label)) || ''\n}\n\n/** Creates the DDF select value format. */\nexport function createValue<T = OptionValue>(\n option: T | SelectOption<T> | (T | SelectOption<T>)[] | null,\n isMulti: boolean,\n): T | SelectOption<T> | (T | SelectOption<T>)[] | null | undefined {\n if (isMulti) {\n return Array.isArray(option)\n ? option.map((item) =>\n typeof item === 'object' ? item : ({ value: item } as SelectOption<T>),\n )\n : option\n }\n\n return option\n}\n\ninterface InternalSelectProps<T = OptionValue> {\n value: SelectValue<T>\n options: SelectOption<T>[]\n label?: string\n helperText?: string\n validateOnMount?: boolean\n meta: ExtendedFieldMeta\n isSearchable?: boolean\n description?: string\n isMulti?: boolean\n placeholder?: string\n onInputChange?: (value: string, reason?: string) => void\n onSearchInput?: (value: string, reason?: string) => void\n isFetching?: boolean\n noOptionsMessage?: () => string\n hideSelectedOptions?: boolean\n closeMenuOnSelect?: boolean\n required?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (value: any) => void\n onFocus?: () => void\n onBlur?: () => void\n FormFieldGridProps?: FormFieldGridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TextFieldProps?: Record<string, any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n inputProps?: Record<string, any>\n isClearable?: boolean\n isDisabled?: boolean\n loadingText?: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nfunction InternalSelectView<T = OptionValue>({\n value,\n options,\n label,\n helperText,\n validateOnMount,\n meta,\n isSearchable,\n description,\n isMulti,\n placeholder = 'Please choose',\n onInputChange,\n onSearchInput,\n isFetching,\n noOptionsText,\n hideSelectedOptions,\n closeMenuOnSelect: _closeMenuOnSelect,\n required,\n onChange,\n onFocus,\n onBlur,\n help,\n FormFieldGridProps = {},\n TextFieldProps: { inputProps: textFieldInputProps, ...TextFieldProps } = {},\n inputProps = {},\n isClearable,\n isDisabled,\n clearable,\n loadingText = 'Loading...',\n // @data-driven-forms/common always injects classNamePrefix (a\n // react-select concern) into its SelectComponent; keep it out of the\n // Autocomplete spread so it never reaches the DOM (AGL-590).\n classNamePrefix: _classNamePrefix,\n ...rest\n}: InternalSelectProps<T>) {\n const invalid = validationError(meta, validateOnMount)\n // When isMulti is true, parseInternalValue always creates a new array; keep\n // the reference stable across renders.\n const internalValue = useMemo(\n () => parseInternalValue(value, isMulti),\n [value, isMulti],\n )\n\n // Selects ship with `disableClearable` on by default here, so the\n // Autocomplete's own ✕ never appears and a chosen option could not be\n // taken back off (AGL-2486). One affordance for every field type beats\n // flipping that default, which would move the control for some fields\n // and not others.\n const clear = buildFieldClear({\n clearable,\n label,\n hasValue: Array.isArray(internalValue)\n ? internalValue.length > 0\n : internalValue !== undefined &&\n internalValue !== null &&\n internalValue !== '',\n locked: Boolean(isDisabled),\n onClear: () => onChange(createValue(null, !!isMulti)),\n })\n\n return (\n <FormFieldGrid help={help} clear={clear} {...FormFieldGridProps}>\n <Autocomplete\n filterSelectedOptions={hideSelectedOptions}\n disabled={isDisabled}\n disableClearable={isClearable}\n popupIcon={\n isFetching ? (\n <CircularProgress size={20} color=\"inherit\" />\n ) : (\n <ArrowDropDownIcon />\n )\n }\n fullWidth\n loadingText={loadingText}\n {...rest}\n renderInput={(params) => (\n <TextField\n onFocus={onFocus}\n onBlur={onBlur}\n {...params}\n required={required}\n error={!!invalid}\n helperText={\n invalid ||\n ((meta.touched || validateOnMount) && meta.warning) ||\n helperText ||\n description\n }\n label={label}\n margin=\"normal\"\n {...TextFieldProps}\n slotProps={{\n ...params.slotProps,\n ...TextFieldProps.slotProps,\n htmlInput: {\n ...params.slotProps?.htmlInput,\n ...textFieldInputProps,\n ...inputProps,\n readOnly: !isSearchable,\n placeholder:\n !internalValue ||\n (internalValue as unknown[]).length === 0\n ? placeholder\n : undefined,\n },\n }}\n />\n )}\n noOptionsText={noOptionsText}\n /*\n * The REASON travels with the text.\n *\n * Autocomplete emits this for a typed character (`input`), for the\n * field taking its own value back (`reset` — which fires on mount and\n * again on every selection) and for the clear button (`clear`). A\n * handler that treats all three alike cannot tell somebody searching\n * from the field describing itself, and one that spends a read per\n * query would spend one on simply opening the panel.\n */\n onInputChange={(_event, value, reason) => {\n onInputChange?.(value, reason)\n onSearchInput?.(value, reason)\n }}\n options={options}\n multiple={isMulti}\n getOptionLabel={(option) =>\n getOptionLabel(option as T | SelectOption<T>, options)\n }\n value={typeof internalValue === 'undefined' ? null : internalValue}\n onChange={(_event, option) =>\n onChange(createValue(option as SelectOption<T> | null, !!isMulti))\n }\n loading={isFetching}\n />\n </FormFieldGrid>\n )\n}\n\n/**\n * Whether the Autocomplete would draw the same thing: every prop the same,\n * except `meta`, which final-form hands over as a new object on every render\n * and which is compared by what it holds.\n */\nfunction drawsTheSame(\n previous: Record<string, unknown>,\n next: Record<string, unknown>,\n): boolean {\n const keys = new Set([...Object.keys(previous), ...Object.keys(next)])\n for (const key of keys) {\n const before = previous[key]\n const after = next[key]\n if (Object.is(before, after)) continue\n if (key === 'meta' && shallowEqual(before, after)) continue\n return false\n }\n return true\n}\n\nfunction shallowEqual(a: unknown, b: unknown): boolean {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false\n const left = a as Record<string, unknown>\n const right = b as Record<string, unknown>\n const keys = Object.keys(left)\n if (keys.length !== Object.keys(right).length) return false\n return keys.every((key) => Object.is(left[key], right[key]))\n}\n\nconst MemoizedSelectView = memo(\n InternalSelectView,\n drawsTheSame,\n) as typeof InternalSelectView\n\n/**\n * The select, drawn only when something it draws has changed (AGL-3423).\n *\n * A multiple select is a multiple Autocomplete, which hands its input a new\n * chip array as `startAdornment` on every render; MUI's `InputBase` copies\n * that into its `FormControl` from a passive effect, a state update left\n * pending after every commit the field takes part in. React 19 counts each\n * such commit as a nested update, and keystrokes delivered back to back\n * commit one after another with nothing to clear the count, so the\n * fifty-first throws \"Maximum update depth exceeded\" (#185). A form that\n * re-renders its fields on every change (a `values` subscription, an owner\n * that keeps the values in state) re-rendered every multi-select with each\n * keystroke in ANY field.\n *\n * So the drawing is memoized, and what defeated a plain `memo` is taken out\n * of the comparison: the handlers, which final-form and the common select\n * rebuild on every render, are called through the latest props instead of\n * compared, and the no-options text is resolved here, where the common\n * select's per-render function for it is called.\n */\nfunction InternalSelect<T = OptionValue>(props: InternalSelectProps<T>) {\n const latest = useRef(props)\n latest.current = props\n const handlers = useMemo(\n () => ({\n onChange: (value: unknown) => latest.current.onChange(value),\n onFocus: (...args: unknown[]) =>\n (latest.current.onFocus as ((...args: unknown[]) => void) | undefined)?.(\n ...args,\n ),\n onBlur: (...args: unknown[]) =>\n (latest.current.onBlur as ((...args: unknown[]) => void) | undefined)?.(\n ...args,\n ),\n onInputChange: (value: string, reason?: string) =>\n latest.current.onInputChange?.(value, reason),\n onSearchInput: (value: string, reason?: string) =>\n latest.current.onSearchInput?.(value, reason),\n }),\n [],\n )\n const { noOptionsMessage, ...drawn } = props\n return (\n <MemoizedSelectView<T>\n {...drawn}\n {...handlers}\n noOptionsText={noOptionsMessage && noOptionsMessage()}\n />\n )\n}\n\n// The common Select's prop types are renderer-version specific; pass through.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DDFSelect = DDFSelectImport as React.ComponentType<any>\n\nexport function Select<T = OptionValue>(props: SelectProps<T>) {\n const {\n input,\n isRequired,\n isDisabled,\n isReadOnly,\n disabled,\n multiple,\n isMulti,\n isClearable,\n disableClearable,\n loadingMessage,\n loadingText,\n noOptionsMessage,\n noOptionsText,\n closeMenuOnSelect,\n ...rest\n } = useFieldApi(props)\n\n return (\n <DDFSelect\n {...input}\n isMulti={multiple || isMulti}\n required={isRequired}\n disabled={isDisabled || isReadOnly || disabled}\n disableClearable={!isClearable || disableClearable}\n loadingText={loadingMessage || loadingText}\n noOptionsMessage={noOptionsMessage || noOptionsText}\n closeMenuOnSelect={closeMenuOnSelect}\n {...rest}\n SelectComponent={InternalSelect}\n />\n )\n}\n\nexport default Select\n"],"names":["memo","useMemo","useRef","Autocomplete","CircularProgress","TextField","ArrowDropDownIcon","DDFSelectImport","parseInternalValue","useFieldApi","FormFieldGrid","buildFieldClear","validationError","getOptionLabel","option","options","Array","isArray","length","String","label","item","find","value","createValue","isMulti","map","InternalSelectView","helperText","validateOnMount","meta","isSearchable","description","placeholder","onInputChange","onSearchInput","isFetching","noOptionsText","hideSelectedOptions","closeMenuOnSelect","_closeMenuOnSelect","required","onChange","onFocus","onBlur","help","FormFieldGridProps","TextFieldProps","inputProps","textFieldInputProps","isClearable","isDisabled","clearable","loadingText","classNamePrefix","_classNamePrefix","rest","invalid","internalValue","clear","hasValue","undefined","locked","Boolean","onClear","filterSelectedOptions","disabled","disableClearable","popupIcon","size","color","fullWidth","renderInput","params","error","touched","warning","margin","slotProps","htmlInput","readOnly","_event","reason","multiple","loading","drawsTheSame","previous","next","keys","Set","Object","key","before","after","is","shallowEqual","a","b","left","right","every","MemoizedSelectView","InternalSelect","props","latest","current","handlers","args","noOptionsMessage","drawn","DDFSelect","Select","input","isRequired","isReadOnly","loadingMessage","SelectComponent"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;CAIC,GAED,SAASA,IAAI,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAE7C,SACEC,YAAY,EACZC,gBAAgB,EAChBC,SAAS,QACJ,gBAAe;AAEtB,OAAOC,uBAAuB,oCAAmC;AAEjE,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,cAAc;AACd,OAAOC,mBAAmBC,kBAAkB,QAAQ,mCAAkC;AAEtF,SAASC,WAAW,QAAQ,iCAA6B;AACzD,OAAOC,iBACLC,eAAe,QAEV,uBAAmB;AAE1B,SAAiCC,eAAe,QAAQ,wBAAoB;AAyC5E,0CAA0C,GAC1C,OAAO,SAASC,eACdC,MAAuC,EACvCC,OAA0B;IAE1B,IAAI,OAAOD,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,IAAI,AAACA,WAAuB,IAAI;QAC9B,OAAO;IACT;IAEA,IAAIE,M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AAY1D;QACrBgB,UAAUwE;QACV/C,UAAUf,cAAc+D,cAAchD;QACtCC,kBAAkB,CAACjB,eAAeiB;QAClCd,aAAa8D,kBAAkB9D;QAC/BuD,kBAAkBA,oBAAoBvE;QACtCE,mBAAmBA;OACfiB;QACJ4D,iBAAiBd;;AAGvB;AAEA,eAAeS,OAAM"}
|
package/src/lib/mapper/wizard.js
CHANGED
|
@@ -24,8 +24,10 @@ import { createElement as _createElement } from "react";
|
|
|
24
24
|
import { Button, Grid, Step, StepLabel, Stepper } from "@mui/material";
|
|
25
25
|
import { styled } from "@mui/material/styles";
|
|
26
26
|
import clsx from "clsx";
|
|
27
|
-
|
|
28
|
-
import
|
|
27
|
+
// The folder entry is the ESM build; the deep `wizard/select-next` file is
|
|
28
|
+
// CommonJS, and its default import is the whole `exports` object to a bundler
|
|
29
|
+
// that reads this package's output under Node's rules (AGL-3201).
|
|
30
|
+
import CommonWizard, { selectNext } from "@data-driven-forms/common/wizard";
|
|
29
31
|
import { FormSpy, WizardContext } from "../vendor/data-driven-forms.js";
|
|
30
32
|
/* -------------------------------- wizard nav ------------------------------ */ const NAV_PREFIX = 'WizardNav';
|
|
31
33
|
const navClasses = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/mapper/wizard.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Ported from `@data-driven-forms/mui-component-mapper` (Apache-2.0) and\n * updated for the current MUI APIs.\n */\n\nimport { Fragment, useContext } from 'react'\n\nimport {\n Button,\n Grid,\n type GridProps,\n Step,\n StepLabel,\n type StepLabelProps,\n type StepProps,\n Stepper,\n type StepperProps,\n} from '@mui/material'\nimport { styled } from '@mui/material/styles'\n\nimport clsx from 'clsx'\n\nimport CommonWizard from '@data-driven-forms/common/wizard'\nimport selectNext from '@data-driven-forms/common/wizard/select-next'\n\nimport {\n type FormOptions,\n FormSpy,\n WizardContext,\n} from '../vendor/data-driven-forms'\n\n\n/* -------------------------------- wizard nav ------------------------------ */\n\nconst NAV_PREFIX = 'WizardNav'\n\nconst navClasses = {\n stepper: `${NAV_PREFIX}-stepper`,\n}\n\nconst StyledStepper = styled(Stepper)(() => ({\n [`&.${navClasses.stepper}`]: {\n width: '100%',\n },\n}))\n\ninterface StepInfo {\n title?: string\n label?: string\n StepLabelProps?: StepLabelProps\n StepProps?: StepProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\ninterface WizardNavProps {\n StepperProps?: StepperProps\n stepsInfo: StepInfo[]\n activeStepIndex: number\n}\n\nconst WizardNav = ({\n StepperProps = {},\n stepsInfo,\n activeStepIndex,\n}: WizardNavProps) => (\n <StyledStepper\n {...StepperProps}\n className={clsx(navClasses.stepper, StepperProps.className)}\n activeStep={activeStepIndex}\n >\n {stepsInfo.map(({ title, label, StepLabelProps = {}, StepProps = {} }, idx) => (\n <Step {...StepProps} key={idx}>\n <StepLabel {...StepLabelProps}>{title || label}</StepLabel>\n </Step>\n ))}\n </StyledStepper>\n)\n\n/* ----------------------------- wizard buttons ----------------------------- */\n\nconst BUTTONS_PREFIX = 'WizardStepButtons'\n\nconst buttonClasses = {\n buttons: `${BUTTONS_PREFIX}-buttons`,\n button: `${BUTTONS_PREFIX}-button`,\n buttonsContainer: `${BUTTONS_PREFIX}-buttonsContainer`,\n}\n\nconst StyledButtonsGrid = styled(Grid)(() => ({\n [`& .${buttonClasses.buttons}`]: {\n display: 'flex',\n justifyContent: 'flex-end',\n },\n\n [`& .${buttonClasses.button}`]: {\n marginRight: 16,\n },\n\n [`&.${buttonClasses.buttonsContainer}`]: {\n marginTop: 36,\n },\n}))\n\ninterface NextButtonProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextStep?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext: (nextStep?: any) => void\n nextLabel: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getState: () => any\n handleSubmit: () => void\n submitLabel: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n}\n\nconst NextButton = ({\n nextStep,\n handleNext,\n nextLabel,\n getState,\n handleSubmit,\n submitLabel,\n conditionalSubmitFlag,\n}: NextButtonProps) => {\n const nextResult = nextStep ? selectNext(nextStep, getState) : nextStep\n const progressNext = nextResult !== conditionalSubmitFlag && nextStep\n const { valid, validating, submitting } = getState()\n\n return (\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!valid || validating || submitting}\n onClick={() => (progressNext ? handleNext(nextResult) : handleSubmit())}\n >\n {progressNext ? nextLabel : submitLabel}\n </Button>\n )\n}\n\ninterface ButtonLabels {\n cancel: string\n submit: string\n back: string\n next: string\n}\n\ninterface WizardStepButtonsProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n buttons?: React.ComponentType<any>\n disableBack: boolean\n handlePrev: () => void\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextStep?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext: (nextStep?: any) => void\n buttonLabels: ButtonLabels\n formOptions: FormOptions\n ButtonContainerProps?: GridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nconst WizardStepButtons = ({\n buttons: Buttons,\n ...props\n}: WizardStepButtonsProps) => {\n if (Buttons) {\n return <Buttons classes={buttonClasses} {...props} />\n }\n\n const {\n disableBack,\n handlePrev,\n nextStep,\n handleNext,\n buttonLabels: { cancel, submit, back, next },\n formOptions,\n ButtonContainerProps = {},\n conditionalSubmitFlag,\n } = props\n\n return (\n <StyledButtonsGrid\n container\n direction=\"row\"\n sx={{ justifyContent: 'space-evenly' }}\n {...ButtonContainerProps}\n className={clsx(\n buttonClasses.buttonsContainer,\n ButtonContainerProps.className,\n )}\n >\n <FormSpy\n subscription={{\n values: true,\n valid: true,\n validating: true,\n submitting: true,\n }}\n >\n {() => (\n <Fragment>\n <Grid size={{ md: 2, xs: 2 }}>\n <Button\n onClick={() =>\n formOptions.onCancel?.(formOptions.getState().values)\n }\n >\n {cancel}\n </Button>\n </Grid>\n <Grid size={{ md: 10, xs: 10 }} className={buttonClasses.buttons}>\n <Button\n disabled={disableBack}\n onClick={() => handlePrev()}\n className={buttonClasses.button}\n >\n {back}\n </Button>\n <NextButton\n {...formOptions}\n conditionalSubmitFlag={conditionalSubmitFlag}\n handleNext={handleNext}\n nextStep={nextStep}\n nextLabel={next}\n submitLabel={submit}\n />\n </Grid>\n </Fragment>\n )}\n </FormSpy>\n </StyledButtonsGrid>\n )\n}\n\n/* --------------------------------- wizard --------------------------------- */\n\nconst PREFIX = 'MuiWizard'\n\nconst classes = {\n wizardBody: `${PREFIX}-wizardBody`,\n}\n\nconst StyledWizard = styled(Grid)(() => ({\n [`& .${classes.wizardBody}`]: {\n padding: 24,\n margin: 0,\n },\n}))\n\ninterface WizardButtonLabels {\n next?: string\n submit?: string\n cancel?: string\n back?: string\n}\n\ninterface WizardInternalProps {\n buttonLabels?: WizardButtonLabels\n stepsInfo?: StepInfo[]\n ButtonContainerProps?: GridProps\n StepperProps?: StepperProps\n WizardBodyProps?: GridProps\n WizardProps?: GridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n}\n\nconst WizardInternal = ({\n buttonLabels = {},\n stepsInfo,\n ButtonContainerProps,\n StepperProps,\n WizardBodyProps = {},\n WizardProps,\n conditionalSubmitFlag,\n}: WizardInternalProps) => {\n const {\n formOptions,\n currentStep,\n handlePrev,\n onKeyDown,\n handleNext,\n activeStepIndex,\n prevSteps,\n } = useContext(WizardContext)\n\n const buttonLabelsFinal = {\n next: 'Continue',\n submit: 'Submit',\n cancel: 'Cancel',\n back: 'Back',\n ...buttonLabels,\n }\n\n return (\n <StyledWizard\n container\n {...WizardProps}\n onKeyDown={onKeyDown as React.KeyboardEventHandler<HTMLDivElement>}\n >\n {stepsInfo && (\n <WizardNav\n StepperProps={StepperProps}\n stepsInfo={stepsInfo}\n activeStepIndex={activeStepIndex}\n />\n )}\n <Grid\n container\n spacing={2}\n {...WizardBodyProps}\n className={clsx(classes.wizardBody, WizardBodyProps.className)}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {currentStep.fields.map((item: any) => formOptions.renderForm([item]))}\n <WizardStepButtons\n {...currentStep}\n formOptions={formOptions}\n buttonLabels={buttonLabelsFinal}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext={(nextStep: any) => handleNext(nextStep)}\n handlePrev={() => handlePrev()}\n disableBack={prevSteps.length === 0}\n conditionalSubmitFlag={conditionalSubmitFlag}\n ButtonContainerProps={ButtonContainerProps}\n />\n </Grid>\n </StyledWizard>\n )\n}\n\nexport interface WizardProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\n// The common Wizard's prop types are renderer-version specific; the schema\n// always provides `fields` at runtime.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst CommonWizardAny = CommonWizard as React.ComponentType<any>\n\nexport const Wizard = (props: WizardProps) => (\n <CommonWizardAny Wizard={WizardInternal} {...props} />\n)\n\nexport default Wizard\n"],"names":["Fragment","useContext","Button","Grid","Step","StepLabel","Stepper","styled","clsx","CommonWizard","selectNext","FormSpy","WizardContext","NAV_PREFIX","navClasses","stepper","StyledStepper","width","WizardNav","StepperProps","stepsInfo","activeStepIndex","className","activeStep","map","title","label","StepLabelProps","StepProps","idx","key","BUTTONS_PREFIX","buttonClasses","buttons","button","buttonsContainer","StyledButtonsGrid","display","justifyContent","marginRight","marginTop","NextButton","nextStep","handleNext","nextLabel","getState","handleSubmit","submitLabel","conditionalSubmitFlag","nextResult","progressNext","valid","validating","submitting","variant","color","disabled","onClick","WizardStepButtons","Buttons","props","classes","disableBack","handlePrev","buttonLabels","cancel","submit","back","next","formOptions","ButtonContainerProps","container","direction","sx","subscription","values","size","md","xs","onCancel","PREFIX","wizardBody","StyledWizard","padding","margin","WizardInternal","WizardBodyProps","WizardProps","currentStep","onKeyDown","prevSteps","buttonLabelsFinal","spacing","fields","item","renderForm","length","CommonWizardAny","Wizard"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;CAGC,GAED,SAASA,QAAQ,EAAEC,UAAU,QAAQ,QAAO;AAE5C,SACEC,MAAM,EACNC,IAAI,EAEJC,IAAI,EACJC,SAAS,EAGTC,OAAO,QAEF,gBAAe;AACtB,SAASC,MAAM,QAAQ,uBAAsB;AAE7C,OAAOC,UAAU,OAAM;AAEvB,OAAOC,kBAAkB,mCAAkC;AAC3D,OAAOC,gBAAgB,+CAA8C;AAErE,SAEEC,OAAO,EACPC,aAAa,QACR,iCAA6B;AAGpC,8EAA8E,GAE9E,MAAMC,aAAa;AAEnB,MAAMC,aAAa;IACjBC,SAAS,GAAGF,WAAW,QAAQ,CAAC;AAClC;AAEA,MAAMG,gBAAgBT,OAAOD,SAAS,IAAO,CAAA;QAC3C,CAAC,CAAC,EAAE,EAAEQ,WAAWC,OAAO,EAAE,CAAC,EAAE;YAC3BE,OAAO;QACT;IACF,CAAA;AAiBA,MAAMC,YAAY,CAAC,EACjBC,eAAe,CAAC,CAAC,EACjBC,SAAS,EACTC,eAAe,EACA,iBACf,KAACL,4BACKG;QACJG,WAAWd,KAAKM,WAAWC,OAAO,EAAEI,aAAaG,SAAS;QAC1DC,YAAYF;kBAEXD,UAAUI,GAAG,CAAC,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAEC,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AA;AAoBA,MAAMC,iBAAiB,CAAC,EACtBrB,eAAe,CAAC,CAAC,EACjB5C,SAAS,EACTkD,oBAAoB,EACpBnD,YAAY,EACZmE,kBAAkB,CAAC,CAAC,EACpBC,WAAW,EACXvC,qBAAqB,EACD;IACpB,MAAM,EACJqB,WAAW,EACXmB,WAAW,EACXzB,UAAU,EACV0B,SAAS,EACT9C,UAAU,EACVtB,eAAe,EACfqE,SAAS,EACV,GAAGzF,WAAWW;IAEf,MAAM+E,oBAAoB;QACxBvB,MAAM;QACNF,QAAQ;QACRD,QAAQ;QACRE,MAAM;OACHH;IAGL,qBACE,MAACkB;QACCX,SAAS;OACLgB;QACJE,WAAWA;;YAEVrE,2BACC,KAACF;gBACCC,cAAcA;gBACdC,WAAWA;gBACXC,iBAAiBA;;0BAGrB,MAAClB;gBACCoE,SAAS;gBACTqB,SAAS;eACLN;gBACJhE,WAAWd,KAAKqD,QAAQoB,UAAU,EAAEK,gBAAgBhE,SAAS;;oBAG5DkE,YAAYK,MAAM,CAACrE,GAAG,CAAC,CAACsE,OAAczB,YAAY0B,UAAU,CAAC;4BAACD;yBAAK;kCACpE,KAACpC,gCACK8B;wBACJnB,aAAaA;wBACbL,cAAc2B;wBACd,8DAA8D;wBAC9DhD,YAAY,CAACD,WAAkBC,WAAWD;wBAC1CqB,YAAY,IAAMA;wBAClBD,aAAa4B,UAAUM,MAAM,KAAK;wBAClChD,uBAAuBA;wBACvBsB,sBAAsBA;;;;;;AAKhC;AAOA,2EAA2E;AAC3E,uCAAuC;AACvC,8DAA8D;AAC9D,MAAM2B,kBAAkBxF;AAExB,OAAO,MAAMyF,SAAS,CAACtC,sBACrB,KAACqC;QAAgBC,QAAQb;OAAoBzB,QAC9C;AAED,eAAesC,OAAM"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx-forms/src/lib/mapper/wizard.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Ported from `@data-driven-forms/mui-component-mapper` (Apache-2.0) and\n * updated for the current MUI APIs.\n */\n\nimport { Fragment, useContext } from 'react'\n\nimport {\n Button,\n Grid,\n type GridProps,\n Step,\n StepLabel,\n type StepLabelProps,\n type StepProps,\n Stepper,\n type StepperProps,\n} from '@mui/material'\nimport { styled } from '@mui/material/styles'\n\nimport clsx from 'clsx'\n\n// The folder entry is the ESM build; the deep `wizard/select-next` file is\n// CommonJS, and its default import is the whole `exports` object to a bundler\n// that reads this package's output under Node's rules (AGL-3201).\nimport CommonWizard, { selectNext } from '@data-driven-forms/common/wizard'\n\nimport {\n type FormOptions,\n FormSpy,\n WizardContext,\n} from '../vendor/data-driven-forms'\n\n\n/* -------------------------------- wizard nav ------------------------------ */\n\nconst NAV_PREFIX = 'WizardNav'\n\nconst navClasses = {\n stepper: `${NAV_PREFIX}-stepper`,\n}\n\nconst StyledStepper = styled(Stepper)(() => ({\n [`&.${navClasses.stepper}`]: {\n width: '100%',\n },\n}))\n\ninterface StepInfo {\n title?: string\n label?: string\n StepLabelProps?: StepLabelProps\n StepProps?: StepProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\ninterface WizardNavProps {\n StepperProps?: StepperProps\n stepsInfo: StepInfo[]\n activeStepIndex: number\n}\n\nconst WizardNav = ({\n StepperProps = {},\n stepsInfo,\n activeStepIndex,\n}: WizardNavProps) => (\n <StyledStepper\n {...StepperProps}\n className={clsx(navClasses.stepper, StepperProps.className)}\n activeStep={activeStepIndex}\n >\n {stepsInfo.map(({ title, label, StepLabelProps = {}, StepProps = {} }, idx) => (\n <Step {...StepProps} key={idx}>\n <StepLabel {...StepLabelProps}>{title || label}</StepLabel>\n </Step>\n ))}\n </StyledStepper>\n)\n\n/* ----------------------------- wizard buttons ----------------------------- */\n\nconst BUTTONS_PREFIX = 'WizardStepButtons'\n\nconst buttonClasses = {\n buttons: `${BUTTONS_PREFIX}-buttons`,\n button: `${BUTTONS_PREFIX}-button`,\n buttonsContainer: `${BUTTONS_PREFIX}-buttonsContainer`,\n}\n\nconst StyledButtonsGrid = styled(Grid)(() => ({\n [`& .${buttonClasses.buttons}`]: {\n display: 'flex',\n justifyContent: 'flex-end',\n },\n\n [`& .${buttonClasses.button}`]: {\n marginRight: 16,\n },\n\n [`&.${buttonClasses.buttonsContainer}`]: {\n marginTop: 36,\n },\n}))\n\ninterface NextButtonProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextStep?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext: (nextStep?: any) => void\n nextLabel: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n getState: () => any\n handleSubmit: () => void\n submitLabel: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n}\n\nconst NextButton = ({\n nextStep,\n handleNext,\n nextLabel,\n getState,\n handleSubmit,\n submitLabel,\n conditionalSubmitFlag,\n}: NextButtonProps) => {\n const nextResult = nextStep ? selectNext(nextStep, getState) : nextStep\n const progressNext = nextResult !== conditionalSubmitFlag && nextStep\n const { valid, validating, submitting } = getState()\n\n return (\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!valid || validating || submitting}\n onClick={() => (progressNext ? handleNext(nextResult) : handleSubmit())}\n >\n {progressNext ? nextLabel : submitLabel}\n </Button>\n )\n}\n\ninterface ButtonLabels {\n cancel: string\n submit: string\n back: string\n next: string\n}\n\ninterface WizardStepButtonsProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n buttons?: React.ComponentType<any>\n disableBack: boolean\n handlePrev: () => void\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n nextStep?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext: (nextStep?: any) => void\n buttonLabels: ButtonLabels\n formOptions: FormOptions\n ButtonContainerProps?: GridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nconst WizardStepButtons = ({\n buttons: Buttons,\n ...props\n}: WizardStepButtonsProps) => {\n if (Buttons) {\n return <Buttons classes={buttonClasses} {...props} />\n }\n\n const {\n disableBack,\n handlePrev,\n nextStep,\n handleNext,\n buttonLabels: { cancel, submit, back, next },\n formOptions,\n ButtonContainerProps = {},\n conditionalSubmitFlag,\n } = props\n\n return (\n <StyledButtonsGrid\n container\n direction=\"row\"\n sx={{ justifyContent: 'space-evenly' }}\n {...ButtonContainerProps}\n className={clsx(\n buttonClasses.buttonsContainer,\n ButtonContainerProps.className,\n )}\n >\n <FormSpy\n subscription={{\n values: true,\n valid: true,\n validating: true,\n submitting: true,\n }}\n >\n {() => (\n <Fragment>\n <Grid size={{ md: 2, xs: 2 }}>\n <Button\n onClick={() =>\n formOptions.onCancel?.(formOptions.getState().values)\n }\n >\n {cancel}\n </Button>\n </Grid>\n <Grid size={{ md: 10, xs: 10 }} className={buttonClasses.buttons}>\n <Button\n disabled={disableBack}\n onClick={() => handlePrev()}\n className={buttonClasses.button}\n >\n {back}\n </Button>\n <NextButton\n {...formOptions}\n conditionalSubmitFlag={conditionalSubmitFlag}\n handleNext={handleNext}\n nextStep={nextStep}\n nextLabel={next}\n submitLabel={submit}\n />\n </Grid>\n </Fragment>\n )}\n </FormSpy>\n </StyledButtonsGrid>\n )\n}\n\n/* --------------------------------- wizard --------------------------------- */\n\nconst PREFIX = 'MuiWizard'\n\nconst classes = {\n wizardBody: `${PREFIX}-wizardBody`,\n}\n\nconst StyledWizard = styled(Grid)(() => ({\n [`& .${classes.wizardBody}`]: {\n padding: 24,\n margin: 0,\n },\n}))\n\ninterface WizardButtonLabels {\n next?: string\n submit?: string\n cancel?: string\n back?: string\n}\n\ninterface WizardInternalProps {\n buttonLabels?: WizardButtonLabels\n stepsInfo?: StepInfo[]\n ButtonContainerProps?: GridProps\n StepperProps?: StepperProps\n WizardBodyProps?: GridProps\n WizardProps?: GridProps\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n conditionalSubmitFlag?: any\n}\n\nconst WizardInternal = ({\n buttonLabels = {},\n stepsInfo,\n ButtonContainerProps,\n StepperProps,\n WizardBodyProps = {},\n WizardProps,\n conditionalSubmitFlag,\n}: WizardInternalProps) => {\n const {\n formOptions,\n currentStep,\n handlePrev,\n onKeyDown,\n handleNext,\n activeStepIndex,\n prevSteps,\n } = useContext(WizardContext)\n\n const buttonLabelsFinal = {\n next: 'Continue',\n submit: 'Submit',\n cancel: 'Cancel',\n back: 'Back',\n ...buttonLabels,\n }\n\n return (\n <StyledWizard\n container\n {...WizardProps}\n onKeyDown={onKeyDown as React.KeyboardEventHandler<HTMLDivElement>}\n >\n {stepsInfo && (\n <WizardNav\n StepperProps={StepperProps}\n stepsInfo={stepsInfo}\n activeStepIndex={activeStepIndex}\n />\n )}\n <Grid\n container\n spacing={2}\n {...WizardBodyProps}\n className={clsx(classes.wizardBody, WizardBodyProps.className)}\n >\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {currentStep.fields.map((item: any) => formOptions.renderForm([item]))}\n <WizardStepButtons\n {...currentStep}\n formOptions={formOptions}\n buttonLabels={buttonLabelsFinal}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleNext={(nextStep: any) => handleNext(nextStep)}\n handlePrev={() => handlePrev()}\n disableBack={prevSteps.length === 0}\n conditionalSubmitFlag={conditionalSubmitFlag}\n ButtonContainerProps={ButtonContainerProps}\n />\n </Grid>\n </StyledWizard>\n )\n}\n\nexport interface WizardProps {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\n// The common Wizard's prop types are renderer-version specific; the schema\n// always provides `fields` at runtime.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst CommonWizardAny = CommonWizard as React.ComponentType<any>\n\nexport const Wizard = (props: WizardProps) => (\n <CommonWizardAny Wizard={WizardInternal} {...props} />\n)\n\nexport default Wizard\n"],"names":["Fragment","useContext","Button","Grid","Step","StepLabel","Stepper","styled","clsx","CommonWizard","selectNext","FormSpy","WizardContext","NAV_PREFIX","navClasses","stepper","StyledStepper","width","WizardNav","StepperProps","stepsInfo","activeStepIndex","className","activeStep","map","title","label","StepLabelProps","StepProps","idx","key","BUTTONS_PREFIX","buttonClasses","buttons","button","buttonsContainer","StyledButtonsGrid","display","justifyContent","marginRight","marginTop","NextButton","nextStep","handleNext","nextLabel","getState","handleSubmit","submitLabel","conditionalSubmitFlag","nextResult","progressNext","valid","validating","submitting","variant","color","disabled","onClick","WizardStepButtons","Buttons","props","classes","disableBack","handlePrev","buttonLabels","cancel","submit","back","next","formOptions","ButtonContainerProps","container","direction","sx","subscription","values","size","md","xs","onCancel","PREFIX","wizardBody","StyledWizard","padding","margin","WizardInternal","WizardBodyProps","WizardProps","currentStep","onKeyDown","prevSteps","buttonLabelsFinal","spacing","fields","item","renderForm","length","CommonWizardAny","Wizard"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;CAGC,GAED,SAASA,QAAQ,EAAEC,UAAU,QAAQ,QAAO;AAE5C,SACEC,MAAM,EACNC,IAAI,EAEJC,IAAI,EACJC,SAAS,EAGTC,OAAO,QAEF,gBAAe;AACtB,SAASC,MAAM,QAAQ,uBAAsB;AAE7C,OAAOC,UAAU,OAAM;AAEvB,2EAA2E;AAC3E,8EAA8E;AAC9E,kEAAkE;AAClE,OAAOC,gBAAgBC,UAAU,QAAQ,mCAAkC;AAE3E,SAEEC,OAAO,EACPC,aAAa,QACR,iCAA6B;AAGpC,8EAA8E,GAE9E,MAAMC,aAAa;AAEnB,MAAMC,aAA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