@molecule/app-ui-react 4.13.0 → 4.14.1
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 +97 -119
- package/dist/components/Accordion.d.ts +1 -11
- package/dist/components/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion.js +1 -82
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/Alert.d.ts +1 -25
- package/dist/components/Alert.d.ts.map +1 -1
- package/dist/components/Alert.js +1 -60
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Avatar.d.ts +1 -11
- package/dist/components/Avatar.d.ts.map +1 -1
- package/dist/components/Avatar.js +1 -28
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Checkbox.d.ts +1 -11
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +1 -27
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Pagination.d.ts +1 -11
- package/dist/components/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination.js +1 -79
- package/dist/components/Pagination.js.map +1 -1
- package/dist/components/RadioGroup.d.ts +1 -11
- package/dist/components/RadioGroup.d.ts.map +1 -1
- package/dist/components/RadioGroup.js +1 -35
- package/dist/components/RadioGroup.js.map +1 -1
- package/dist/components/Select.d.ts +1 -26
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js +1 -71
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Spinner.d.ts +1 -16
- package/dist/components/Spinner.d.ts.map +1 -1
- package/dist/components/Spinner.js +1 -29
- package/dist/components/Spinner.js.map +1 -1
- package/dist/components/Switch.d.ts +1 -11
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +1 -32
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Table.d.ts +1 -11
- package/dist/components/Table.d.ts.map +1 -1
- package/dist/components/Table.js +1 -57
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.d.ts +1 -11
- package/dist/components/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs.js +1 -75
- package/dist/components/Tabs.js.map +1 -1
- package/dist/components/Textarea.d.ts +1 -10
- package/dist/components/Textarea.d.ts.map +1 -1
- package/dist/components/Textarea.js +1 -27
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/Toast.d.ts +2 -14
- package/dist/components/Toast.d.ts.map +1 -1
- package/dist/components/Toast.js +8 -89
- package/dist/components/Toast.js.map +1 -1
- package/dist/components/formSubmitError.d.ts.map +1 -1
- package/dist/components/formSubmitError.js +7 -2
- package/dist/components/formSubmitError.js.map +1 -1
- package/dist/elements/Anchor.d.ts +1 -1
- package/dist/elements/Box.d.ts +1 -15
- package/dist/elements/Box.d.ts.map +1 -1
- package/dist/elements/Box.js +1 -56
- package/dist/elements/Box.js.map +1 -1
- package/dist/elements/CheckField.d.ts +1 -16
- package/dist/elements/CheckField.d.ts.map +1 -1
- package/dist/elements/CheckField.js +1 -52
- package/dist/elements/CheckField.js.map +1 -1
- package/dist/elements/Image.d.ts +1 -16
- package/dist/elements/Image.d.ts.map +1 -1
- package/dist/elements/Image.js +1 -21
- package/dist/elements/Image.js.map +1 -1
- package/dist/elements/Pressable.d.ts +1 -16
- package/dist/elements/Pressable.d.ts.map +1 -1
- package/dist/elements/Pressable.js +1 -42
- package/dist/elements/Pressable.js.map +1 -1
- package/dist/elements/ScrollArea.d.ts +1 -15
- package/dist/elements/ScrollArea.d.ts.map +1 -1
- package/dist/elements/ScrollArea.js +1 -41
- package/dist/elements/ScrollArea.js.map +1 -1
- package/dist/elements/SelectField.d.ts +1 -10
- package/dist/elements/SelectField.d.ts.map +1 -1
- package/dist/elements/SelectField.js +1 -63
- package/dist/elements/SelectField.js.map +1 -1
- package/dist/elements/Svg.d.ts +1 -123
- package/dist/elements/Svg.d.ts.map +1 -1
- package/dist/elements/Svg.js +1 -177
- package/dist/elements/Svg.js.map +1 -1
- package/dist/elements/TableBox.d.ts +1 -15
- package/dist/elements/TableBox.d.ts.map +1 -1
- package/dist/elements/TableBox.js +1 -17
- package/dist/elements/TableBox.js.map +1 -1
- package/dist/elements/TableCell.d.ts +1 -15
- package/dist/elements/TableCell.d.ts.map +1 -1
- package/dist/elements/TableCell.js +1 -17
- package/dist/elements/TableCell.js.map +1 -1
- package/dist/elements/Text.d.ts +1 -17
- package/dist/elements/Text.d.ts.map +1 -1
- package/dist/elements/Text.js +1 -19
- package/dist/elements/Text.js.map +1 -1
- package/dist/elements/TextField.d.ts +1 -17
- package/dist/elements/TextField.d.ts.map +1 -1
- package/dist/elements/TextField.js +1 -104
- package/dist/elements/TextField.js.map +1 -1
- package/dist/elements/drag.d.ts +1 -10
- package/dist/elements/drag.d.ts.map +1 -1
- package/dist/elements/drag.js +1 -21
- package/dist/elements/drag.js.map +1 -1
- package/dist/elements/flow.d.ts +1 -16
- package/dist/elements/flow.d.ts.map +1 -1
- package/dist/elements/flow.js +1 -17
- package/dist/elements/flow.js.map +1 -1
- package/dist/elements/hover.d.ts +1 -9
- package/dist/elements/hover.d.ts.map +1 -1
- package/dist/elements/hover.js +1 -22
- package/dist/elements/hover.js.map +1 -1
- package/dist/elements/measure.d.ts +1 -24
- package/dist/elements/measure.d.ts.map +1 -1
- package/dist/elements/measure.js +1 -19
- package/dist/elements/measure.js.map +1 -1
- package/dist/elements/paste.d.ts +1 -4
- package/dist/elements/paste.d.ts.map +1 -1
- package/dist/elements/paste.js +1 -14
- package/dist/elements/paste.js.map +1 -1
- package/dist/elements/ref.d.ts +1 -15
- package/dist/elements/ref.d.ts.map +1 -1
- package/dist/elements/ref.js +1 -17
- package/dist/elements/ref.js.map +1 -1
- package/dist/elements/style.d.ts +1 -34
- package/dist/elements/style.d.ts.map +1 -1
- package/dist/elements/style.js +1 -33
- package/dist/elements/style.js.map +1 -1
- package/dist/elements/types.d.ts +1 -22
- package/dist/elements/types.d.ts.map +1 -1
- package/dist/elements/types.js +1 -6
- package/dist/elements/types.js.map +1 -1
- package/dist/elements/viewport.d.ts +1 -52
- package/dist/elements/viewport.d.ts.map +1 -1
- package/dist/elements/viewport.js +1 -103
- package/dist/elements/viewport.js.map +1 -1
- package/dist/index.native.d.ts +1 -0
- package/dist/index.native.d.ts.map +1 -1
- package/dist/index.native.js +1 -0
- package/dist/index.native.js.map +1 -1
- package/dist/kit.native.d.ts +12 -0
- package/dist/kit.native.d.ts.map +1 -0
- package/dist/kit.native.js +11 -0
- package/dist/kit.native.js.map +1 -0
- package/dist/kit.web.d.ts +39 -0
- package/dist/kit.web.d.ts.map +1 -0
- package/dist/kit.web.js +34 -0
- package/dist/kit.web.js.map +1 -0
- package/dist/platform/index.d.ts +1 -28
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +1 -179
- package/dist/platform/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +1 -12
- package/dist/utilities/initials.d.ts.map +1 -1
- package/dist/utilities/initials.js +1 -22
- package/dist/utilities/initials.js.map +1 -1
- package/dist/utilities/isReactNode.d.ts +1 -15
- package/dist/utilities/isReactNode.d.ts.map +1 -1
- package/dist/utilities/isReactNode.js +1 -26
- package/dist/utilities/isReactNode.js.map +1 -1
- package/dist/utilities/mergeRefs.d.ts +1 -19
- package/dist/utilities/mergeRefs.d.ts.map +1 -1
- package/dist/utilities/mergeRefs.js +1 -33
- package/dist/utilities/mergeRefs.js.map +1 -1
- package/dist/utilities/renderIcon.d.ts +3 -17
- package/dist/utilities/renderIcon.d.ts.map +1 -1
- package/dist/utilities/renderIcon.js +6 -31
- package/dist/utilities/renderIcon.js.map +1 -1
- package/dist/utilities/rootProps.d.ts +1 -19
- package/dist/utilities/rootProps.d.ts.map +1 -1
- package/dist/utilities/rootProps.js +1 -18
- package/dist/utilities/rootProps.js.map +1 -1
- package/package.json +16 -8
- package/dist/platform/arrow.d.ts +0 -5
- package/dist/platform/arrow.d.ts.map +0 -1
- package/dist/platform/arrow.js +0 -49
- package/dist/platform/arrow.js.map +0 -1
package/dist/components/Tabs.js
CHANGED
|
@@ -1,76 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Tabs component.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { forwardRef, useId, useRef, useState } from 'react';
|
|
8
|
-
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
-
import { Box, Pressable } from '@molecule/app-ui-react/elements';
|
|
10
|
-
/**
|
|
11
|
-
* Tabs component.
|
|
12
|
-
*/
|
|
13
|
-
export const Tabs = forwardRef(({ items, value, defaultValue, onChange, variant, size, fitted, className, style, testId, automationId, disabled, }, ref) => {
|
|
14
|
-
const [internalValue, setInternalValue] = useState(defaultValue || items[0]?.value);
|
|
15
|
-
const activeValue = value !== undefined ? value : internalValue;
|
|
16
|
-
const cm = getClassMap();
|
|
17
|
-
// Per-instance id prefix: bare `tab-${value}` ids collided whenever two
|
|
18
|
-
// Tabs instances on one page shared a tab value (e.g. both have an
|
|
19
|
-
// "overview" tab) — aria-labelledby/aria-controls then resolved to the
|
|
20
|
-
// OTHER instance's elements.
|
|
21
|
-
const idBase = useId();
|
|
22
|
-
const tabRefs = useRef({});
|
|
23
|
-
const selectTab = (tabValue) => {
|
|
24
|
-
if (value === undefined) {
|
|
25
|
-
setInternalValue(tabValue);
|
|
26
|
-
}
|
|
27
|
-
onChange?.(tabValue);
|
|
28
|
-
};
|
|
29
|
-
// WAI-ARIA APG "automatic activation" tabs pattern: roving tabindex
|
|
30
|
-
// (only the active tab is a Tab stop — see `tabIndex` below) plus
|
|
31
|
-
// Left/Right/Home/End moving BOTH focus and the active tab, so keyboard
|
|
32
|
-
// users never have to Tab through every trigger to reach the one they
|
|
33
|
-
// want. Disabled tabs are skipped; a disabled Tabs disables every tab.
|
|
34
|
-
const handleKeyDown = (event) => {
|
|
35
|
-
const enabled = disabled ? [] : items.filter((item) => !item.disabled);
|
|
36
|
-
if (enabled.length === 0)
|
|
37
|
-
return;
|
|
38
|
-
const currentIndex = enabled.findIndex((item) => item.value === activeValue);
|
|
39
|
-
let nextIndex;
|
|
40
|
-
switch (event.key) {
|
|
41
|
-
case 'ArrowRight':
|
|
42
|
-
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % enabled.length;
|
|
43
|
-
break;
|
|
44
|
-
case 'ArrowLeft':
|
|
45
|
-
nextIndex = currentIndex === -1 ? 0 : (currentIndex - 1 + enabled.length) % enabled.length;
|
|
46
|
-
break;
|
|
47
|
-
case 'Home':
|
|
48
|
-
nextIndex = 0;
|
|
49
|
-
break;
|
|
50
|
-
case 'End':
|
|
51
|
-
nextIndex = enabled.length - 1;
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
const nextValue = enabled[nextIndex].value;
|
|
58
|
-
selectTab(nextValue);
|
|
59
|
-
tabRefs.current[nextValue]?.focus();
|
|
60
|
-
};
|
|
61
|
-
const activeItem = items.find((item) => item.value === activeValue);
|
|
62
|
-
return (_jsxs(Box, { as: "div", ref: ref, className: className, webStyle: style, "data-testid": testId, "data-mol-id": automationId, children: [_jsx(Box, { as: "div", className: cm.cn(cm.tabsList({ variant, size }), fitted && cm.tabsFitted), role: "tablist", children: items.map((item) => {
|
|
63
|
-
const isActive = item.value === activeValue;
|
|
64
|
-
return (_jsxs(Pressable, { as: "button", ref: (node) => {
|
|
65
|
-
tabRefs.current[item.value] = node;
|
|
66
|
-
}, id: `${idBase}-tab-${item.value}`, type: "button", role: "tab", "aria-selected": isActive, "aria-controls": isActive && !!item.content ? `${idBase}-tabpanel-${item.value}` : undefined, "data-state": isActive ? 'active' : 'inactive',
|
|
67
|
-
// Roving tabindex: only the active tab is a Tab stop —
|
|
68
|
-
// arrow keys (handled above) move focus among the rest.
|
|
69
|
-
tabIndex: isActive ? 0 : -1, disabled: disabled || item.disabled, onClick: () => selectTab(item.value),
|
|
70
|
-
// The arrow keys act on the focused tab (the tablist itself never
|
|
71
|
-
// takes focus), so the handler sits on each tab.
|
|
72
|
-
onKeyDown: handleKeyDown, className: cm.cn(cm.tabsTrigger({ variant, size }), fitted && cm.tabTriggerFitted), children: [!!item.icon && (_jsx(Box, { as: "span", className: cm.tabTriggerIcon, children: item.icon })), item.label] }, item.value));
|
|
73
|
-
}) }), !!activeItem?.content && (_jsx(Box, { as: "div", role: "tabpanel", id: `${idBase}-tabpanel-${activeValue}`, "aria-labelledby": `${idBase}-tab-${activeValue}`, className: cm.tabsContent({ variant, size }), children: activeItem.content }))] }));
|
|
74
|
-
});
|
|
75
|
-
Tabs.displayName = 'Tabs';
|
|
1
|
+
export { Tabs } from '#kit';
|
|
76
2
|
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/components/Tabs.
|
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/components/Tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA"}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Textarea component.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type { TextareaProps } from '@molecule/app-ui';
|
|
7
|
-
/**
|
|
8
|
-
* Textarea component.
|
|
9
|
-
*/
|
|
10
|
-
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
1
|
+
export { Textarea } from '#kit';
|
|
11
2
|
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA"}
|
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Textarea component.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { forwardRef, useId } from 'react';
|
|
8
|
-
import { fieldLayout, getClassMap } from '@molecule/app-ui';
|
|
9
|
-
import { Box, Text, TextField } from '@molecule/app-ui-react/elements';
|
|
10
|
-
import { rootProps } from '../utilities/rootProps.js';
|
|
11
|
-
/**
|
|
12
|
-
* Textarea component.
|
|
13
|
-
*/
|
|
14
|
-
export const Textarea = forwardRef(({ size, label, error, hint, autoResize, minRows = 3, maxRows, className, style, testId, disabled, required, value, defaultValue, placeholder, name, id, rows, onChange, onValueChange, onFocus, onBlur, ...rest }, ref) => {
|
|
15
|
-
const cm = getClassMap();
|
|
16
|
-
// A column around the label, the control and the message, so the control's margin moves
|
|
17
|
-
// the control on every renderer (the same layout in every framework's kit).
|
|
18
|
-
const field = fieldLayout(cm);
|
|
19
|
-
// Fall back to a generated id so label htmlFor / aria-describedby never
|
|
20
|
-
// point at `undefined-error` (which also collides across multiple
|
|
21
|
-
// id-less textareas on the same page).
|
|
22
|
-
const generatedId = useId();
|
|
23
|
-
const textareaId = id || name || generatedId;
|
|
24
|
-
const textareaClasses = cm.cn(cm.textarea({ error: !!error, size }), className);
|
|
25
|
-
return (_jsxs(Box, { as: "div", className: field.root, children: [label && (_jsx(Text, { as: "label", htmlFor: textareaId, className: cm.cn(cm.label({ required: !!required }), cm.labelBlock), children: label })), _jsx(TextField, { as: "textarea", ref: ref, id: textareaId, name: name, value: value, defaultValue: defaultValue, placeholder: placeholder, disabled: disabled, required: required, rows: rows || minRows, "aria-invalid": !!error, "aria-describedby": error ? `${textareaId}-error` : hint ? `${textareaId}-hint` : undefined, className: textareaClasses, webStyle: autoResize ? { resize: 'none', ...style } : style, autoGrow: autoResize ? { minRows, maxRows } : undefined, "data-testid": testId, onChange: onChange, onValueChange: onValueChange, onFocus: onFocus, onBlur: onBlur, ...rootProps(rest) }), error && (_jsx(Text, { as: "p", id: `${textareaId}-error`, className: cm.formError, children: error })), hint && !error && (_jsx(Text, { as: "p", id: `${textareaId}-hint`, className: cm.formHint, children: hint }))] }));
|
|
26
|
-
});
|
|
27
|
-
Textarea.displayName = 'Textarea';
|
|
1
|
+
export { Textarea } from '#kit';
|
|
28
2
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/components/Textarea.
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/components/Textarea.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA"}
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Toast
|
|
2
|
+
* Toast queue and overlay container for the React UI kit.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { type FC, type NamedExoticComponent, type ReactNode, type RefAttributes } from 'react';
|
|
7
7
|
import type { ElementHandle, ToastProps as WebToastProps } from '@molecule/app-ui';
|
|
8
8
|
import type { ToastProps } from '../types.js';
|
|
9
|
-
|
|
10
|
-
* Single Toast component.
|
|
11
|
-
*
|
|
12
|
-
* The auto-dismiss countdown pauses on hover AND focus (WCAG 2.2.1) and
|
|
13
|
-
* resumes with whatever time was left — a slow reader or a keyboard/AT
|
|
14
|
-
* user interacting with the toast never has it disappear mid-read. The
|
|
15
|
-
* announced role follows `status`: `warning`/`error` get the assertive
|
|
16
|
-
* `role="alert"`; every other status (`info`, `success`, the default) gets
|
|
17
|
-
* the polite `role="status"` so routine confirmations don't interrupt a
|
|
18
|
-
* screen reader mid-sentence the way an assertive announcement does.
|
|
19
|
-
*/
|
|
20
|
-
export declare const Toast: NamedExoticComponent<WebToastProps & RefAttributes<ElementHandle>>;
|
|
9
|
+
export { Toast } from '#kit';
|
|
21
10
|
/**
|
|
22
11
|
* Toast container for positioning toasts.
|
|
23
12
|
*/
|
|
@@ -59,5 +48,4 @@ interface ToastProviderProps {
|
|
|
59
48
|
* @returns The rendered provider with toast container.
|
|
60
49
|
*/
|
|
61
50
|
export declare const ToastProvider: FC<ToastProviderProps>;
|
|
62
|
-
export {};
|
|
63
51
|
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,KAAK,EAAE,EAEP,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,aAAa,EAMnB,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAKlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAE5B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAID;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,oBAAoB,CAC/C,mBAAmB,GAAG,aAAa,CAAC,aAAa,CAAC,CAqBnD,CAAA;AAID;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO;IACzD,MAAM,EAAE,CAAC,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAA;IACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,MAAM,CAAA;IACrD,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC;AAED,KAAK,kBAAkB,GAAG,iBAAiB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;AAItE;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAO,kBAW3B,CAAA;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;CAClC;AAID;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA+BhD,CAAA"}
|
package/dist/components/Toast.js
CHANGED
|
@@ -1,99 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* Toast
|
|
3
|
+
* Toast queue and overlay container for the React UI kit.
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Toast } from '#kit';
|
|
8
|
+
import { createContext, forwardRef, useCallback, useContext, useMemo, useRef, useState, } from 'react';
|
|
8
9
|
import { useTranslation } from '@molecule/app-react';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { focusStaysWithin, OverlayPortal, ToastMessage, useOverlayLayer, } from '@molecule/app-ui-react/platform';
|
|
10
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
11
|
+
import { Box } from '@molecule/app-ui-react/elements';
|
|
12
|
+
import { OverlayPortal, useOverlayLayer } from '@molecule/app-ui-react/platform';
|
|
13
13
|
import { isReactNode } from '../utilities/isReactNode.js';
|
|
14
14
|
import { mergeRefs } from '../utilities/mergeRefs.js';
|
|
15
|
-
|
|
16
|
-
import { rootProps } from '../utilities/rootProps.js';
|
|
17
|
-
/**
|
|
18
|
-
* Map status to toast variant.
|
|
19
|
-
*/
|
|
20
|
-
const statusVariantMap = {
|
|
21
|
-
primary: 'default',
|
|
22
|
-
secondary: 'default',
|
|
23
|
-
success: 'success',
|
|
24
|
-
warning: 'warning',
|
|
25
|
-
error: 'error',
|
|
26
|
-
info: 'info',
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Map toast status to icon name.
|
|
30
|
-
*/
|
|
31
|
-
const statusIconMap = {
|
|
32
|
-
info: 'info-circle',
|
|
33
|
-
success: 'check-circle',
|
|
34
|
-
warning: 'exclamation-triangle',
|
|
35
|
-
error: 'x-circle',
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Single Toast component.
|
|
39
|
-
*
|
|
40
|
-
* The auto-dismiss countdown pauses on hover AND focus (WCAG 2.2.1) and
|
|
41
|
-
* resumes with whatever time was left — a slow reader or a keyboard/AT
|
|
42
|
-
* user interacting with the toast never has it disappear mid-read. The
|
|
43
|
-
* announced role follows `status`: `warning`/`error` get the assertive
|
|
44
|
-
* `role="alert"`; every other status (`info`, `success`, the default) gets
|
|
45
|
-
* the polite `role="status"` so routine confirmations don't interrupt a
|
|
46
|
-
* screen reader mid-sentence the way an assertive announcement does.
|
|
47
|
-
*/
|
|
48
|
-
export const Toast = forwardRef(({ children: childrenProp, title, description, status = 'info', duration = 5000, dismissible = true, onDismiss, position: _position = 'bottom-right', closeLabel, className, style, testId, onMouseEnter, onMouseLeave, onFocus, onBlur, ...rest }, ref) => {
|
|
49
|
-
const [isVisible, setIsVisible] = useState(true);
|
|
50
|
-
const { t } = useTranslation();
|
|
51
|
-
const cm = getClassMap();
|
|
52
|
-
const variant = statusVariantMap[status] || 'default';
|
|
53
|
-
const iconName = statusIconMap[variant];
|
|
54
|
-
const statusIcon = iconName ? renderIcon(iconName, cm.iconMd) : null;
|
|
55
|
-
// Keep the latest onDismiss in a ref so the auto-dismiss timer depends
|
|
56
|
-
// ONLY on `duration`. With onDismiss in the effect deps, every parent
|
|
57
|
-
// re-render that recreates the callback (e.g. ToastProvider re-rendering
|
|
58
|
-
// as new toasts arrive) restarted the countdown — a busy toast stack
|
|
59
|
-
// never auto-dismissed.
|
|
60
|
-
const onDismissRef = useRef(onDismiss);
|
|
61
|
-
useCommittedRef(onDismissRef, onDismiss);
|
|
62
|
-
const [countdown] = useState(() => new ToastCountdown(() => {
|
|
63
|
-
setIsVisible(false);
|
|
64
|
-
onDismissRef.current?.();
|
|
65
|
-
}));
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
countdown.start(duration);
|
|
68
|
-
return countdown.stop;
|
|
69
|
-
}, [countdown, duration]);
|
|
70
|
-
if (!isVisible)
|
|
71
|
-
return null;
|
|
72
|
-
const message = description || (isReactNode(childrenProp) ? slot(childrenProp) : undefined);
|
|
73
|
-
// Assertive announcement is appropriate for warnings/errors — an info or
|
|
74
|
-
// success toast interrupting a screen-reader user mid-sentence for a
|
|
75
|
-
// routine confirmation is the same over-announcing trap `role="alert"`
|
|
76
|
-
// creates everywhere it's used for non-urgent content.
|
|
77
|
-
const role = variant === 'warning' || variant === 'error' ? 'alert' : 'status';
|
|
78
|
-
return (_jsxs(ToastMessage, { accessibilityGroup: false, ref: ref, spokenContent: _jsxs(_Fragment, { children: [title, message] }), role: role, "data-state": "open", className: cm.cn(cm.toast({ variant }), className), webStyle: style, "data-testid": testId, ...rootProps(rest),
|
|
79
|
-
// The timer pauses while the pointer or focus is on the toast; the caller's handlers
|
|
80
|
-
// for the same events run after it.
|
|
81
|
-
onMouseEnter: (event) => {
|
|
82
|
-
countdown.setPaused('hover', true);
|
|
83
|
-
onMouseEnter?.(event);
|
|
84
|
-
}, onMouseLeave: (event) => {
|
|
85
|
-
countdown.setPaused('hover', false);
|
|
86
|
-
onMouseLeave?.(event);
|
|
87
|
-
}, onFocus: (event) => {
|
|
88
|
-
countdown.setPaused('focus', true);
|
|
89
|
-
onFocus?.(event);
|
|
90
|
-
}, onBlur: (event) => {
|
|
91
|
-
if (!focusStaysWithin(event))
|
|
92
|
-
countdown.setPaused('focus', false);
|
|
93
|
-
onBlur?.(event);
|
|
94
|
-
}, children: [statusIcon && (_jsx(Box, { as: "span", className: cm.toastIconWrapper, children: statusIcon })), _jsxs(Box, { as: "div", className: cm.toastContentWrapper, children: [title && (_jsx(Box, { as: "div", className: cm.toastTitle, children: title })), !!message && (_jsx(Box, { as: "div", className: cm.toastDescription, children: message }))] }), dismissible && (_jsx(Pressable, { as: "button", type: "button", onClick: countdown.dismiss, className: cm.toastClose, "aria-label": closeLabel ?? t('ui.toast.close', undefined, { defaultValue: 'Close' }), children: renderIcon('x-mark', cm.iconSm) }))] }));
|
|
95
|
-
});
|
|
96
|
-
Toast.displayName = 'Toast';
|
|
15
|
+
export { Toast } from '#kit';
|
|
97
16
|
// positionClasses removed — use cm.toastContainer({ position }) instead
|
|
98
17
|
/**
|
|
99
18
|
* Container that positions toasts on screen via a portal.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EAEb,UAAU,EAIV,WAAW,EACX,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../src/components/Toast.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EACL,aAAa,EAEb,UAAU,EAIV,WAAW,EACX,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAGhF,OAAO,EAAE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AAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;IACtD,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,MAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,aAC5D,QAAQ,EACT,KAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,YAC/B,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,KAAC,KAAK,OAAoB,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,IAA3D,KAAK,CAAC,EAAE,CAAuD,CAC5E,CAAC,GACa,IACK,CACzB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formSubmitError.d.ts","sourceRoot":"","sources":["../../src/components/formSubmitError.ts"],"names":[],"mappings":"AAAA,yFAAyF;AASzF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"formSubmitError.d.ts","sourceRoot":"","sources":["../../src/components/formSubmitError.ts"],"names":[],"mappings":"AAAA,yFAAyF;AASzF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBlF"}
|
|
@@ -25,7 +25,12 @@ export function formSubmitErrorMessages(error, fallback) {
|
|
|
25
25
|
.map((message) => `${field} ${message}`));
|
|
26
26
|
if (messages.length)
|
|
27
27
|
return messages;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// A failure that carries a response came from the transport, and its own message is a status line written for
|
|
29
|
+
// logs ("Request failed with status 401."): the body speaks for the server. Molecule API routes answer a refused
|
|
30
|
+
// request with `{ error }`, already translated for the user.
|
|
31
|
+
const sources = record(failure?.response)
|
|
32
|
+
? [body?.error, body?.message]
|
|
33
|
+
: [body?.error, body?.message, failure?.message, error];
|
|
34
|
+
return [sources.find(text) ?? fallback];
|
|
30
35
|
}
|
|
31
36
|
//# sourceMappingURL=formSubmitError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formSubmitError.js","sourceRoot":"","sources":["../../src/components/formSubmitError.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,iFAAiF;AACjF,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAChD,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAc,EAAE,QAAgB;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI,IAAI,KAAK,CAAC,CAAA;IAC/F,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,CAAA;IAC3B,MAAM,IAAI,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC/C,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAA;IACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACpC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAC9D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C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAC9D,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;aACrC,MAAM,CAAC,IAAI,CAAC;aACZ,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC,CAC3C,CAAA;IACL,IAAI,QAAQ,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAA;IACpC,8GAA8G;IAC9G,iHAAiH;IACjH,6DAA6D;IAC7D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;QACvC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;QAC9B,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IACzD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -8,7 +8,7 @@ import type { ElementHandle } from '@molecule/app-ui';
|
|
|
8
8
|
* Renders a literal `<a href>` with the supplied props. The browser handles navigation after the
|
|
9
9
|
* caller's click handler, including cancellation through `preventDefault()`.
|
|
10
10
|
*/
|
|
11
|
-
export declare const Anchor: import("react").ForwardRefExoticComponent<Omit<import("@molecule/app-ui").ElementLinkProps<import("react").ReactNode>, "
|
|
11
|
+
export declare const Anchor: import("react").ForwardRefExoticComponent<Omit<import("@molecule/app-ui").ElementLinkProps<import("react").ReactNode>, "to" | "replace" | "state"> & {
|
|
12
12
|
href: string;
|
|
13
13
|
} & import("react").RefAttributes<ElementHandle>>;
|
|
14
14
|
//# sourceMappingURL=Anchor.d.ts.map
|
package/dist/elements/Box.d.ts
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Box: a container element.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type { BoxProps, ElementHandle } from '@molecule/app-ui';
|
|
7
|
-
/**
|
|
8
|
-
* A container: renders exactly its `as` tag (`<Box as="ul">` is a `<ul>`) with the props given.
|
|
9
|
-
* On React Native it is a `View`. Text goes in a {@link Text}.
|
|
10
|
-
*
|
|
11
|
-
* @param props - See {@link BoxProps}.
|
|
12
|
-
* @param ref - The element rendered by `as`.
|
|
13
|
-
* @returns The element.
|
|
14
|
-
*/
|
|
15
|
-
export declare const Box: import("react").ForwardRefExoticComponent<BoxProps<import("react").ReactNode> & import("react").RefAttributes<ElementHandle>>;
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/Box.js';
|
|
16
2
|
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../src/elements/Box.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Box.d.ts","sourceRoot":"","sources":["../../src/elements/Box.tsx"],"names":[],"mappings":"AAAA,cAAc,uDAAuD,CAAA"}
|
package/dist/elements/Box.js
CHANGED
|
@@ -1,57 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Box: a container element.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { createElement, forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
7
|
-
import { mergeRefs } from '../utilities/mergeRefs.js';
|
|
8
|
-
import { useWebDrag } from './drag.js';
|
|
9
|
-
import { useWebHover } from './hover.js';
|
|
10
|
-
import { pasteHandler } from './paste.js';
|
|
11
|
-
import { useElementRef } from './ref.js';
|
|
12
|
-
import { webElementAttributes } from './style.js';
|
|
13
|
-
/**
|
|
14
|
-
* A container: renders exactly its `as` tag (`<Box as="ul">` is a `<ul>`) with the props given.
|
|
15
|
-
* On React Native it is a `View`. Text goes in a {@link Text}.
|
|
16
|
-
*
|
|
17
|
-
* @param props - See {@link BoxProps}.
|
|
18
|
-
* @param ref - The element rendered by `as`.
|
|
19
|
-
* @returns The element.
|
|
20
|
-
*/
|
|
21
|
-
export const Box = forwardRef(function Box({ as, children, drag, onPressOutside, secondaryAction, accessibilityGroup: _accessibilityGroup, ...props }, ref) {
|
|
22
|
-
const { hidden, onDoubleClick, onMouseEnter, onMouseLeave, onPasteText, onTouchStart } = props;
|
|
23
|
-
const node = useRef(null);
|
|
24
|
-
const forward = useElementRef(ref);
|
|
25
|
-
const setNode = useMemo(() => mergeRefs(node, forward), [forward]);
|
|
26
|
-
const pointerDown = useWebDrag(hidden ? undefined : drag, as);
|
|
27
|
-
const hover = useWebHover({ onMouseEnter, onMouseLeave });
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const element = node.current;
|
|
30
|
-
const ownerDocument = element?.ownerDocument;
|
|
31
|
-
const ownerWindow = ownerDocument?.defaultView;
|
|
32
|
-
if (hidden || !onPressOutside || !element || !ownerDocument || !ownerWindow)
|
|
33
|
-
return;
|
|
34
|
-
const dismiss = (event) => {
|
|
35
|
-
if (event.target instanceof ownerWindow.Node && !element.contains(event.target)) {
|
|
36
|
-
onPressOutside();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
ownerDocument.addEventListener('mousedown', dismiss);
|
|
40
|
-
return () => ownerDocument.removeEventListener('mousedown', dismiss);
|
|
41
|
-
}, [as, hidden, onPressOutside]);
|
|
42
|
-
return createElement(as, webElementAttributes(props, {
|
|
43
|
-
...hover,
|
|
44
|
-
ref: onPressOutside ? setNode : forward,
|
|
45
|
-
onPointerDown: pointerDown,
|
|
46
|
-
onTouchStart: onTouchStart ? () => onTouchStart() : undefined,
|
|
47
|
-
onDoubleClick: secondaryAction
|
|
48
|
-
? (event) => {
|
|
49
|
-
onDoubleClick?.(event);
|
|
50
|
-
if (!event.defaultPrevented)
|
|
51
|
-
secondaryAction.run();
|
|
52
|
-
}
|
|
53
|
-
: onDoubleClick,
|
|
54
|
-
onPaste: pasteHandler(onPasteText),
|
|
55
|
-
}, { onPasteText: 'onPaste' }), children);
|
|
56
|
-
});
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/Box.js';
|
|
57
2
|
//# sourceMappingURL=Box.js.map
|
package/dist/elements/Box.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.js","sourceRoot":"","sources":["../../src/elements/Box.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Box.js","sourceRoot":"","sources":["../../src/elements/Box.tsx"],"names":[],"mappings":"AAAA,cAAc,uDAAuD,CAAA"}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* CheckField: a checkbox or controlled radio.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { type ReactElement, type Ref } from 'react';
|
|
7
|
-
import type { CheckFieldHandle, CheckFieldProps } from '@molecule/app-ui';
|
|
8
|
-
/**
|
|
9
|
-
* Renders the original input tag and forwards the browser's check state and events.
|
|
10
|
-
*
|
|
11
|
-
* @param props - The checkbox or radio's props and ref.
|
|
12
|
-
* @returns The input.
|
|
13
|
-
*/
|
|
14
|
-
export declare function CheckField({ as, indeterminate, nativeChangeEvent, ref, ...props }: CheckFieldProps & {
|
|
15
|
-
ref?: Ref<CheckFieldHandle>;
|
|
16
|
-
}): ReactElement;
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/CheckField.js';
|
|
17
2
|
//# sourceMappingURL=CheckField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckField.d.ts","sourceRoot":"","sources":["../../src/elements/CheckField.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CheckField.d.ts","sourceRoot":"","sources":["../../src/elements/CheckField.tsx"],"names":[],"mappings":"AAAA,cAAc,8DAA8D,CAAA"}
|
|
@@ -1,53 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* CheckField: a checkbox or controlled radio.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { createElement, useCallback, useLayoutEffect, useRef, } from 'react';
|
|
7
|
-
import { useElementRef } from './ref.js';
|
|
8
|
-
import { webElementAttributes } from './style.js';
|
|
9
|
-
/**
|
|
10
|
-
* Renders the original input tag and forwards the browser's check state and events.
|
|
11
|
-
*
|
|
12
|
-
* @param props - The checkbox or radio's props and ref.
|
|
13
|
-
* @returns The input.
|
|
14
|
-
*/
|
|
15
|
-
export function CheckField({ as, indeterminate, nativeChangeEvent, ref, ...props }) {
|
|
16
|
-
const { checked, onChange, onCheckedChange } = props;
|
|
17
|
-
const node = useRef(null);
|
|
18
|
-
const forward = useElementRef(ref);
|
|
19
|
-
const handleNativeChange = useCallback((event) => {
|
|
20
|
-
const input = node.current;
|
|
21
|
-
if (!input)
|
|
22
|
-
return;
|
|
23
|
-
const next = input.checked;
|
|
24
|
-
onChange?.(event);
|
|
25
|
-
onCheckedChange?.(next);
|
|
26
|
-
}, [onChange, onCheckedChange]);
|
|
27
|
-
const listener = nativeChangeEvent ? handleNativeChange : undefined;
|
|
28
|
-
const setNode = useCallback((element) => {
|
|
29
|
-
if (listener) {
|
|
30
|
-
node.current?.removeEventListener('change', listener);
|
|
31
|
-
element?.addEventListener('change', listener);
|
|
32
|
-
}
|
|
33
|
-
node.current = element;
|
|
34
|
-
forward?.(element);
|
|
35
|
-
}, [forward, listener]);
|
|
36
|
-
useLayoutEffect(() => {
|
|
37
|
-
if (node.current)
|
|
38
|
-
node.current.indeterminate = indeterminate ?? false;
|
|
39
|
-
}, [indeterminate]);
|
|
40
|
-
const handleChange = onChange || onCheckedChange || checked !== undefined
|
|
41
|
-
? (event) => {
|
|
42
|
-
if (nativeChangeEvent)
|
|
43
|
-
return;
|
|
44
|
-
const next = event.currentTarget.checked;
|
|
45
|
-
onChange?.(event);
|
|
46
|
-
onCheckedChange?.(next);
|
|
47
|
-
}
|
|
48
|
-
: undefined;
|
|
49
|
-
return createElement(as, webElementAttributes(props, { onChange: handleChange, ref: setNode }, {
|
|
50
|
-
onCheckedChange: 'onChange',
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/CheckField.js';
|
|
53
2
|
//# sourceMappingURL=CheckField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckField.js","sourceRoot":"","sources":["../../src/elements/CheckField.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CheckField.js","sourceRoot":"","sources":["../../src/elements/CheckField.tsx"],"names":[],"mappings":"AAAA,cAAc,8DAA8D,CAAA"}
|
package/dist/elements/Image.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Image: a picture.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { type ReactElement } from 'react';
|
|
7
|
-
import type { ImageProps } from '@molecule/app-ui';
|
|
8
|
-
import type { ElementRefProps } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* An image: renders exactly an `<img>` with the props given. On React Native it is an `Image`
|
|
11
|
-
* with `alt` as its accessibility label.
|
|
12
|
-
*
|
|
13
|
-
* @param props - See {@link ImageProps}.
|
|
14
|
-
* @returns The element.
|
|
15
|
-
*/
|
|
16
|
-
export declare function Image({ ref, ...props }: ImageProps & ElementRefProps): ReactElement;
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/Image.js';
|
|
17
2
|
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../src/elements/Image.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../src/elements/Image.tsx"],"names":[],"mappings":"AAAA,cAAc,yDAAyD,CAAA"}
|
package/dist/elements/Image.js
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Image: a picture.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import { createElement } from 'react';
|
|
7
|
-
import { useElementRef } from './ref.js';
|
|
8
|
-
import { webElementAttributes } from './style.js';
|
|
9
|
-
/**
|
|
10
|
-
* An image: renders exactly an `<img>` with the props given. On React Native it is an `Image`
|
|
11
|
-
* with `alt` as its accessibility label.
|
|
12
|
-
*
|
|
13
|
-
* @param props - See {@link ImageProps}.
|
|
14
|
-
* @returns The element.
|
|
15
|
-
*/
|
|
16
|
-
export function Image({ ref, ...props }) {
|
|
17
|
-
return createElement('img', {
|
|
18
|
-
...webElementAttributes(props),
|
|
19
|
-
ref: useElementRef(ref),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/Image.js';
|
|
22
2
|
//# sourceMappingURL=Image.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../src/elements/Image.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../src/elements/Image.tsx"],"names":[],"mappings":"AAAA,cAAc,yDAAyD,CAAA"}
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Pressable: an element the user activates.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import type { ElementHandle, PressableProps } from '@molecule/app-ui';
|
|
7
|
-
/**
|
|
8
|
-
* Something the user activates: renders exactly its `as` tag (`<Pressable as="button"
|
|
9
|
-
* type="button">`) with its handlers. On React Native it is a `Pressable`; `onClick` fires on press
|
|
10
|
-
* and a string child is drawn in a `Text`.
|
|
11
|
-
*
|
|
12
|
-
* @param props - See {@link PressableProps}.
|
|
13
|
-
* @param ref - The element rendered by `as`.
|
|
14
|
-
* @returns The element.
|
|
15
|
-
*/
|
|
16
|
-
export declare const Pressable: import("react").ForwardRefExoticComponent<PressableProps<import("react").ReactNode> & import("react").RefAttributes<ElementHandle>>;
|
|
1
|
+
export * from '@molecule/app-react-ui-kit-components/elements/Pressable.js';
|
|
17
2
|
//# sourceMappingURL=Pressable.d.ts.map
|