@mezzanine-ui/react 1.0.0-rc.6 → 1.0.0-rc.7

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.
Files changed (61) hide show
  1. package/AutoComplete/AutoComplete.d.ts +25 -9
  2. package/AutoComplete/AutoComplete.js +84 -17
  3. package/AutoComplete/AutoCompleteInside.d.ts +54 -0
  4. package/AutoComplete/AutoCompleteInside.js +17 -0
  5. package/AutoComplete/useAutoCompleteKeyboard.d.ts +2 -1
  6. package/AutoComplete/useAutoCompleteKeyboard.js +4 -1
  7. package/Breadcrumb/BreadcrumbDropdown.d.ts +1 -1
  8. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +1 -1
  9. package/Breadcrumb/typings.d.ts +1 -1
  10. package/COMPONENTS.md +2 -2
  11. package/Checkbox/Checkbox.js +24 -3
  12. package/Cropper/Cropper.d.ts +1 -1
  13. package/Description/Description.d.ts +1 -1
  14. package/Description/Description.js +1 -1
  15. package/Description/DescriptionTitle.d.ts +6 -1
  16. package/Description/DescriptionTitle.js +2 -2
  17. package/Drawer/Drawer.d.ts +39 -34
  18. package/Drawer/Drawer.js +33 -35
  19. package/Dropdown/Dropdown.d.ts +16 -1
  20. package/Dropdown/Dropdown.js +156 -9
  21. package/Dropdown/DropdownItem.d.ts +26 -2
  22. package/Dropdown/DropdownItem.js +91 -43
  23. package/Dropdown/DropdownItemCard.d.ts +3 -2
  24. package/Dropdown/DropdownItemCard.js +8 -5
  25. package/Dropdown/dropdownKeydownHandler.d.ts +6 -0
  26. package/Dropdown/dropdownKeydownHandler.js +14 -7
  27. package/FilterArea/Filter.d.ts +25 -2
  28. package/FilterArea/Filter.js +23 -0
  29. package/FilterArea/FilterArea.d.ts +43 -4
  30. package/FilterArea/FilterArea.js +35 -2
  31. package/FilterArea/FilterLine.d.ts +19 -0
  32. package/FilterArea/FilterLine.js +19 -0
  33. package/Input/SpinnerButton/SpinnerButton.js +1 -1
  34. package/Modal/Modal.d.ts +22 -86
  35. package/Modal/Modal.js +4 -2
  36. package/Modal/ModalBodyForVerification.js +3 -1
  37. package/NotificationCenter/NotificationCenter.d.ts +21 -9
  38. package/NotificationCenter/NotificationCenter.js +22 -10
  39. package/NotificationCenter/NotificationCenterDrawer.d.ts +52 -1
  40. package/NotificationCenter/NotificationCenterDrawer.js +2 -2
  41. package/OverflowTooltip/OverflowTooltip.js +46 -5
  42. package/PageFooter/PageFooter.js +6 -14
  43. package/Pagination/PaginationPageSize.js +1 -1
  44. package/README.md +34 -4
  45. package/Radio/Radio.js +16 -2
  46. package/Table/Table.js +1 -1
  47. package/TimePicker/TimePicker.js +1 -1
  48. package/TimeRangePicker/TimeRangePicker.js +1 -1
  49. package/Toggle/Toggle.d.ts +1 -1
  50. package/Toggle/Toggle.js +1 -1
  51. package/Upload/Upload.d.ts +13 -7
  52. package/Upload/Upload.js +55 -20
  53. package/Upload/UploadItem.js +4 -1
  54. package/Upload/UploadPictureCard.d.ts +5 -0
  55. package/Upload/UploadPictureCard.js +8 -5
  56. package/Upload/Uploader.d.ts +32 -31
  57. package/Upload/Uploader.js +10 -9
  58. package/index.d.ts +3 -3
  59. package/index.js +1 -1
  60. package/llms.txt +128 -9
  61. package/package.json +5 -4
