@molecule/app-ui-react 4.1.7 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -26
- package/dist/components/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion.js +5 -4
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +3 -2
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/AuthGuard.d.ts +12 -9
- package/dist/components/AuthGuard.d.ts.map +1 -1
- package/dist/components/AuthGuard.js +23 -15
- package/dist/components/AuthGuard.js.map +1 -1
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +3 -2
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Badge.js +3 -2
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +2 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/Card.js +11 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +2 -1
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/ConfirmButton.d.ts.map +1 -1
- package/dist/components/ConfirmButton.js +2 -1
- package/dist/components/ConfirmButton.js.map +1 -1
- package/dist/components/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown.js +34 -24
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Form.d.ts.map +1 -1
- package/dist/components/Form.js +4 -3
- package/dist/components/Form.js.map +1 -1
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +2 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/Layout.js +22 -20
- package/dist/components/Layout.js.map +1 -1
- package/dist/components/Modal.d.ts +4 -4
- package/dist/components/Modal.d.ts.map +1 -1
- package/dist/components/Modal.js +7 -32
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/OptimisticToggleButton.d.ts.map +1 -1
- package/dist/components/OptimisticToggleButton.js +2 -1
- package/dist/components/OptimisticToggleButton.js.map +1 -1
- package/dist/components/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination.js +2 -2
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/Progress.d.ts.map +1 -1
- package/dist/components/Progress.js +2 -2
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/RadioGroup.d.ts.map +1 -1
- package/dist/components/RadioGroup.js +2 -2
- package/dist/components/RadioGroup.js.map +1 -1
- package/dist/components/ResponsiveAppShell.d.ts +14 -12
- package/dist/components/ResponsiveAppShell.d.ts.map +1 -1
- package/dist/components/ResponsiveAppShell.js +15 -14
- package/dist/components/ResponsiveAppShell.js.map +1 -1
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js +2 -1
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Separator.d.ts.map +1 -1
- package/dist/components/Separator.js +2 -2
- package/dist/components/Separator.js.map +1 -1
- package/dist/components/SidebarUserCard.d.ts.map +1 -1
- package/dist/components/SidebarUserCard.js +1 -2
- package/dist/components/SidebarUserCard.js.map +1 -1
- package/dist/components/Skeleton.d.ts.map +1 -1
- package/dist/components/Skeleton.js +2 -2
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Spinner.d.ts +2 -2
- package/dist/components/Spinner.d.ts.map +1 -1
- package/dist/components/Spinner.js +4 -8
- package/dist/components/Spinner.js.map +1 -1
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +2 -2
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js +3 -2
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs.js +5 -5
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Textarea.js +2 -1
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip.js +9 -4
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/UserMenu.d.ts.map +1 -1
- package/dist/components/UserMenu.js +1 -2
- package/dist/components/UserMenu.js.map +1 -1
- package/dist/components/UserMenuPopover.d.ts.map +1 -1
- package/dist/components/UserMenuPopover.js +1 -2
- package/dist/components/UserMenuPopover.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/mergeRefs.d.ts +16 -0
- package/dist/utilities/mergeRefs.d.ts.map +1 -0
- package/dist/utilities/mergeRefs.js +23 -0
- package/dist/utilities/mergeRefs.js.map +1 -0
- package/package.json +7 -8
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-22T17:17:49.428Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-ui-react
|
|
@@ -78,7 +78,7 @@ function ConfirmDelete({ onConfirm }: { onConfirm: () => void }) {
|
|
|
78
78
|
## Installation
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
npm install @molecule/app-ui-react @molecule/app-i18n @molecule/app-icons @molecule/app-react @molecule/app-ui react react-dom
|
|
81
|
+
npm install @molecule/app-ui-react @molecule/app-i18n @molecule/app-icons @molecule/app-react @molecule/app-ui react react-dom
|
|
82
82
|
npm install -D @types/react @types/react-dom
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -97,6 +97,99 @@ interface CSSProperties {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
#### `KitEvent`
|
|
101
|
+
|
|
102
|
+
The event a UI kit hands a component's handler: the members that behave the same on every kit. React's kit
|
|
103
|
+
passes React's event (so `stopPropagation()` stops React parent handlers), the other kits pass the DOM event;
|
|
104
|
+
both satisfy this type. A handler that needs a member only one of them has (`nativeEvent`, `composedPath()`,
|
|
105
|
+
`isComposing`) takes the component's ref element (see {@link BaseProps}) and listens on it.
|
|
106
|
+
|
|
107
|
+
`type` is left out on purpose: kits report different event types for the same moment (a text field's
|
|
108
|
+
`onChange` is React's `'change'` and the DOM's `'input'`).
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
interface KitEvent {
|
|
112
|
+
/** The element the event started on (`(event.target as HTMLInputElement).value` reads a field). */
|
|
113
|
+
readonly target: EventTarget | null
|
|
114
|
+
/** The element of the component the handler was passed to. */
|
|
115
|
+
readonly currentTarget: EventTarget | null
|
|
116
|
+
/** Whether a handler already called {@link KitEvent.preventDefault}. */
|
|
117
|
+
readonly defaultPrevented: boolean
|
|
118
|
+
/** Cancels the browser's default action (a form's submit, a checkbox's toggle). */
|
|
119
|
+
preventDefault(): void
|
|
120
|
+
/** Stops handlers of ancestor components of the same kit. */
|
|
121
|
+
stopPropagation(): void
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### `KitModifierKeys`
|
|
126
|
+
|
|
127
|
+
The modifier keys held during a mouse or keyboard event.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface KitModifierKeys {
|
|
131
|
+
/** Alt (Option) was held. */
|
|
132
|
+
readonly altKey: boolean
|
|
133
|
+
/** Control was held. */
|
|
134
|
+
readonly ctrlKey: boolean
|
|
135
|
+
/** Meta (Command, Windows) was held. */
|
|
136
|
+
readonly metaKey: boolean
|
|
137
|
+
/** Shift was held. */
|
|
138
|
+
readonly shiftKey: boolean
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### `KitMouseEvent`
|
|
143
|
+
|
|
144
|
+
A mouse event as every kit hands it to a handler.
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
interface KitMouseEvent extends KitEvent, KitModifierKeys {
|
|
148
|
+
/** The button that changed state (0 main, 1 auxiliary, 2 secondary). */
|
|
149
|
+
readonly button: number
|
|
150
|
+
/** The buttons held, as a bit mask. */
|
|
151
|
+
readonly buttons: number
|
|
152
|
+
/** The pointer's x position in the viewport. */
|
|
153
|
+
readonly clientX: number
|
|
154
|
+
/** The pointer's y position in the viewport. */
|
|
155
|
+
readonly clientY: number
|
|
156
|
+
/** The pointer's x position in the document. */
|
|
157
|
+
readonly pageX: number
|
|
158
|
+
/** The pointer's y position in the document. */
|
|
159
|
+
readonly pageY: number
|
|
160
|
+
/** The click count of a click event. */
|
|
161
|
+
readonly detail: number
|
|
162
|
+
/** The element the pointer came from or went to, for enter and leave events. */
|
|
163
|
+
readonly relatedTarget: EventTarget | null
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### `KitKeyboardEvent`
|
|
168
|
+
|
|
169
|
+
A keyboard event as every kit hands it to a handler.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
interface KitKeyboardEvent extends KitEvent, KitModifierKeys {
|
|
173
|
+
/** The key's value (`'Enter'`, `'a'`). */
|
|
174
|
+
readonly key: string
|
|
175
|
+
/** The physical key (`'KeyA'`). */
|
|
176
|
+
readonly code: string
|
|
177
|
+
/** Whether the key is held down and auto-repeating. */
|
|
178
|
+
readonly repeat: boolean
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### `KitFocusEvent`
|
|
183
|
+
|
|
184
|
+
A focus event as every kit hands it to a handler.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
interface KitFocusEvent extends KitEvent {
|
|
188
|
+
/** The element losing focus (on focus) or gaining it (on blur). */
|
|
189
|
+
readonly relatedTarget: EventTarget | null
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
100
193
|
#### `BaseProps`
|
|
101
194
|
|
|
102
195
|
Base props shared by all components.
|
|
@@ -1531,7 +1624,7 @@ interface SkeletonProps extends BaseProps {
|
|
|
1531
1624
|
Props for {@link AuthGuard}.
|
|
1532
1625
|
|
|
1533
1626
|
All props are optional — the default behavior (loading tag → redirect
|
|
1534
|
-
to `/login` →
|
|
1627
|
+
to `/login` → the routed page) matches the bare-bones guard apps were
|
|
1535
1628
|
shipping locally. The props let apps customize per-call without
|
|
1536
1629
|
forking the component.
|
|
1537
1630
|
|
|
@@ -1570,8 +1663,10 @@ interface AuthGuardProps {
|
|
|
1570
1663
|
*/
|
|
1571
1664
|
onAuthenticated?: () => void
|
|
1572
1665
|
/**
|
|
1573
|
-
* Children to render when authenticated.
|
|
1574
|
-
*
|
|
1666
|
+
* Children to render when authenticated. Without them the guard renders
|
|
1667
|
+
* `<RoutedView />`: the matched child route, through whichever routing bond
|
|
1668
|
+
* the app wired. That throws when the routing bond has no routed view
|
|
1669
|
+
* (Next.js gives a layout its page as `children`): pass the page then.
|
|
1575
1670
|
*/
|
|
1576
1671
|
children?: ReactNode
|
|
1577
1672
|
}
|
|
@@ -2389,15 +2484,16 @@ type ShellSidebarWidth = 'sm' | 'md' | 'lg' | number
|
|
|
2389
2484
|
|
|
2390
2485
|
#### `AuthGuard(props)`
|
|
2391
2486
|
|
|
2392
|
-
Route-element guard for authenticated sections of
|
|
2487
|
+
Route-element guard for authenticated sections of the app's route tree.
|
|
2393
2488
|
|
|
2394
2489
|
- While `useAuth().status` is `'loading'` (no session decision yet), renders the
|
|
2395
2490
|
`loadingFallback` (or the default `<div data-mol-id="auth-guard-loading">{t('common.loading')}</div>`).
|
|
2396
|
-
- If the status is `'unauthenticated'`, redirects to
|
|
2397
|
-
|
|
2398
|
-
`
|
|
2399
|
-
|
|
2400
|
-
|
|
2491
|
+
- If the status is `'unauthenticated'`, renders nothing and redirects to
|
|
2492
|
+
`loginPath` (replacing the entry), carrying the attempted location in
|
|
2493
|
+
`state.from` for post-login restoration. On `loginPath` itself it renders
|
|
2494
|
+
its children instead, so a guard that wraps the whole route tree (login
|
|
2495
|
+
page included) does not redirect in a loop.
|
|
2496
|
+
- Otherwise renders `children` (or `<RoutedView />` if none).
|
|
2401
2497
|
|
|
2402
2498
|
The guard reads `status`, not `initialized`: a stored token AND user make the
|
|
2403
2499
|
FIRST render `'authenticated'`, so a protected page paints immediately instead
|
|
@@ -3231,10 +3327,10 @@ const Spacer: React.ForwardRefExoticComponent<SpacerProps & React.RefAttributes<
|
|
|
3231
3327
|
|
|
3232
3328
|
Modal component.
|
|
3233
3329
|
|
|
3234
|
-
Renders into a `document.body` portal.
|
|
3235
|
-
`aria
|
|
3236
|
-
|
|
3237
|
-
|
|
3330
|
+
Renders into a `document.body` portal. Every other declared prop (`id`, `title`,
|
|
3331
|
+
`aria-*`, `data-*`, `automationId` as `data-mol-id`, the DOM event handlers) reaches the
|
|
3332
|
+
inner dialog `<div>`; a caller's `role`, `tabIndex` or `aria-labelledby` replaces the
|
|
3333
|
+
default (e.g. `role="alertdialog"`).
|
|
3238
3334
|
|
|
3239
3335
|
The internal close button always carries `data-mol-id="modal-close"`
|
|
3240
3336
|
as the molecule-convention default for the one fixed interactive
|
|
@@ -3396,8 +3492,8 @@ const SkeletonCircle: React.ForwardRefExoticComponent<
|
|
|
3396
3492
|
|
|
3397
3493
|
Spinner component.
|
|
3398
3494
|
|
|
3399
|
-
|
|
3400
|
-
|
|
3495
|
+
`automationId` renders as `data-mol-id`; `data-*` and `aria-*` props on the rest reach
|
|
3496
|
+
the status element (a caller's `aria-label` replaces the default).
|
|
3401
3497
|
|
|
3402
3498
|
```typescript
|
|
3403
3499
|
const Spinner: React.ForwardRefExoticComponent<
|
|
@@ -3495,11 +3591,10 @@ Peer dependencies:
|
|
|
3495
3591
|
|
|
3496
3592
|
- `@molecule/app-i18n` ^1.0.1
|
|
3497
3593
|
- `@molecule/app-icons` ^1.0.1
|
|
3498
|
-
- `@molecule/app-react` ^4.
|
|
3499
|
-
- `@molecule/app-ui` ^1.
|
|
3594
|
+
- `@molecule/app-react` ^4.12.0
|
|
3595
|
+
- `@molecule/app-ui` ^1.5.0
|
|
3500
3596
|
- `react` ^18.0.0 || ^19.0.0
|
|
3501
3597
|
- `react-dom` ^18.0.0 || ^19.0.0
|
|
3502
|
-
- `react-router` ^7.0.0 || ^8.0.0
|
|
3503
3598
|
|
|
3504
3599
|
### Runtime Dependencies
|
|
3505
3600
|
|
|
@@ -3509,7 +3604,6 @@ Peer dependencies:
|
|
|
3509
3604
|
- `@molecule/app-ui`
|
|
3510
3605
|
- `react`
|
|
3511
3606
|
- `react-dom`
|
|
3512
|
-
- `react-router`
|
|
3513
3607
|
|
|
3514
3608
|
Wiring prerequisites — get these right before debugging anything else:
|
|
3515
3609
|
|
|
@@ -3522,11 +3616,12 @@ Wiring prerequisites — get these right before debugging anything else:
|
|
|
3522
3616
|
`ThemeToggle` need `I18nProvider` (via `MoleculeProvider i18n={...}`); `ThemeToggle` also
|
|
3523
3617
|
needs `ThemeProvider`; `AuthGuard` also needs `AuthProvider`. The primitive components
|
|
3524
3618
|
(Button, Modal, Input, …) need only the ClassMap.
|
|
3525
|
-
- **Router-linked components** (`UserMenu`, `UserMenuPopover`, `SidebarUserCard`, `Dropdown
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3619
|
+
- **Router-linked components** (`UserMenu`, `UserMenuPopover`, `SidebarUserCard`, `Dropdown`,
|
|
3620
|
+
`ResponsiveAppShell`, `AuthGuard`) read the router through `@molecule/app-react`
|
|
3621
|
+
(`useLocation`, `useRouterInstance`, `RoutedView`), so they work under any routing bond and
|
|
3622
|
+
import no router library. They need the router component of the app's routing bond
|
|
3623
|
+
(`BrowserRouter` from `@molecule/app-routing-react-router`) above them, and throw an error
|
|
3624
|
+
naming it without one.
|
|
3530
3625
|
- **`UserMenu` panel content is `children`** (rendered inside the popover, with
|
|
3531
3626
|
`PanelClose`/`usePanelClose` available) — there is no `renderPanel` prop.
|
|
3532
3627
|
- **`Icon` names are kebab-case `IconName`s from `@molecule/app-icons`** — an unknown name is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../src/components/Accordion.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA8E,MAAM,OAAO,CAAA;AAGlG,OAAO,KAAK,EAAsC,cAAc,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Accordion.d.ts","sourceRoot":"","sources":["../../src/components/Accordion.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA8E,MAAM,OAAO,CAAA;AAGlG,OAAO,KAAK,EAAsC,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAmF1F;;GAEG;AACH,eAAO,MAAM,SAAS,+FAoFrB,CAAA"}
|
|
@@ -19,20 +19,21 @@ const useAccordionContext = () => {
|
|
|
19
19
|
}
|
|
20
20
|
return context;
|
|
21
21
|
};
|
|
22
|
-
const AccordionItemComponent = ({ item, className }) => {
|
|
22
|
+
const AccordionItemComponent = ({ item, className, disabled, }) => {
|
|
23
23
|
const { expandedItems, toggleItem } = useAccordionContext();
|
|
24
|
+
const isDisabled = disabled || item.disabled;
|
|
24
25
|
const isExpanded = expandedItems.includes(item.value);
|
|
25
26
|
const contentId = useId();
|
|
26
27
|
const triggerId = useId();
|
|
27
28
|
const cm = getClassMap();
|
|
28
|
-
return (_jsxs("div", { className: cm.cn(cm.accordionItem, className), "data-state": isExpanded ? 'open' : 'closed', children: [_jsxs("button", { id: triggerId, type: "button", className: cm.cn(cm.accordion({ variant: 'default' }), cm.accordionTriggerBase), onClick: () => !
|
|
29
|
+
return (_jsxs("div", { className: cm.cn(cm.accordionItem, className), "data-state": isExpanded ? 'open' : 'closed', children: [_jsxs("button", { id: triggerId, type: "button", className: cm.cn(cm.accordion({ variant: 'default' }), cm.accordionTriggerBase), onClick: () => !isDisabled && toggleItem(item.value), "aria-expanded": isExpanded, "aria-controls": contentId, "data-state": isExpanded ? 'open' : 'closed', disabled: isDisabled, children: [item.header, renderIcon('chevron-down', cm.accordionChevron)] }), _jsx("div", { id: contentId, role: "region", "aria-labelledby": triggerId, "data-state": isExpanded ? 'open' : 'closed', className: cm.accordionContent, style: {
|
|
29
30
|
display: isExpanded ? 'block' : 'none',
|
|
30
31
|
}, children: _jsx("div", { className: cm.accordionContentInner, children: item.content }) })] }));
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
33
34
|
* Accordion component.
|
|
34
35
|
*/
|
|
35
|
-
export const Accordion = forwardRef(({ items, value, defaultValue, onChange, multiple = false, collapsible = true, className, style, testId, }, ref) => {
|
|
36
|
+
export const Accordion = forwardRef(({ items, value, defaultValue, onChange, multiple = false, collapsible = true, className, style, testId, automationId, disabled, }, ref) => {
|
|
36
37
|
const cm = getClassMap();
|
|
37
38
|
// Normalize value to array
|
|
38
39
|
const normalizeValue = (v) => {
|
|
@@ -75,7 +76,7 @@ export const Accordion = forwardRef(({ items, value, defaultValue, onChange, mul
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
}, [expandedItems, multiple, collapsible, value, onChange]);
|
|
78
|
-
return (_jsx(AccordionContext.Provider, { value: { expandedItems, toggleItem, multiple }, children: _jsx("div", { ref: ref, className: cm.cn(cm.accordionRoot, className), style: style, "data-testid": testId, children: items.map((item) => (_jsx(AccordionItemComponent, { item: item }, item.value))) }) }));
|
|
79
|
+
return (_jsx(AccordionContext.Provider, { value: { expandedItems, toggleItem, multiple }, children: _jsx("div", { ref: ref, className: cm.cn(cm.accordionRoot, className), style: style, "data-testid": testId, "data-mol-id": automationId, children: items.map((item) => (_jsx(AccordionItemComponent, { item: item, disabled: disabled }, item.value))) }) }));
|
|
79
80
|
});
|
|
80
81
|
Accordion.displayName = 'Accordion';
|
|
81
82
|
//# sourceMappingURL=Accordion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../src/components/Accordion.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAWvD,MAAM,gBAAgB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAA;AAE1E,MAAM,mBAAmB,GAAG,GAA0B,EAAE;IACtD,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAA;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,CAAC,CAAC,yCAAyC,EAAE,SAAS,EAAE;YACtD,YAAY,EAAE,uDAAuD;SACtE,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"Accordion.js","sourceRoot":"","sources":["../../src/components/Accordion.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,UAA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D,CAAA;IAED,OAAO,CACL,KAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,YACvE,cACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,EAC7C,KAAK,EAAE,KAAK,iBACC,MAAM,iBACN,YAAY,YAExB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,KAAC,sBAAsB,IAAkB,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,IAA1C,IAAI,CAAC,KAAK,CAAoC,CAC5E,CAAC,GACE,GACoB,CAC7B,CAAA;AACH,CAAC,CACF,CAAA;AAED,SAAS,CAAC,WAAW,GAAG,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAIzC,OAAO,KAAK,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAA;AA0BhE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK;WAAoD,OAAO;wCAmE5E,CAAA"}
|
package/dist/components/Alert.js
CHANGED
|
@@ -8,6 +8,7 @@ import { forwardRef } from 'react';
|
|
|
8
8
|
import { useTranslation } from '@molecule/app-react';
|
|
9
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
10
|
import { renderIcon } from '../utilities/renderIcon.js';
|
|
11
|
+
import { rootProps } from '../utilities/rootProps.js';
|
|
11
12
|
const statusVariantMap = {
|
|
12
13
|
primary: 'default',
|
|
13
14
|
secondary: 'default',
|
|
@@ -40,7 +41,7 @@ const statusIconMap = {
|
|
|
40
41
|
* page's normal content, and it announces politely (`role="status"`)
|
|
41
42
|
* instead of interrupting.
|
|
42
43
|
*/
|
|
43
|
-
export const Alert = forwardRef(({ children, title, status = 'info', variant, live = true, dismissible, onDismiss, icon, dismissLabel, className, style, testId, }, ref) => {
|
|
44
|
+
export const Alert = forwardRef(({ children, title, status = 'info', variant, live = true, dismissible, onDismiss, icon, dismissLabel, className, style, testId, ...rest }, ref) => {
|
|
44
45
|
const { t } = useTranslation();
|
|
45
46
|
const cm = getClassMap();
|
|
46
47
|
const alertVariant = statusVariantMap[status] || 'default';
|
|
@@ -51,7 +52,7 @@ export const Alert = forwardRef(({ children, title, status = 'info', variant, li
|
|
|
51
52
|
// status-colored leading bar (previously silently dropped).
|
|
52
53
|
variant === 'left-accent' && cm.alertLeftAccent({ variant: alertVariant }), className);
|
|
53
54
|
const role = live ? 'alert' : 'status';
|
|
54
|
-
return (_jsxs("div", { ref: ref, role: role, className: alertClasses, style: style, "data-testid": testId, children: [(icon || defaultIcon) && (_jsx("span", { className: cm.alertIconWrapper, children: (icon || defaultIcon) })), _jsxs("div", { className: cm.alertContent, children: [title && _jsx("h5", { className: cm.alertTitle, children: title }), _jsx("div", { className: cm.alertDescription, children: children })] }), dismissible && (_jsx("button", { type: "button", onClick: onDismiss, className: cm.alertDismiss, "aria-label": dismissLabel ?? t('ui.alert.dismiss', undefined, { defaultValue: 'Dismiss' }), children: renderIcon('x-mark', cm.iconSm) }))] }));
|
|
55
|
+
return (_jsxs("div", { ref: ref, role: role, className: alertClasses, style: style, "data-testid": testId, ...rootProps(rest), children: [(icon || defaultIcon) && (_jsx("span", { className: cm.alertIconWrapper, children: (icon || defaultIcon) })), _jsxs("div", { className: cm.alertContent, children: [title && _jsx("h5", { className: cm.alertTitle, children: title }), _jsx("div", { className: cm.alertDescription, children: children })] }), dismissible && (_jsx("button", { type: "button", onClick: onDismiss, className: cm.alertDismiss, "aria-label": dismissLabel ?? t('ui.alert.dismiss', undefined, { defaultValue: 'Dismiss' }), children: renderIcon('x-mark', cm.iconSm) }))] }));
|
|
55
56
|
});
|
|
56
57
|
Alert.displayName = 'Alert';
|
|
57
58
|
//# sourceMappingURL=Alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../src/components/Alert.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,MAAM,gBAAgB,GACpB;IACE,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAA;AAEH;;GAEG;AACH,MAAM,aAAa,GAA6B;IAC9C,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,sBAAsB;IAC/B,KAAK,EAAE,UAAU;CA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AI,IAAI,WAAW,CAAoB,GAAQ,CACxF,EACD,eAAK,SAAS,EAAE,EAAE,CAAC,YAAY,aAC5B,KAAK,IAAI,aAAI,SAAS,EAAE,EAAE,CAAC,UAAU,YAAG,KAAK,GAAM,EACpD,cAAK,SAAS,EAAE,EAAE,CAAC,gBAAgB,YAAG,QAA2B,GAAO,IACpE,EACL,WAAW,IAAI,CACd,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,EAAE,CAAC,YAAY,gBAExB,YAAY,IAAI,CAAC,CAAC,kBAAkB,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,YAG9E,UAAU,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GACzB,CACV,IACG,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { type ReactNode } from 'react';
|
|
|
3
3
|
* Props for {@link AuthGuard}.
|
|
4
4
|
*
|
|
5
5
|
* All props are optional — the default behavior (loading tag → redirect
|
|
6
|
-
* to `/login` →
|
|
6
|
+
* to `/login` → the routed page) matches the bare-bones guard apps were
|
|
7
7
|
* shipping locally. The props let apps customize per-call without
|
|
8
8
|
* forking the component.
|
|
9
9
|
*/
|
|
@@ -41,21 +41,24 @@ export interface AuthGuardProps {
|
|
|
41
41
|
*/
|
|
42
42
|
onAuthenticated?: () => void;
|
|
43
43
|
/**
|
|
44
|
-
* Children to render when authenticated.
|
|
45
|
-
*
|
|
44
|
+
* Children to render when authenticated. Without them the guard renders
|
|
45
|
+
* `<RoutedView />`: the matched child route, through whichever routing bond
|
|
46
|
+
* the app wired. That throws when the routing bond has no routed view
|
|
47
|
+
* (Next.js gives a layout its page as `children`): pass the page then.
|
|
46
48
|
*/
|
|
47
49
|
children?: ReactNode;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
|
-
* Route-element guard for authenticated sections of
|
|
52
|
+
* Route-element guard for authenticated sections of the app's route tree.
|
|
51
53
|
*
|
|
52
54
|
* - While `useAuth().status` is `'loading'` (no session decision yet), renders the
|
|
53
55
|
* `loadingFallback` (or the default `<div data-mol-id="auth-guard-loading">{t('common.loading')}</div>`).
|
|
54
|
-
* - If the status is `'unauthenticated'`, redirects to
|
|
55
|
-
*
|
|
56
|
-
* `
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* - If the status is `'unauthenticated'`, renders nothing and redirects to
|
|
57
|
+
* `loginPath` (replacing the entry), carrying the attempted location in
|
|
58
|
+
* `state.from` for post-login restoration. On `loginPath` itself it renders
|
|
59
|
+
* its children instead, so a guard that wraps the whole route tree (login
|
|
60
|
+
* page included) does not redirect in a loop.
|
|
61
|
+
* - Otherwise renders `children` (or `<RoutedView />` if none).
|
|
59
62
|
*
|
|
60
63
|
* The guard reads `status`, not `initialized`: a stored token AND user make the
|
|
61
64
|
* FIRST render `'authenticated'`, so a protected page paints immediately instead
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/components/AuthGuard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/components/AuthGuard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAA;AAUzD;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,CAAC,EACxB,eAAe,EACf,UAA6B,EAC7B,cAA6B,EAC7B,SAAoB,EACpB,eAAe,EACf,QAAQ,GACT,GAAE,cAAmB,GAAG,SAAS,CAqCjC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { useAuth, useTranslation } from '@molecule/app-react';
|
|
3
|
+
import { RoutedView, useAuth, useLocation, useRouterInstance, useTranslation, } from '@molecule/app-react';
|
|
5
4
|
/**
|
|
6
5
|
* The pathname part of a login path (`/login?next=x` → `/login`).
|
|
7
6
|
*
|
|
@@ -10,15 +9,16 @@ import { useAuth, useTranslation } from '@molecule/app-react';
|
|
|
10
9
|
*/
|
|
11
10
|
const loginPathname = (loginPath) => loginPath.split(/[?#]/)[0] || '/';
|
|
12
11
|
/**
|
|
13
|
-
* Route-element guard for authenticated sections of
|
|
12
|
+
* Route-element guard for authenticated sections of the app's route tree.
|
|
14
13
|
*
|
|
15
14
|
* - While `useAuth().status` is `'loading'` (no session decision yet), renders the
|
|
16
15
|
* `loadingFallback` (or the default `<div data-mol-id="auth-guard-loading">{t('common.loading')}</div>`).
|
|
17
|
-
* - If the status is `'unauthenticated'`, redirects to
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
*
|
|
16
|
+
* - If the status is `'unauthenticated'`, renders nothing and redirects to
|
|
17
|
+
* `loginPath` (replacing the entry), carrying the attempted location in
|
|
18
|
+
* `state.from` for post-login restoration. On `loginPath` itself it renders
|
|
19
|
+
* its children instead, so a guard that wraps the whole route tree (login
|
|
20
|
+
* page included) does not redirect in a loop.
|
|
21
|
+
* - Otherwise renders `children` (or `<RoutedView />` if none).
|
|
22
22
|
*
|
|
23
23
|
* The guard reads `status`, not `initialized`: a stored token AND user make the
|
|
24
24
|
* FIRST render `'authenticated'`, so a protected page paints immediately instead
|
|
@@ -40,7 +40,12 @@ export function AuthGuard({ loadingFallback, loadingKey = 'common.loading', load
|
|
|
40
40
|
const { isAuthenticated, status } = useAuth();
|
|
41
41
|
const { t } = useTranslation();
|
|
42
42
|
const location = useLocation();
|
|
43
|
+
const router = useRouterInstance();
|
|
43
44
|
const lastAuthRef = useRef(false);
|
|
45
|
+
// On the login path itself the guard renders its children: a guard wrapping
|
|
46
|
+
// the whole route tree contains the login page, and redirecting there again
|
|
47
|
+
// would re-navigate on every render.
|
|
48
|
+
const redirecting = status === 'unauthenticated' && location.pathname !== loginPathname(loginPath);
|
|
44
49
|
useEffect(() => {
|
|
45
50
|
if (!onAuthenticated)
|
|
46
51
|
return;
|
|
@@ -49,15 +54,18 @@ export function AuthGuard({ loadingFallback, loadingKey = 'common.loading', load
|
|
|
49
54
|
}
|
|
50
55
|
lastAuthRef.current = isAuthenticated;
|
|
51
56
|
}, [isAuthenticated, onAuthenticated]);
|
|
57
|
+
// Navigates after the commit, as a redirect component does: on entering the
|
|
58
|
+
// redirect state and again for each new entry while in it (`useLocation`
|
|
59
|
+
// returns the same object until the router's location changes).
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (redirecting)
|
|
62
|
+
router.navigate(loginPath, { replace: true, state: { from: location } });
|
|
63
|
+
}, [redirecting, router, loginPath, location]);
|
|
52
64
|
if (status === 'loading') {
|
|
53
65
|
return (loadingFallback ?? (_jsx("div", { "data-mol-id": "auth-guard-loading", children: t(loadingKey, {}, { defaultValue: loadingDefault }) })));
|
|
54
66
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (status === 'unauthenticated' && location.pathname !== loginPathname(loginPath)) {
|
|
59
|
-
return _jsx(Navigate, { to: loginPath, state: { from: location }, replace: true });
|
|
60
|
-
}
|
|
61
|
-
return _jsx(_Fragment, { children: children ?? _jsx(Outlet, {}) });
|
|
67
|
+
if (redirecting)
|
|
68
|
+
return null;
|
|
69
|
+
return _jsx(_Fragment, { children: children ?? _jsx(RoutedView, {}) });
|
|
62
70
|
}
|
|
63
71
|
//# sourceMappingURL=AuthGuard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuard.js","sourceRoot":"","sources":["../../src/components/AuthGuard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"AuthGuard.js","sourceRoot":"","sources":["../../src/components/AuthGuard.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEzD,OAAO,EACL,UAAU,EACV,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAA;AAoD5B;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAA;AAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,eAAe,EACf,UAAU,GAAG,gBAAgB,EAC7B,cAAc,GAAG,YAAY,EAC7B,SAAS,GAAG,QAAQ,EACpB,eAAe,EACf,QAAQ,MACU,EAAE;IACpB,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAA;IAC7C,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;IAC9B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAC9B,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACjC,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AE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA+B,MAAM,OAAO,CAAA;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAOnD;;GAEG;AACH,eAAO,MAAM,MAAM,oFAmDlB,CAAA"}
|
|
@@ -9,10 +9,11 @@ import { useTranslation } from '@molecule/app-react';
|
|
|
9
9
|
import { getClassMap } from '@molecule/app-ui';
|
|
10
10
|
import { getInitials } from '../utilities/initials.js';
|
|
11
11
|
import { renderIcon } from '../utilities/renderIcon.js';
|
|
12
|
+
import { rootProps } from '../utilities/rootProps.js';
|
|
12
13
|
/**
|
|
13
14
|
* Avatar component.
|
|
14
15
|
*/
|
|
15
|
-
export const Avatar = forwardRef(({ src, alt, name, size = 'md', rounded = true, fallback, className, style, testId }, ref) => {
|
|
16
|
+
export const Avatar = forwardRef(({ src, alt, name, size = 'md', rounded = true, fallback, className, style, testId, ...rest }, ref) => {
|
|
16
17
|
const [imageError, setImageError] = useState(false);
|
|
17
18
|
const { t } = useTranslation();
|
|
18
19
|
const cm = getClassMap();
|
|
@@ -20,7 +21,7 @@ export const Avatar = forwardRef(({ src, alt, name, size = 'md', rounded = true,
|
|
|
20
21
|
const avatarSize = typeof size === 'number' ? undefined : size;
|
|
21
22
|
const containerClasses = cm.cn(cm.avatar({ size: avatarSize }), !rounded && cm.avatarSquare, className);
|
|
22
23
|
const customSize = typeof size === 'number' ? { width: size, height: size } : undefined;
|
|
23
|
-
return (_jsx("div", { ref: ref, className: containerClasses, style: { ...style, ...customSize }, "data-testid": testId, children: !showFallback ? (_jsx("img", { src: src, alt: alt || name || t('ui.avatar.alt', undefined, { defaultValue: 'Avatar' }), className: cm.avatarImage, onError: () => setImageError(true) })) : (_jsx("div", { className: cm.avatarFallback, children: fallback ? fallback : name ? (_jsx("span", { className: cm.avatarInitials, children: getInitials(name) })) : (renderIcon('user', cm.avatarFallbackIcon)) })) }));
|
|
24
|
+
return (_jsx("div", { ref: ref, className: containerClasses, style: { ...style, ...customSize }, "data-testid": testId, ...rootProps(rest), children: !showFallback ? (_jsx("img", { src: src, alt: alt || name || t('ui.avatar.alt', undefined, { defaultValue: 'Avatar' }), className: cm.avatarImage, onError: () => setImageError(true) })) : (_jsx("div", { className: cm.avatarFallback, children: fallback ? fallback : name ? (_jsx("span", { className: cm.avatarInitials, children: getInitials(name) })) : (renderIcon('user', cm.avatarFallbackIcon)) })) }));
|
|
24
25
|
});
|
|
25
26
|
Avatar.displayName = 'Avatar';
|
|
26
27
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../src/components/Avatar.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,SAAS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e,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,EAC7E,SAAS,EAAE,EAAE,CAAC,WAAW,EACzB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,GAClC,CACH,CAAC,CAAC,CAAC,CACF,cAAK,SAAS,EAAE,EAAE,CAAC,cAAc,YAC9B,QAAQ,CAAC,CAAC,CACR,QACF,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACT,eAAM,SAAS,EAAE,EAAE,CAAC,cAAc,YAAG,WAAW,CAAC,IAAI,CAAC,GAAQ,CAC/D,CAAC,CAAC,CAAC,CACF,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAC1C,GACG,CACP,GACG,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAKlD;;GAEG;AACH,eAAO,MAAM,KAAK,oFAqCjB,CAAA"}
|
package/dist/components/Badge.js
CHANGED
|
@@ -6,13 +6,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
*/
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { rootProps } from '../utilities/rootProps.js';
|
|
9
10
|
/**
|
|
10
11
|
* Badge component.
|
|
11
12
|
*/
|
|
12
|
-
export const Badge = forwardRef(({ children, color = 'primary', variant: _variant = 'solid', size, rounded = true, className, style, testId, }, ref) => {
|
|
13
|
+
export const Badge = forwardRef(({ children, color = 'primary', variant: _variant = 'solid', size, rounded = true, className, style, testId, ...rest }, ref) => {
|
|
13
14
|
const cm = getClassMap();
|
|
14
15
|
const badgeClasses = cm.cn(cm.badge({ variant: color, size }), !rounded && cm.badgeSquare, className);
|
|
15
|
-
return (_jsx("span", { ref: ref, className: badgeClasses, style: style, "data-testid": testId, children: children }));
|
|
16
|
+
return (_jsx("span", { ref: ref, className: badgeClasses, style: style, "data-testid": testId, ...rootProps(rest), children: children }));
|
|
16
17
|
});
|
|
17
18
|
Badge.displayName = 'Badge';
|
|
18
19
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EACE,QAAQ,EACR,KAAK,GAAG,SAAS,EACjB,OAAO,EAAE,QAAQ,GAAG,OAAO,EAC3B,IAAI,EACJ,OAAO,GAAG,IAAI,EACd,SAAS,EACT,KAAK,EACL,MAAM,
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../src/components/Badge.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EACE,QAAQ,EACR,KAAK,GAAG,SAAS,EACjB,OAAO,EAAE,QAAQ,GAAG,OAAO,EAC3B,IAAI,EACJ,OAAO,GAAG,IAAI,EACd,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;IAExB,MAAM,YAAY,GAAG,EAAE,CAAC,EAAE,CACxB,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAClC,CAAC,OAAO,IAAI,EAAE,CAAC,WAAW,EAC1B,SAAS,CACV,CAAA;IAED,OAAO,CAGL,eACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,KAAK,iBACC,MAAM,KACf,SAAS,CAAC,IAAI,CAAC,YAElB,QAA2B,GACvB,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAMnD;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,uFAgDlB,CAAA"}
|
|
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
*/
|
|
7
7
|
import { forwardRef } from 'react';
|
|
8
8
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
+
import { rootProps } from '../utilities/rootProps.js';
|
|
9
10
|
import { Spinner } from './Spinner.js';
|
|
10
11
|
/**
|
|
11
12
|
* Button component.
|
|
@@ -19,7 +20,7 @@ import { Spinner } from './Spinner.js';
|
|
|
19
20
|
export const Button = forwardRef(({ children, variant = 'solid', color = 'primary', size = 'md', loading = false, loadingText, fullWidth = false, leftIcon, rightIcon, className, style, testId, disabled, type = 'button', onClick, ...rest }, ref) => {
|
|
20
21
|
const cm = getClassMap();
|
|
21
22
|
const classes = cm.cn(cm.button({ variant, color, size, fullWidth }), className);
|
|
22
|
-
return (_jsxs("button", { ref: ref, type: type, className: classes, style: style, "data-testid": testId, disabled: disabled || loading, onClick: onClick, "aria-busy": loading, ...rest, children: [loading && _jsx(Spinner, { size: "sm", className: cm.buttonIconLeft }), !loading && !!leftIcon && (_jsx("span", { className: cm.buttonIconLeft, children: leftIcon })), loading && loadingText ? loadingText : children, !loading && !!rightIcon && (_jsx("span", { className: cm.buttonIconRight, children: rightIcon }))] }));
|
|
23
|
+
return (_jsxs("button", { ref: ref, type: type, className: classes, style: style, "data-testid": testId, disabled: disabled || loading, onClick: onClick, "aria-busy": loading, ...rootProps(rest), children: [loading && _jsx(Spinner, { size: "sm", className: cm.buttonIconLeft }), !loading && !!leftIcon && (_jsx("span", { className: cm.buttonIconLeft, children: leftIcon })), loading && loadingText ? loadingText : children, !loading && !!rightIcon && (_jsx("span", { className: cm.buttonIconRight, children: rightIcon }))] }));
|
|
23
24
|
});
|
|
24
25
|
Button.displayName = 'Button';
|
|
25
26
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,WAAW,EAA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x"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../src/components/Card.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAajD;;GAEG;AACH,eAAO,MAAM,IAAI;oBAA4D,MAAM;wCA+DlF,CAAA;AAID;;GAEG;AACH,eAAO,MAAM,UAAU,6GAUtB,CAAA;AAID;;GAEG;AACH,eAAO,MAAM,SAAS,qHAUrB,CAAA;AAID;;GAEG;AACH,eAAO,MAAM,eAAe,yHAW1B,CAAA;AAIF;;GAEG;AACH,eAAO,MAAM,WAAW,6GAUvB,CAAA;AAID;;GAEG;AACH,eAAO,MAAM,UAAU,6GAUtB,CAAA"}
|