dynamic-mui 2.0.26 → 2.2.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 +218 -37
- package/dist/AxisSharedComponents-BbsKw1BT.js +3 -0
- package/dist/AxisSharedComponents-xLtpOLH_.mjs +605 -0
- package/dist/ChartsAxis-CANvBdY9.mjs +47 -0
- package/dist/ChartsAxis-EZ7m_KrU.js +1 -0
- package/dist/ChartsGrid-BCRTvNTr.js +3 -0
- package/dist/ChartsGrid-C_HT7qpL.mjs +381 -0
- package/dist/ChartsWrapper-CM7EDyAK.js +5 -0
- package/dist/ChartsWrapper-CO5_Z6BD.mjs +1878 -0
- package/dist/ChartsXAxis-CPmuCRhq.mjs +487 -0
- package/dist/ChartsXAxis-DFFY1sPg.js +3 -0
- package/dist/ChartsYAxis-DLUMr9vG.mjs +392 -0
- package/dist/ChartsYAxis-fpevi1sP.js +1 -0
- package/dist/XmlShapeDeserializer-3yQdm0b0.mjs +237 -0
- package/dist/XmlShapeDeserializer-XKJAoqLc.js +1 -0
- package/dist/ai/client.d.ts +2 -0
- package/dist/ai/index.d.ts +4 -0
- package/dist/ai/mapping.d.ts +14 -0
- package/dist/ai/react/AIFill.d.ts +25 -0
- package/dist/ai/react/AIForm.d.ts +29 -0
- package/dist/ai/react/AIFormGenerator.d.ts +20 -0
- package/dist/ai/react/AISchemaReview.d.ts +18 -0
- package/dist/ai/react/AITextAssist.d.ts +35 -0
- package/dist/ai/react/AIVisionImport.d.ts +21 -0
- package/dist/ai/react/index.d.ts +6 -0
- package/dist/ai/types.d.ts +107 -0
- package/dist/clampAngle-BvZjnf53.mjs +11 -0
- package/dist/clampAngle-DpAsDoeT.js +1 -0
- package/dist/components/FormGenerator.d.ts +46 -1
- package/dist/components/controls/AddressField/addressfield.d.ts +2 -0
- package/dist/components/controls/Alert/alert.d.ts +3 -0
- package/dist/components/controls/AsyncAutocomplete/asyncautocomplete.d.ts +9 -0
- package/dist/components/controls/Button/button.d.ts +3 -0
- package/dist/components/controls/CascadeSelect/cascadeselect.d.ts +2 -0
- package/dist/components/controls/CheckBox/checkbox.d.ts +1 -1
- package/dist/components/controls/ChipSelect/chipselect.d.ts +3 -0
- package/dist/components/controls/ColorPicker/colorpicker.d.ts +3 -0
- package/dist/components/controls/Computed/computed.d.ts +7 -0
- package/dist/components/controls/ConsentField/consentfield.d.ts +3 -0
- package/dist/components/controls/CurrencyField/currencyfield.d.ts +2 -0
- package/dist/components/controls/DateRangePicker/daterangepicker.d.ts +3 -0
- package/dist/components/controls/EditableTable/editabletable.d.ts +2 -0
- package/dist/components/controls/FileUpload/fileupload.d.ts +3 -0
- package/dist/components/controls/FormWizard/formwizard.d.ts +2 -0
- package/dist/components/controls/GeoField/geofield.d.ts +6 -0
- package/dist/components/controls/IntlPhone/intlphone.d.ts +2 -0
- package/dist/components/controls/KeyValueField/keyvaluefield.d.ts +2 -0
- package/dist/components/controls/LocationField/locationfield.d.ts +1 -1
- package/dist/components/controls/MarkdownEditor/markdowneditor.d.ts +3 -0
- package/dist/components/controls/MatrixField/matrixfield.d.ts +3 -0
- package/dist/components/controls/MultiTextbox/multitextbox.d.ts +1 -1
- package/dist/components/controls/NpsScale/npsscale.d.ts +3 -0
- package/dist/components/controls/NumberField/numberfield.d.ts +1 -1
- package/dist/components/controls/NumberStepper/numberstepper.d.ts +2 -0
- package/dist/components/controls/OtpField/otpfield.d.ts +2 -0
- package/dist/components/controls/PasswordField/passwordfield.d.ts +2 -0
- package/dist/components/controls/PhoneField/phonefield.d.ts +2 -0
- package/dist/components/controls/Radio/radio.d.ts +1 -1
- package/dist/components/controls/Rating/rating.d.ts +3 -0
- package/dist/components/controls/RichTextEditor/richtexteditor.d.ts +3 -0
- package/dist/components/controls/Select/select.d.ts +1 -1
- package/dist/components/controls/Slider/slider.d.ts +3 -0
- package/dist/components/controls/SummaryField/summaryfield.d.ts +7 -0
- package/dist/components/controls/Switch/switch.d.ts +1 -1
- package/dist/components/controls/TagsInput/tagsinput.d.ts +3 -0
- package/dist/components/controls/TextField/textfield.d.ts +1 -1
- package/dist/components/controls/ToggleButtons/togglebuttons.d.ts +3 -0
- package/dist/components/controls/index.d.ts +60 -0
- package/dist/createSelector-B-9FwV16.mjs +430 -0
- package/dist/createSelector-f0oqn8Lr.js +7 -0
- package/dist/date-utils-CFUUt6NL.js +4 -0
- package/dist/date-utils-pGzaKb0p.mjs +477 -0
- package/dist/dynamic-mui.cjs.js +1 -1
- package/dist/dynamic-mui.es.js +19 -6
- package/dist/index--8Zky9Oh.js +299 -0
- package/dist/index-6WTs1Xy_.js +1 -0
- package/dist/index-B1R1akM2.js +1 -0
- package/dist/index-BW8_rRff.js +7 -0
- package/dist/index-BXFVK_GX.js +1 -0
- package/dist/index-B_KNUTjy.js +1 -0
- package/dist/index-BhaKvHkU.mjs +62051 -0
- package/dist/index-Bif92ima.js +1 -0
- package/dist/index-BnZOu8CL.js +1 -0
- package/dist/index-CDxpgRlR.mjs +7 -0
- package/dist/index-CThMfvtJ.mjs +2555 -0
- package/dist/index-CVqLvm8B.js +1 -0
- package/dist/index-CodJBIn6.mjs +1665 -0
- package/dist/index-Cr6Wp_S-.mjs +3141 -0
- package/dist/index-CslPwsrf.mjs +4 -0
- package/dist/index-CuV0MQzZ.mjs +1173 -0
- package/dist/{index-BGfWFaIb.mjs → index-DA0XouZs.mjs} +16 -16
- package/dist/index-DKS5Sz9e.js +14 -0
- package/dist/index-DSkYYZuW.mjs +4 -0
- package/dist/index-DU78_FiA.js +1 -0
- package/dist/index-D_mYhgJ0.js +10 -0
- package/dist/index-DcWfyXJp.mjs +92 -0
- package/dist/index-Dlimbnxj.mjs +2965 -0
- package/dist/index-MllWgTJ5.mjs +9372 -0
- package/dist/index-in5z9hUb.js +133 -0
- package/dist/index-qUW7FnZ-.mjs +20540 -0
- package/dist/index.browser-BSu11T_q.mjs +363 -0
- package/dist/index.browser-By7-GABP.js +4 -0
- package/dist/index.d.ts +4 -1
- package/dist/isDeepEqual-BHfPvf9U.mjs +393 -0
- package/dist/isDeepEqual-CqxZGVRk.js +1 -0
- package/dist/loadCognitoIdentity-DtYTy-DW.js +1 -0
- package/dist/loadCognitoIdentity-DzdR91GB.mjs +872 -0
- package/dist/loadSts-Cic6UToN.mjs +593 -0
- package/dist/loadSts-csbFP6zX.js +1 -0
- package/dist/noAuth-B8ui2kBg.mjs +71 -0
- package/dist/noAuth-JPA2o4dt.js +1 -0
- package/dist/playground/AIContext.d.ts +18 -0
- package/dist/playground/AIPanel.d.ts +10 -0
- package/dist/playground/DemoGallery.d.ts +6 -0
- package/dist/playground/Sidebar.d.ts +9 -1
- package/dist/playground/demoForms.d.ts +3 -0
- package/dist/playground/demoRecipes.d.ts +15 -0
- package/dist/playground/demoVariants.d.ts +11 -0
- package/dist/schema.d.ts +404 -0
- package/dist/theme/theme.d.ts +5 -0
- package/dist/types.d.ts +97 -10
- package/dist/useAxis-DSbfEtO7.js +3 -0
- package/dist/useAxis-SiNBMMWq.mjs +3010 -0
- package/dist/useChartContainerProps-Bl3hO-r1.mjs +5418 -0
- package/dist/useChartContainerProps-C_C_PZoi.js +12 -0
- package/dist/useItemHighlightedGetter-9CIwqsGj.js +1 -0
- package/dist/useItemHighlightedGetter-CTISrNdV.mjs +88 -0
- package/dist/util/helper.d.ts +2 -30
- package/dist/util/premiumStyles.d.ts +27 -0
- package/dist/util/rules.d.ts +35 -0
- package/package.json +2 -2
- package/dist/index-BHROoqH4.js +0 -1
- package/dist/index-S6BQaF_5.js +0 -465
- package/dist/index-Wtsz8Yiv.mjs +0 -102315
- package/dist/loadCognitoIdentity-CiUaDv6q.mjs +0 -935
- package/dist/loadCognitoIdentity-DN_MCNUl.js +0 -1
package/README.md
CHANGED
|
@@ -1,67 +1,248 @@
|
|
|
1
1
|
# dynamic-mui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Build rich, dynamic forms in React from a JSON schema — powered by Material UI.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **New Documentation Mode**: Integrated documentation sidebar with component details.
|
|
10
|
-
- **Advanced Validation**: Mandatory field validation with visual indicators (`*` and red error states).
|
|
11
|
-
- **Rich Component Library**: Includes TextField, Select, Date/Time Pickers, Checkbox, Radio, Switch, Signature, and more.
|
|
12
|
-
- **JSON Editing**: Edit form schema directly or use the visual builder.
|
|
13
|
-
- **Data Preview**: View current form data in real-time.
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
5
|
+
Render complex, reactive forms without writing form code. Fields can show/hide,
|
|
6
|
+
enable/disable, become required, compute their value, and drive each other's
|
|
7
|
+
options — all declaratively from data. Comes with 45+ controls, a typed schema
|
|
8
|
+
helper, an imperative API, i18n, and an optional visual builder / AI module.
|
|
16
9
|
|
|
17
10
|
```bash
|
|
11
|
+
npm install dynamic-mui
|
|
12
|
+
# peer dependencies (if you don't already have them)
|
|
18
13
|
npm install @mui/material @emotion/react @emotion/styled
|
|
19
|
-
npm install dynamic-mui --save
|
|
20
14
|
```
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
23
19
|
|
|
24
20
|
```tsx
|
|
25
|
-
import { FormGenerator } from 'dynamic-mui';
|
|
21
|
+
import { FormGenerator, FormData } from 'dynamic-mui';
|
|
26
22
|
|
|
27
|
-
const
|
|
23
|
+
const schema = [
|
|
28
24
|
{
|
|
29
25
|
type: 'textfield',
|
|
26
|
+
props: { id: 'name', MuiAttributes: { label: 'Full name', fullWidth: true } },
|
|
27
|
+
rules: { validation: [{ rule: 'mandatory', message: 'Name is required' }] },
|
|
28
|
+
layout: { row: 1, xs: 12, md: 6 },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'select',
|
|
30
32
|
props: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
rules: {
|
|
35
|
-
validation: [{ rule: 'mandatory', message: 'Name is required' }]
|
|
36
|
-
}
|
|
33
|
+
id: 'role',
|
|
34
|
+
options: [{ value: 'dev', label: 'Developer' }, { value: 'design', label: 'Designer' }],
|
|
35
|
+
MuiBoxAttributes: { label: 'Role' },
|
|
37
36
|
},
|
|
38
|
-
layout: { row: 1, xs: 12, md: 6 }
|
|
39
|
-
}
|
|
37
|
+
layout: { row: 1, xs: 12, md: 6 },
|
|
38
|
+
},
|
|
40
39
|
];
|
|
41
40
|
|
|
42
|
-
export default function
|
|
43
|
-
const handleSubmit = (data) => {
|
|
44
|
-
console.log('Form Data:', data);
|
|
45
|
-
};
|
|
46
|
-
|
|
41
|
+
export default function MyForm() {
|
|
47
42
|
return (
|
|
48
43
|
<FormGenerator
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
guid="my-form"
|
|
45
|
+
data={schema}
|
|
46
|
+
onSubmit={(values, errors) => {
|
|
47
|
+
if (errors.length === 0) console.log(FormData('my-form'));
|
|
48
|
+
}}
|
|
51
49
|
/>
|
|
52
50
|
);
|
|
53
51
|
}
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
Every field is an object of `{ type, props, layout, rules?, ...engine }`.
|
|
55
|
+
`layout` uses MUI Grid units (`row`, `xs`, `sm`, `md`, `lg`).
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Reading & writing form data
|
|
60
|
+
|
|
61
|
+
Data lives in a store keyed by the form's `guid`:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { FormData, ClearFormData, useForm } from 'dynamic-mui';
|
|
65
|
+
|
|
66
|
+
FormData('my-form'); // { name: 'Ada', role: 'dev' }
|
|
67
|
+
ClearFormData('my-form'); // reset one form (or all forms if called with no guid)
|
|
68
|
+
|
|
69
|
+
const values = useForm('my-form'); // reactive hook inside a component
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Prefill a form with `patch`:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<FormGenerator guid="my-form" data={schema} patch={{ name: 'Ada', role: 'dev' }} />
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Conditional fields, subforms, computed values, and `requiredWhen` all evaluate
|
|
79
|
+
correctly from the **initial** `patch` — not just after the first edit.
|
|
80
|
+
|
|
81
|
+
### Imperative API (`apiRef`)
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useRef } from 'react';
|
|
85
|
+
import { FormGenerator, FormApi } from 'dynamic-mui';
|
|
86
|
+
|
|
87
|
+
const api = useRef<FormApi>(null);
|
|
88
|
+
|
|
89
|
+
<FormGenerator guid="my-form" data={schema} apiRef={api} />;
|
|
90
|
+
|
|
91
|
+
api.current?.getValues(); // current values
|
|
92
|
+
api.current?.setValues({ ... }); // patch values in
|
|
93
|
+
api.current?.validate(); // boolean — runs validation, shows errors
|
|
94
|
+
api.current?.getErrors(); // array of { id, rule, message }
|
|
95
|
+
api.current?.reset(); // clear values
|
|
96
|
+
api.current?.submit(); // trigger the submit flow
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Dynamic rule engine
|
|
102
|
+
|
|
103
|
+
Add these keys to any field to make the form reactive. All conditions run
|
|
104
|
+
against the live form values.
|
|
105
|
+
|
|
106
|
+
| Key | What it does |
|
|
107
|
+
| ------------- | --------------------------------------------------------- |
|
|
108
|
+
| `visibleWhen` | Show the field only when a condition holds |
|
|
109
|
+
| `disabledWhen`| Disable the field when a condition holds |
|
|
110
|
+
| `requiredWhen`| Make the field required when a condition holds |
|
|
111
|
+
| `formula` | Compute the field's value from other fields |
|
|
112
|
+
| `dependsOn` + `optionsMap` | Swap a field's options based on another field |
|
|
113
|
+
| `subforms` | Reveal a group of fields for a matching parent value |
|
|
114
|
+
|
|
115
|
+
A condition is `{ field, op, value }` with operators `eq`, `neq`, `gt`, `gte`,
|
|
116
|
+
`lt`, `lte`, `in`, `nin`, `contains`, `startsWith`, `endsWith`, `empty`,
|
|
117
|
+
`notEmpty`, `truthy`, `falsy`, plus `all` / `any` / `none` groups.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
// Show + require "reason" only when status is "other"
|
|
121
|
+
{
|
|
122
|
+
type: 'textfield',
|
|
123
|
+
props: { id: 'reason', MuiAttributes: { label: 'Reason' } },
|
|
124
|
+
visibleWhen: { field: 'status', op: 'eq', value: 'other' },
|
|
125
|
+
requiredWhen: { field: 'status', op: 'eq', value: 'other' },
|
|
126
|
+
requiredMessage: 'Please tell us why',
|
|
127
|
+
layout: { row: 2, xs: 12 },
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Live total = qty * price
|
|
131
|
+
{
|
|
132
|
+
type: 'computed',
|
|
133
|
+
props: { id: 'total', format: '0,0.00', MuiAttributes: { label: 'Total' } },
|
|
134
|
+
formula: 'qty * price',
|
|
135
|
+
layout: { row: 3, xs: 12 },
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// State options depend on the selected country (one control, not many)
|
|
139
|
+
{
|
|
140
|
+
type: 'select',
|
|
141
|
+
props: { id: 'state', MuiBoxAttributes: { label: 'State' } },
|
|
142
|
+
dependsOn: 'country',
|
|
143
|
+
optionsMap: {
|
|
144
|
+
us: [{ value: 'ca', label: 'California' }],
|
|
145
|
+
in: [{ value: 'ka', label: 'Karnataka' }],
|
|
146
|
+
},
|
|
147
|
+
layout: { row: 4, xs: 12 },
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`formula` supports `+ - * / %`, parentheses, unary minus, and
|
|
152
|
+
`SUM/AVG/MIN/MAX/ROUND/ABS/FLOOR/CEIL`.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Validation
|
|
157
|
+
|
|
158
|
+
Per-field rules live under `rules.validation`:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
rules: { validation: [{ rule: 'mandatory', message: 'Required' }] }
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Cross-field validators compare against another field:
|
|
165
|
+
`equalsField`, `notEqualsField`, `gtField`, `gteField`, `ltField`, `lteField`.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
// "confirm" must equal "password"
|
|
169
|
+
rules: { validation: [{ rule: 'equalsField', field: 'password', message: 'Passwords must match' }] }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Turn on an accessible summary and auto-focus of the first error with
|
|
173
|
+
`validationSummary`. Hidden (`visibleWhen`) fields are excluded from validation.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Typed schema (`defineForm`)
|
|
178
|
+
|
|
179
|
+
Get full TypeScript autocompletion and compile-time checks for your schema:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { defineForm, FormGenerator } from 'dynamic-mui';
|
|
183
|
+
|
|
184
|
+
const schema = defineForm([
|
|
185
|
+
{ type: 'textfield', props: { id: 'email', MuiAttributes: { label: 'Email' } }, layout: { row: 1, xs: 12 } },
|
|
186
|
+
]);
|
|
187
|
+
|
|
188
|
+
<FormGenerator guid="typed" data={schema} />;
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Internationalisation
|
|
57
194
|
|
|
58
|
-
|
|
195
|
+
```tsx
|
|
196
|
+
<FormGenerator
|
|
197
|
+
guid="fr"
|
|
198
|
+
data={schema}
|
|
199
|
+
messages={{ required: 'Champ obligatoire', errorSummary: '{n} champ(s) à corriger' }}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Controls
|
|
206
|
+
|
|
207
|
+
Text & numbers · password · OTP · phone / international phone · currency ·
|
|
208
|
+
select · async autocomplete · autocomplete · cascade select · chip select ·
|
|
209
|
+
radio · checkbox · switch · toggle buttons · slider · rating · NPS · stepper ·
|
|
210
|
+
date / time / date-time / date-range pickers · file upload · signature ·
|
|
211
|
+
color picker · markdown & rich-text editors · tags · key-value · matrix ·
|
|
212
|
+
editable & data tables · line items · address · geo / location · consent ·
|
|
213
|
+
alert · divider · typography · charts (bar / line / pie / mixed), and more.
|
|
214
|
+
|
|
215
|
+
Each control is configured through `props` (its `MuiAttributes` /
|
|
216
|
+
`MuiBoxAttributes` map straight onto the underlying MUI component).
|
|
217
|
+
|
|
218
|
+
### Theming
|
|
219
|
+
|
|
220
|
+
Controls render under **your** MUI theme. Date/time pickers automatically match
|
|
221
|
+
the size and variant of your text fields, so a picker lines up with the fields
|
|
222
|
+
beside it.
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## AI module (optional)
|
|
227
|
+
|
|
228
|
+
`dynamic-mui/ai` provides AI-assisted building blocks (generate a form from a
|
|
229
|
+
prompt, autofill, text assist, schema review) that talk to **your** proxy/relay
|
|
230
|
+
so your provider key stays server-side. See [`examples/`](./examples) for a
|
|
231
|
+
ready-to-deploy proxy (including an AWS Lambda BYOK relay).
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Playground
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm install
|
|
239
|
+
npm run dev # visual builder + live demo gallery
|
|
240
|
+
```
|
|
59
241
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
3. Open `http://localhost:5173` (or the port shown in terminal).
|
|
242
|
+
Build forms visually, browse every control in multiple configurations, explore
|
|
243
|
+
real-world example forms, view the generated JSON, and copy it into your app.
|
|
63
244
|
|
|
64
|
-
|
|
245
|
+
---
|
|
65
246
|
|
|
66
247
|
## License
|
|
67
248
|
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const q=require("react"),P=require("./useAxis-DSbfEtO7.js"),b=require("./index--8Zky9Oh.js"),j=require("./clampAngle-DpAsDoeT.js");function J(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const O=J(q);function F(){const[e,t]=O.useState(!1);return O.useEffect(()=>{t(!0)},[]),e}function V(e){return typeof e=="number"&&!Number.isFinite(e)}function Q(e,t){return Math.abs(t.getFullYear()-e.getFullYear())}function v(e,t){return Math.abs(t.getFullYear()*12+t.getMonth()-12*e.getFullYear()-e.getMonth())}function C(e,t){return Math.abs(t.getTime()-e.getTime())/(1e3*60*60*24)}function K(e,t){return Math.abs(t.getTime()-e.getTime())/(1e3*60*60)}const tt={years:{getTickNumber:Q,isTick:(e,t)=>t.getFullYear()!==e.getFullYear(),format:e=>e.getFullYear().toString()},quarterly:{getTickNumber:(e,t)=>Math.floor(v(e,t)/3),isTick:(e,t)=>t.getMonth()!==e.getMonth()&&t.getMonth()%3===0,format:new Intl.DateTimeFormat("default",{month:"short"}).format},months:{getTickNumber:v,isTick:(e,t)=>t.getMonth()!==e.getMonth(),format:new Intl.DateTimeFormat("default",{month:"short"}).format},biweekly:{getTickNumber:(e,t)=>C(e,t)/14,isTick:(e,t)=>(t.getDay()<e.getDay()||C(t,e)>7)&&Math.floor(t.getDate()/7)%2===1,format:new Intl.DateTimeFormat("default",{day:"numeric"}).format},weeks:{getTickNumber:(e,t)=>C(e,t)/7,isTick:(e,t)=>t.getDay()<e.getDay()||C(t,e)>=7,format:new Intl.DateTimeFormat("default",{day:"numeric"}).format},days:{getTickNumber:C,isTick:(e,t)=>t.getDate()!==e.getDate(),format:new Intl.DateTimeFormat("default",{day:"numeric"}).format},hours:{getTickNumber:K,isTick:(e,t)=>t.getHours()!==e.getHours(),format:new Intl.DateTimeFormat("default",{hour:"2-digit",minute:"2-digit"}).format}},A={start:0,extremities:0,end:1,middle:.5};function S(e,t,n){return e(t)-(e.step()-e.bandwidth())/2+A[n]*e.step()}function et(e,t,n){const s=Math.abs(t[1]-t[0]),i=Math.ceil(e.length/(s/n));return Number.isNaN(i)||i<=1?e:e.filter((o,c)=>c%i===0)}function nt(e,t,n,s,i){if(n.length===0)return[];const o=s.range()[0]>s.range()[1],c=e.findIndex(l=>i(S(s,l,o?"start":"end"))),u=e.findLastIndex(l=>i(S(s,l,o?"end":"start"))),r=e[0],a=e[e.length-1];if(!(r instanceof Date)||!(a instanceof Date))return[];let d=0;for(let l=0;l<n.length;l+=1)if(n[l].getTickNumber(r,a)!==0){d=l;break}let g=d;for(let l=d;l<n.length;l+=1){if(l===n.length-1){g=l;break}const x=n[l].getTickNumber(r,a),f=n[l+1].getTickNumber(r,a);if(f>t||t/x<f/t){g=l;break}}const m=[];for(let l=Math.max(1,c);l<=u;l+=1)for(let x=d;x<=g;x+=1){const f=e[l-1],k=e[l];if(f instanceof Date&&k instanceof Date&&n[x].isTick(f,k)){m.push({index:l,formatter:n[x].format});break}}return m}function it(e){const{scale:t,tickNumber:n,valueFormatter:s,tickInterval:i,tickPlacement:o,tickLabelPlacement:c,tickSpacing:u,isInside:r,ordinalTimeTicks:a}=e;if(a!==void 0&&P.isDateData(t.domain())&&P.isOrdinalScale(t)){const f=t.domain();if(f.length===0||f.length===1)return[];const k="middle";return nt(f,n,a.map(p=>typeof p=="string"?tt[p]:p),t,r).map(({index:p,formatter:I})=>{const M=f[p],T=I(M);return{value:M,formattedValue:T,offset:S(t,M,k),labelOffset:0}})}const d=o??"extremities";if(P.isOrdinalScale(t)){const f=t.domain(),k=c??"middle";let h=f;if(typeof i=="object"&&i!=null?h=i:(typeof i=="function"&&(h=h.filter(i)),u!==void 0&&u>0&&(h=et(h,t.range(),u))),h.length===0)return[];if(t.bandwidth()>0){const p=t.range()[0]>t.range()[1],I=h.findIndex(T=>r(S(t,T,p?"start":"end"))),M=h.findLastIndex(T=>r(S(t,T,p?"end":"start")));return[...h.slice(I,M+1).map(T=>{const $=`${T}`;return{value:T,formattedValue:s?.(T,{location:"tick",scale:t,tickNumber:n,defaultTickLabel:$})??$,offset:S(t,T,d),labelOffset:k==="tick"?0:t.step()*(A[k]-A[d])}}),...d==="extremities"&&M===f.length-1&&r(t.range()[1])?[{formattedValue:void 0,offset:t.range()[1],labelOffset:0}]:[]]}return h.map(p=>{const I=`${p}`;return{value:p,formattedValue:s?.(p,{location:"tick",scale:t,tickNumber:n,defaultTickLabel:I})??I,offset:t(p),labelOffset:0}})}if(t.domain().some(V))return[];const m=c,l=typeof i=="object"?i:rt(t,n),x=[];for(let f=0;f<l.length;f+=1){const k=l[f],h=t(k);if(r(h)){const p=t.tickFormat(n)(k);x.push({value:k,formattedValue:s?.(k,{location:"tick",scale:t,tickNumber:n,defaultTickLabel:p})??p,offset:h,labelOffset:m==="middle"?t(l[f-1]??0)-(h+t(l[f-1]??0))/2:0})}}return x}function rt(e,t){const n=e.domain();return n[0]===n[1]?[n[0]]:e.ticks(t)}function st(e){const{scale:t,tickNumber:n,valueFormatter:s,tickInterval:i,tickPlacement:o="extremities",tickLabelPlacement:c,tickSpacing:u,direction:r,ordinalTimeTicks:a}=e,{instance:d}=P.useChartContext(),g=r==="x"?d.isXInside:d.isYInside;return O.useMemo(()=>it({scale:t,tickNumber:n,tickPlacement:o,tickInterval:i,tickLabelPlacement:c,tickSpacing:u,valueFormatter:s,isInside:g,ordinalTimeTicks:a}),[t,n,o,i,c,u,s,g,a])}const B=typeof window<"u"&&"Intl"in window&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;function ot(e){return e.length}function at(e){const t=B.segment(e);let n=0;for(const s of t)n+=1;return n}const ct=B?at:ot;function lt(e){return e*(Math.PI/180)}const z=typeof window<"u"&&"Intl"in window&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null;function ut(e,t){return e.slice(0,t)}function dt(e,t){const n=z.segment(e);let s="",i=0;for(const o of n)if(s+=o.segment,i+=1,i>=t)break;return s}const ft=z?dt:ut,R="…";function gt(e,t){const{width:n,height:s,measureText:i}=t,o=lt(t.angle),c=i(e),u=Math.abs(c.width*Math.cos(o))+Math.abs(c.height*Math.sin(o)),r=Math.abs(c.width*Math.sin(o))+Math.abs(c.height*Math.cos(o));return u<=n&&r<=s}function mt(e,t){if(t(e))return e;let n=e,s=1,i=1/2;const o=ct(e);let c=o,u=o,r=null;do{if(u=c,c=Math.floor(o*i),c===0)break;n=ft(e,c).trim();const a=t(n+R);s+=1,a?(r=n,i+=1/2**s):i-=1/2**s}while(Math.abs(c-u)!==1);return r?r+R:""}function H(){return typeof window>"u"}const w=new Map,Y=2e3,ht=new Set(["minWidth","maxWidth","width","minHeight","maxHeight","height","top","left","fontSize","padding","margin","paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom"]);function L(e,t){return ht.has(e)&&t===+t?`${t}px`:t}const pt=/([A-Z])/g;function E(e){return String(e).replace(pt,t=>`-${t.toLowerCase()}`)}function U(e){let t="";for(const n in e)if(Object.hasOwn(e,n)){const s=n,i=e[s];if(i===void 0)continue;t+=`${E(s)}:${L(s,i)};`}return t}const G=(e,t={})=>{if(e==null||H())return{width:0,height:0};const n=String(e),s=U(t),i=`${n}-${s}`,o=w.get(i);if(o)return o;try{const c=X(),u=document.createElementNS("http://www.w3.org/2000/svg","text");Object.keys(t).map(a=>(u.style[E(a)]=L(a,t[a]),a)),u.textContent=n,c.replaceChildren(u);const r=W(u);return w.set(i,r),w.size+1>Y&&w.clear(),process.env.NODE_ENV==="test"&&c.replaceChildren(),r}catch{return{width:0,height:0}}};function bt(e,t={}){if(H())return new Map(Array.from(e).map(r=>[r,{width:0,height:0}]));const n=new Map,s=[],i=U(t);for(const r of e){const a=`${r}-${i}`,d=w.get(a);d?n.set(r,d):s.push(r)}const o=X(),c=b._extends({},t);Object.keys(c).map(r=>(o.style[E(r)]=L(r,c[r]),r));const u=[];for(const r of s){const a=document.createElementNS("http://www.w3.org/2000/svg","text");a.textContent=`${r}`,u.push(a)}o.replaceChildren(...u);for(let r=0;r<s.length;r+=1){const a=s[r],d=o.children[r],g=W(d),m=`${a}-${i}`;w.set(m,g),n.set(a,g)}return w.size+1>Y&&w.clear(),process.env.NODE_ENV==="test"&&o.replaceChildren(),n}function W(e){try{const t=e.getBBox();return{width:t.width,height:t.height}}catch{const t=e.getBoundingClientRect();return{width:t.width,height:t.height}}}let y=null;function X(){return y===null&&(y=document.createElementNS("http://www.w3.org/2000/svg","svg"),y.setAttribute("aria-hidden","true"),y.style.position="absolute",y.style.top="-20000px",y.style.left="0",y.style.padding="0",y.style.margin="0",y.style.border="none",y.style.pointerEvents="none",y.style.visibility="hidden",y.style.contain="strict",document.body.appendChild(y)),y}function xt(e){return b.generateUtilityClass("MuiChartsAxis",e)}const N=b.generateUtilityClasses("MuiChartsAxis",["root","line","tickContainer","tick","tickLabel","label","directionX","directionY","top","bottom","left","right","id"]);function kt({style:e,needsComputation:t,text:n}){return n.split(`
|
|
2
|
+
`).map(s=>b._extends({text:s},t?G(s,e):{width:0,height:0}))}const yt=["x","y","style","text","ownerState"],Tt=["angle","textAnchor","dominantBaseline"];function Z(e){const{x:t,y:n,style:s,text:i}=e,o=b._objectWithoutPropertiesLoose(e,yt),c=s??{},{angle:u,textAnchor:r,dominantBaseline:a}=c,d=b._objectWithoutPropertiesLoose(c,Tt),g=F(),m=O.useMemo(()=>kt({style:d,needsComputation:g&&i.includes(`
|
|
3
|
+
`),text:i}),[d,i,g]);let l;switch(a){case"hanging":case"text-before-edge":l=0;break;case"central":l=(m.length-1)/2*-m[0].height;break;default:l=(m.length-1)*-m[0].height;break}return b.jsxRuntimeExports.jsx("text",b._extends({},o,{transform:u?`rotate(${u}, ${t}, ${n})`:void 0,x:t,y:n,textAnchor:r,dominantBaseline:a,style:d,children:m.map((x,f)=>b.jsxRuntimeExports.jsx("tspan",{x:t,dy:`${f===0?l:m[0].height}px`,dominantBaseline:a,children:x.text},f))}))}process.env.NODE_ENV!=="production"&&(Z.propTypes={lineHeight:b.PropTypes.number,needsComputation:b.PropTypes.bool,ownerState:b.PropTypes.any,style:b.PropTypes.object,text:b.PropTypes.string.isRequired});function wt(e){const t=j.clampAngle(e);return t<=30||t>=330||t<=210&&t>=150?"middle":t<=180?"end":"start"}function It(e){const t=j.clampAngle(e);return t<=30||t>=330?"hanging":t<=210&&t>=150?"auto":"central"}function Mt(e){switch(e){case"start":return"end";case"end":return"start";default:return e}}const D={start:0,extremities:0,end:1,middle:.5,tick:0};function St(e){const{scale:t,tickInterval:n,tickLabelPlacement:s="middle",tickPlacement:i="extremities",groups:o}=e;return O.useMemo(()=>{const c=t.domain(),u=typeof n=="function"&&c.filter(n)||typeof n=="object"&&n||c;if(t.bandwidth()>0){const r=_(u,o,i,s,t);return r[0]&&(r[0].ignoreTick=!0),[{formattedValue:void 0,offset:t.range()[0],labelOffset:0,groupIndex:o.length-1},...r,{formattedValue:void 0,offset:t.range()[1],labelOffset:0,groupIndex:o.length-1}]}return _(u,o,i,s,t)},[t,n,o,i,s])}function _(e,t,n,s,i){const o=[],c=new Map;let u=0;for(let r=0;r<t.length;r+=1)for(let a=0;a<e.length;a+=1){const d=e[a],g=t[r].getValue(d,a),m=o[o.length-1];if(m?.value!==g||m?.groupIndex!==r){u=1;const x=P.isOrdinalScale(i)?i(d)-(i.step()-i.bandwidth())/2+D[n]*i.step():i(d),f=i.step()*u*(D[s]-D[n]);o.push({value:g,formattedValue:`${g}`,offset:x,groupIndex:r,dataIndex:a,ignoreTick:!1,labelOffset:f}),c.has(a)||c.set(a,new Set);const k=c.get(a);for(const h of k.values())o[h].ignoreTick=!0;k.add(o.length-1)}else{u+=1;const x=i.step()*u*(D[s]-D[n]);m.labelOffset=x}}return o}const Ct=b.styled("g",{name:"MuiChartsAxis",slot:"Root"})(({theme:e})=>({[`& .${N.tickLabel}`]:b._extends({},e.typography.caption,{fill:(e.vars||e).palette.text.primary}),[`& .${N.label}`]:{fill:(e.vars||e).palette.text.primary},[`& .${N.line}`]:{stroke:(e.vars||e).palette.text.primary,shapeRendering:"crispEdges",strokeWidth:1},[`& .${N.tick}`]:{stroke:(e.vars||e).palette.text.primary,shapeRendering:"crispEdges"}}));exports.AxisRoot=Ct;exports.ChartsText=Z;exports.axisClasses=N;exports.batchMeasureStrings=bt;exports.doesTextFitInRect=gt;exports.ellipsize=mt;exports.getAxisUtilityClass=xt;exports.getDefaultBaseline=It;exports.getDefaultTextAnchor=wt;exports.getStringSize=G;exports.invertTextAnchor=Mt;exports.isInfinity=V;exports.useIsHydrated=F;exports.useTicks=st;exports.useTicksGrouped=St;
|