package/llms.txt CHANGED
@@ -28,22 +28,71 @@ import Select from '@mezzanine-ui/react/Select';
28
28
 
29
29
  Named exports from the barrel (hooks, types, utilities):
30
30
  ```ts
31
- import { usePagination, useCheckboxControlValue } from '@mezzanine-ui/react';
31
+ import { usePagination, useCheckboxControlValue, cx } from '@mezzanine-ui/react';
32
32
  import type { ButtonProps, ButtonVariant } from '@mezzanine-ui/react';
33
33
  ```
34
34
 
35
- Required CSS import per component's style entry from @mezzanine-ui/core:
35
+ Sub-path imports for component groups and core types:
36
36
  ```ts
37
- import '@mezzanine-ui/core/button/styles';
38
- import '@mezzanine-ui/core/select/styles';
37
+ // Navigation sub-components
38
+ import {
39
+ NavigationFooter,
40
+ NavigationHeader,
41
+ NavigationOption,
42
+ NavigationIconButton,
43
+ NavigationUserMenu,
44
+ } from '@mezzanine-ui/react/Navigation';
45
+
46
+ // ContentHeader (page-level header with back button + action slots)
47
+ import ContentHeader from '@mezzanine-ui/react/ContentHeader';
48
+
49
+ // Form layout tokens from core (used with FormField)
50
+ import {
51
+ ControlFieldSlotLayout,
52
+ FormFieldLayout,
53
+ FormFieldLabelSpacing,
54
+ } from '@mezzanine-ui/core/form';
39
55
  ```
40
56
 
57
+ Spacing helpers in SCSS (from `@mezzanine-ui/system/spacing`):
58
+ ```scss
59
+ @use '@mezzanine-ui/system/spacing';
60
+
61
+ .host {
62
+ padding: spacing.semantic-variable(padding, vertical, spacious)
63
+ spacing.semantic-variable(padding, horizontal, comfort-fixed);
64
+ row-gap: spacing.semantic-variable(gap, calm);
65
+ }
66
+ ```
67
+
68
+ Required styles — create a `main.scss` and import it at your app entry point. All component styles are loaded at once via `@include mzn-core.styles()`:
69
+ ```scss
70
+ @use '@mezzanine-ui/system' as mzn-system;
71
+ @use '@mezzanine-ui/core' as mzn-core;
72
+
73
+ :root {
74
+ @include mzn-system.common-variables('default');
75
+ @include mzn-system.colors();
76
+ }
77
+
78
+ /* Optional: light/dark palette theming */
79
+ :root { @include mzn-system.palette-variables(light); }
80
+ [data-theme='dark'] { @include mzn-system.palette-variables(dark); }
81
+
82
+ /* Optional: compact density */
83
+ [data-density='compact'] { @include mzn-system.common-variables(compact); }
84
+
85
+ @include mzn-core.styles();
86
+ ```
87
+
88
+ > **Note:** The `~` prefix (e.g. `~@mezzanine-ui/core`) was required by older webpack 4 + sass-loader setups. Modern tooling (Next.js 13+, Vite) resolves node_modules without it — use bare paths as shown above.
89
+
41
90
  ## Component Categories
42
91
 
43
92
  - **General** — Button, ButtonGroup, Cropper, Icon, Layout, Separator, Typography
44
93
  - **Navigation** — Breadcrumb, Drawer, Navigation (+ sub-components), PageHeader, PageFooter, Stepper, Tab
45
94
  - **Data Display** — Accordion, Badge, Cards (BaseCard, FourThumbnailCard, SingleThumbnailCard, QuickActionCard), Description, Empty, Pagination, Table, Tag, Tooltip
46
- - **Data Entry** — AutoComplete, Checkbox, DatePicker, DateRangePicker, DateTimePicker, FilterArea, FormField, Input, Radio, Select, Slider, Switch, Textarea, TimePicker, Upload, Cascader
95
+ - **Data Entry** — AutoComplete, Checkbox, DatePicker, DateRangePicker, DateTimePicker, FilterArea, FormField, Input, Radio, Select, Slider, Toggle, Textarea, TimePicker, Upload, Cascader
47
96
  - **Feedback** — InlineMessage, Message, Modal, NotificationCenter, Progress, ResultState, Skeleton, Spin
48
97
  - **Others** — AlertBanner, Anchor, Backdrop, FloatingButton
49
98
  - **Utility** — Calendar, Dropdown, Popper, Portal, TimePanel, Transition animations (Collapse, Fade, Rotate, Scale, Slide, Translate)
@@ -65,15 +114,85 @@ Available control hooks: `useAutoCompleteValueControl`, `useCheckboxControlValue
65
114
 
66
115
  **Portal-based overlays** — Modal, Drawer, and Tooltip render outside the component tree via `Portal`. Use the `container` prop to target a specific DOM node.
67
116
 
68
- **Calendar adapter pattern** — Calendar components require a date adapter. Install one of `dayjs >= 1`, `moment >= 2`, or `luxon >= 3` and pass it to `CalendarConfigProvider`:
117
+ **Calendar adapter pattern** — Calendar components require wrapping the app with a date-adapter provider. Import from the library-specific entry point to avoid bundling unused date libraries:
69
118
  ```tsx
70
- import { CalendarConfigProvider } from '@mezzanine-ui/react';
71
- import dayjs from 'dayjs';
72
- <CalendarConfigProvider methods={dayjsMethods}>...</CalendarConfigProvider>
119
+ // Day.js (recommended)
120
+ import { CalendarConfigProviderDayjs, CalendarLocale } from '@mezzanine-ui/react/dayjs';
121
+ <CalendarConfigProviderDayjs locale={CalendarLocale.ZH_TW}>{children}</CalendarConfigProviderDayjs>
122
+
123
+ // Moment.js
124
+ import { CalendarConfigProviderMoment, CalendarLocale } from '@mezzanine-ui/react/moment';
125
+
126
+ // Luxon
127
+ import { CalendarConfigProviderLuxon, CalendarLocale } from '@mezzanine-ui/react/luxon';
73
128
  ```
74
129
 
75
130
  **forwardRef** — all components forward their ref to the underlying DOM element.
76
131
 
132
+ **React Hook Form integration** — the recommended pattern is a `BaseField` wrapper that combines `FormField` with RHF's `formState.errors` for automatic error display. `ControlFieldSlotLayout.SUB` aligns the hint/error message with the input:
133
+ ```tsx
134
+ import { useFormContext, get } from 'react-hook-form';
135
+ import FormField from '@mezzanine-ui/react/Form/FormField';
136
+ import { ControlFieldSlotLayout, FormFieldLayout } from '@mezzanine-ui/core/form';
137
+
138
+ function BaseField({ name, label, required, disabled, children }) {
139
+ const { formState } = useFormContext();
140
+ const error = get(formState.errors, name);
141
+ return (
142
+ <FormField
143
+ name={name}
144
+ label={label}
145
+ required={required}
146
+ disabled={disabled}
147
+ layout={FormFieldLayout.VERTICAL}
148
+ controlFieldSlotLayout={ControlFieldSlotLayout.SUB}
149
+ hintText={error?.message ?? ''}
150
+ severity={error ? 'error' : 'info'}
151
+ >
152
+ {children}
153
+ </FormField>
154
+ );
155
+ }
156
+ ```
157
+
158
+ **Message imperative API** — `Message` is a global singleton for toast notifications. Call it imperatively without rendering any JSX:
159
+ ```tsx
160
+ import { Message } from '@mezzanine-ui/react';
161
+
162
+ Message.success('儲存成功');
163
+ Message.warning('請確認輸入資料');
164
+ Message.error('操作失敗,請稍後再試');
165
+ ```
166
+
167
+ **Select inside Modal** — when rendering a `Select` (or `AutoComplete`) inside a `Modal` or `Drawer`, pass `dropdownZIndex` higher than the overlay (default modal z-index is ~1000):
168
+ ```tsx
169
+ <Select options={options} dropdownZIndex={1004} />
170
+ ```
171
+
172
+ ## Common Pitfalls for AI Assistants
173
+
174
+ **Typography `variant` is not h1–h6.** The prop is named `variant` but its type is `TypographySemanticType` — a design-system semantic scale, not HTML heading levels. Valid values are `h1`, `h2`, `h3` (no h4/h5/h6), then `body`, `body-highlight`, `body-mono`, `caption`, `caption-highlight`, `annotation`, `annotation-highlight`, `button`, `input`, `label-primary`, `label-secondary`, and a few others. Never use `h4`, `h5`, or `h6`.
175
+ ```tsx
176
+ <Typography variant="h1">Title</Typography> // ✅
177
+ <Typography variant="body">Body text</Typography> // ✅
178
+ <Typography variant="h5">Subtitle</Typography> // ❌ h5 does not exist
179
+ ```
180
+
181
+ **Button icons use `icon` + `iconType`, not `prefix`/`suffix` JSX.** Pass an icon definition object (from `@mezzanine-ui/icons`) to the `icon` prop and set position via `iconType`: `"leading"` | `"trailing"` | `"icon-only"`. Do not wrap `<Icon />` in `prefix` or `suffix` props — those props do not exist on Button.
182
+ ```tsx
183
+ import { PlusIcon } from '@mezzanine-ui/icons';
184
+ <Button icon={PlusIcon} iconType="leading">新增</Button> // ✅
185
+ <Button prefix={<Icon icon={PlusIcon} />}>新增</Button> // ❌ prefix does not exist
186
+ ```
187
+
188
+ **`TextField` is a low-level layout container, not a full form field.** It renders the border/background/affix shell around an `<input>` but does not include a label, hint text, or error message. For a complete labeled form field, use `FormField` (which wraps `TextField` + `Input` + label + validation message).
189
+ ```tsx
190
+ // Full labeled form field:
191
+ <FormField label="Email" required errorMessage={error}>
192
+ <TextField><Input placeholder="you@example.com" /></TextField>
193
+ </FormField>
194
+ ```
195
+
77
196
  ## Further Reference
78
197
 
79
198
  - Full component index with descriptions: `packages/react/COMPONENTS.md`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/react",
3
- "version": "1.0.0-rc.6",
3
+ "version": "1.0.0-rc.7",
4
4
  "description": "React components for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -13,6 +13,7 @@
13
13
  "module": "index.js",
14
14
  "typings": "index.d.ts",
15
15
  "sideEffects": false,
16
+ "llms": "./llms.txt",
16
17
  "publishConfig": {
17
18
  "access": "public"
18
19
  },
@@ -31,9 +32,9 @@
31
32
  "@floating-ui/dom": "^1.7.4",
32
33
  "@floating-ui/react-dom": "^2.1.6",
33
34
  "@hello-pangea/dnd": "^18.0.1",
34
- "@mezzanine-ui/core": "1.0.0-rc.6",
35
- "@mezzanine-ui/icons": "1.0.0-rc.6",
36
- "@mezzanine-ui/system": "1.0.0-rc.6",
35
+ "@mezzanine-ui/core": "1.0.0-rc.7",
36
+ "@mezzanine-ui/icons": "1.0.0-rc.7",
37
+ "@mezzanine-ui/system": "1.0.0-rc.7",
37
38
  "@tanstack/react-virtual": "^3.13.13",
38
39
  "@types/react-transition-group": "^4.4.12",
39
40
  "clsx": "^2.1.1",