@korzun/design 0.0.4 → 0.0.6
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/AGENTS.md +3 -0
- package/dist/component/card/index.d.ts +13 -2
- package/dist/component/card/index.d.ts.map +1 -1
- package/dist/component/card/index.js +1 -0
- package/dist/component/card/index.js.map +1 -1
- package/dist/component/card/style.d.ts.map +1 -1
- package/dist/component/card/style.js +3 -1
- package/dist/component/card/style.js.map +1 -1
- package/dist/component/card-divider/index.d.ts +15 -0
- package/dist/component/card-divider/index.d.ts.map +1 -1
- package/dist/component/card-divider/index.js +4 -0
- package/dist/component/card-divider/index.js.map +1 -1
- package/dist/component/card-row/index.d.ts +5 -0
- package/dist/component/card-row/index.d.ts.map +1 -1
- package/dist/component/card-row/index.js +1 -0
- package/dist/component/card-row/index.js.map +1 -1
- package/dist/component/card-row/style.js +1 -1
- package/dist/component/card-row/style.js.map +1 -1
- package/dist/component/collapsible-section/index.d.ts +8 -3
- package/dist/component/collapsible-section/index.d.ts.map +1 -1
- package/dist/component/collapsible-section/index.js +1 -0
- package/dist/component/collapsible-section/index.js.map +1 -1
- package/dist/component/empty-state/index.d.ts +2 -2
- package/dist/component/empty-state/index.d.ts.map +1 -1
- package/dist/component/empty-state/index.js.map +1 -1
- package/dist/component/index.d.ts +10 -10
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js.map +1 -1
- package/dist/component/meta-line/index.d.ts +1 -1
- package/dist/component/meta-line/index.d.ts.map +1 -1
- package/dist/component/meta-line/index.js.map +1 -1
- package/dist/component/metadata/index.d.ts +2 -0
- package/dist/component/metadata/index.d.ts.map +1 -1
- package/dist/component/metadata/index.js +1 -0
- package/dist/component/metadata/index.js.map +1 -1
- package/dist/component/metadata-list/index.d.ts +6 -2
- package/dist/component/metadata-list/index.d.ts.map +1 -1
- package/dist/component/metadata-list/index.js +1 -0
- package/dist/component/metadata-list/index.js.map +1 -1
- package/dist/component/nav-desktop/index.d.ts +6 -0
- package/dist/component/nav-desktop/index.d.ts.map +1 -1
- package/dist/component/nav-desktop/index.js +5 -2
- package/dist/component/nav-desktop/index.js.map +1 -1
- package/dist/component/nav-mobile/index.d.ts +11 -3
- package/dist/component/nav-mobile/index.d.ts.map +1 -1
- package/dist/component/nav-mobile/index.js +5 -0
- package/dist/component/nav-mobile/index.js.map +1 -1
- package/dist/component/nav-types.d.ts +4 -0
- package/dist/component/nav-types.d.ts.map +1 -1
- package/dist/component/nav-types.js.map +1 -1
- package/dist/component/page/index.d.ts +10 -2
- package/dist/component/page/index.d.ts.map +1 -1
- package/dist/component/page/index.js +1 -0
- package/dist/component/page/index.js.map +1 -1
- package/dist/component/progress-indicator/index.d.ts +4 -2
- package/dist/component/progress-indicator/index.d.ts.map +1 -1
- package/dist/component/progress-indicator/index.js +1 -0
- package/dist/component/progress-indicator/index.js.map +1 -1
- package/dist/component/tag/index.d.ts +6 -3
- package/dist/component/tag/index.d.ts.map +1 -1
- package/dist/component/tag/index.js +1 -0
- package/dist/component/tag/index.js.map +1 -1
- package/dist/component/theme-setting/index.d.ts +6 -0
- package/dist/component/theme-setting/index.d.ts.map +1 -1
- package/dist/component/theme-setting/index.js +4 -0
- package/dist/component/theme-setting/index.js.map +1 -1
- package/dist/component/top-fade/index.d.ts +7 -0
- package/dist/component/top-fade/index.d.ts.map +1 -1
- package/dist/component/top-fade/index.js +5 -2
- package/dist/component/top-fade/index.js.map +1 -1
- package/dist/control/action-menu-list/index.d.ts +7 -0
- package/dist/control/action-menu-list/index.d.ts.map +1 -1
- package/dist/control/action-menu-list/index.js.map +1 -1
- package/dist/control/back-button/index.d.ts +9 -2
- package/dist/control/back-button/index.d.ts.map +1 -1
- package/dist/control/back-button/index.js +4 -0
- package/dist/control/back-button/index.js.map +1 -1
- package/dist/control/button/index.d.ts +30 -1
- package/dist/control/button/index.d.ts.map +1 -1
- package/dist/control/button/index.js +4 -0
- package/dist/control/button/index.js.map +1 -1
- package/dist/control/chips-input/index.d.ts +20 -0
- package/dist/control/chips-input/index.d.ts.map +1 -1
- package/dist/control/chips-input/index.js +4 -0
- package/dist/control/chips-input/index.js.map +1 -1
- package/dist/control/confirm-modal/index.d.ts +15 -2
- package/dist/control/confirm-modal/index.d.ts.map +1 -1
- package/dist/control/confirm-modal/index.js +4 -0
- package/dist/control/confirm-modal/index.js.map +1 -1
- package/dist/control/date-time-input/index.d.ts +4 -0
- package/dist/control/date-time-input/index.d.ts.map +1 -1
- package/dist/control/date-time-input/index.js.map +1 -1
- package/dist/control/field-list/index.d.ts +20 -2
- package/dist/control/field-list/index.d.ts.map +1 -1
- package/dist/control/field-list/index.js +4 -0
- package/dist/control/field-list/index.js.map +1 -1
- package/dist/control/index.d.ts +16 -21
- package/dist/control/index.d.ts.map +1 -1
- package/dist/control/index.js +5 -5
- package/dist/control/index.js.map +1 -1
- package/dist/control/number-input/index.d.ts +12 -0
- package/dist/control/number-input/index.d.ts.map +1 -1
- package/dist/control/number-input/index.js +4 -0
- package/dist/control/number-input/index.js.map +1 -1
- package/dist/control/page-actions-bar/index.d.ts +11 -3
- package/dist/control/page-actions-bar/index.d.ts.map +1 -1
- package/dist/control/page-actions-bar/index.js +5 -1
- package/dist/control/page-actions-bar/index.js.map +1 -1
- package/dist/control/page-actions-menu/index.d.ts +6 -1
- package/dist/control/page-actions-menu/index.d.ts.map +1 -1
- package/dist/control/page-actions-menu/index.js +4 -0
- package/dist/control/page-actions-menu/index.js.map +1 -1
- package/dist/control/page-footer-actions/index.d.ts +16 -2
- package/dist/control/page-footer-actions/index.d.ts.map +1 -1
- package/dist/control/page-footer-actions/index.js +4 -0
- package/dist/control/page-footer-actions/index.js.map +1 -1
- package/dist/control/popover/index.d.ts +6 -3
- package/dist/control/popover/index.d.ts.map +1 -1
- package/dist/control/popover/index.js +2 -0
- package/dist/control/popover/index.js.map +1 -1
- package/dist/control/segmented-control/index.d.ts +10 -3
- package/dist/control/segmented-control/index.d.ts.map +1 -1
- package/dist/control/segmented-control/index.js.map +1 -1
- package/dist/control/select/index.d.ts +17 -0
- package/dist/control/select/index.d.ts.map +1 -1
- package/dist/control/select/index.js +4 -0
- package/dist/control/select/index.js.map +1 -1
- package/dist/control/switch/index.d.ts +16 -2
- package/dist/control/switch/index.d.ts.map +1 -1
- package/dist/control/switch/index.js +4 -0
- package/dist/control/switch/index.js.map +1 -1
- package/dist/control/switch/style.d.ts.map +1 -1
- package/dist/control/switch/style.js +1 -3
- package/dist/control/switch/style.js.map +1 -1
- package/dist/control/text-area/index.d.ts +15 -0
- package/dist/control/text-area/index.d.ts.map +1 -1
- package/dist/control/text-area/index.js +4 -0
- package/dist/control/text-area/index.js.map +1 -1
- package/dist/control/text-input/index.d.ts +23 -1
- package/dist/control/text-input/index.d.ts.map +1 -1
- package/dist/control/text-input/index.js +4 -0
- package/dist/control/text-input/index.js.map +1 -1
- package/dist/control/use-modal-dialog/index.d.ts +7 -1
- package/dist/control/use-modal-dialog/index.d.ts.map +1 -1
- package/dist/control/use-modal-dialog/index.js +5 -0
- package/dist/control/use-modal-dialog/index.js.map +1 -1
- package/dist/theme/theme.d.ts +2 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +5 -0
- package/dist/theme/theme.js.map +1 -1
- package/docs/component/card-row.md +11 -12
- package/docs/component/card.md +4 -5
- package/docs/control/confirm-modal.md +1 -2
- package/docs/control/segmented-control.md +2 -2
- package/docs/corners.md +4 -4
- package/docs/philosophy.md +1 -1
- package/docs/theme.md +1 -0
- package/docs/tokens.md +1 -0
- package/package.json +1 -1
- package/src/component/card/index.tsx +14 -2
- package/src/component/card/style.ts +3 -1
- package/src/component/card-divider/index.tsx +15 -6
- package/src/component/card-row/index.tsx +6 -0
- package/src/component/card-row/style.ts +1 -1
- package/src/component/collapsible-section/index.tsx +8 -2
- package/src/component/empty-state/index.tsx +2 -2
- package/src/component/index.ts +10 -10
- package/src/component/meta-line/index.tsx +1 -1
- package/src/component/metadata/index.tsx +6 -1
- package/src/component/metadata-list/index.tsx +13 -2
- package/src/component/nav-desktop/index.tsx +6 -2
- package/src/component/nav-mobile/index.tsx +11 -3
- package/src/component/nav-types.ts +4 -0
- package/src/component/page/index.tsx +11 -1
- package/src/component/progress-indicator/index.tsx +4 -1
- package/src/component/tag/index.tsx +6 -3
- package/src/component/theme-setting/index.tsx +7 -0
- package/src/component/top-fade/index.tsx +8 -2
- package/src/control/action-menu-list/index.tsx +7 -0
- package/src/control/back-button/index.tsx +9 -1
- package/src/control/button/index.tsx +39 -5
- package/src/control/chips-input/index.tsx +20 -3
- package/src/control/confirm-modal/index.tsx +15 -1
- package/src/control/date-time-input/index.tsx +4 -0
- package/src/control/field-list/index.tsx +20 -1
- package/src/control/index.ts +39 -22
- package/src/control/number-input/index.tsx +12 -0
- package/src/control/page-actions-bar/index.tsx +16 -2
- package/src/control/page-actions-menu/index.tsx +6 -1
- package/src/control/page-footer-actions/index.tsx +16 -1
- package/src/control/popover/index.tsx +6 -2
- package/src/control/segmented-control/index.tsx +10 -3
- package/src/control/select/index.tsx +17 -1
- package/src/control/switch/index.tsx +17 -1
- package/src/control/switch/style.ts +1 -3
- package/src/control/text-area/index.tsx +15 -0
- package/src/control/text-input/index.tsx +25 -0
- package/src/control/use-modal-dialog/index.ts +11 -2
- package/src/theme/theme.ts +7 -0
|
@@ -2,13 +2,15 @@ import { ComponentType } from 'react';
|
|
|
2
2
|
import { IconProps } from '../../icon/index.js';
|
|
3
3
|
import { ButtonTypeValue, ButtonRadiusValue } from './style.js';
|
|
4
4
|
type ButtonVariant = {
|
|
5
|
+
/** Red treatment for destructive actions. Mutually exclusive with `success`. */
|
|
5
6
|
danger?: boolean;
|
|
6
7
|
success?: false | undefined;
|
|
7
8
|
} | {
|
|
9
|
+
/** Green treatment. Mutually exclusive with `danger`. */
|
|
8
10
|
success?: boolean;
|
|
9
11
|
danger?: false | undefined;
|
|
10
12
|
};
|
|
11
|
-
type ButtonProps = React.PropsWithChildren<{
|
|
13
|
+
export type ButtonProps = React.PropsWithChildren<{
|
|
12
14
|
/**
|
|
13
15
|
* Accessible name when the visible children are not distinguishing enough
|
|
14
16
|
* on their own — several "Remove" buttons in a list, each belonging to a
|
|
@@ -17,20 +19,47 @@ type ButtonProps = React.PropsWithChildren<{
|
|
|
17
19
|
ariaLabel?: string;
|
|
18
20
|
/** For a disclosure button: the state of what it controls, and its id. */
|
|
19
21
|
ariaExpanded?: boolean;
|
|
22
|
+
/** For a disclosure button: the id of the element it controls. */
|
|
20
23
|
ariaControls?: string;
|
|
24
|
+
/** Extra class; win specificity with `'&&'` in your sheet, never `!important`. */
|
|
21
25
|
className?: string;
|
|
26
|
+
/** Greys the button out and blocks clicks. */
|
|
22
27
|
disabled?: boolean;
|
|
28
|
+
/** Id of the `<form>` to submit, for a `submit` button outside its form. */
|
|
23
29
|
form?: string;
|
|
30
|
+
/** Shows a spinner in place of the icons and blocks clicks. */
|
|
24
31
|
loading?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Applies to the default (div) mode only. In submit mode it is ignored:
|
|
34
|
+
* native form submission (driven by the associated <form>) fires instead.
|
|
35
|
+
* Receives no event.
|
|
36
|
+
*/
|
|
25
37
|
onClick?: () => void;
|
|
38
|
+
/** Icon component shown before the label (`prefix={SearchIcon}`), not an element. */
|
|
26
39
|
prefix?: ComponentType<IconProps>;
|
|
40
|
+
/** The surface the button sits on: `'background'` (default), `'card'`, `'inset'`, `'modal'`. */
|
|
27
41
|
radius?: ButtonRadiusValue;
|
|
42
|
+
/**
|
|
43
|
+
* Render a native `<button type="submit">`; also spins while the enclosing
|
|
44
|
+
* form action is pending. `onClick` is then ignored.
|
|
45
|
+
*/
|
|
28
46
|
submit?: boolean;
|
|
47
|
+
/** Icon component shown after the label (`suffix={ChevronIcon}`), not an element. */
|
|
29
48
|
suffix?: ComponentType<IconProps>;
|
|
49
|
+
/** Passed through; forced to -1 while disabled or loading (div mode). */
|
|
30
50
|
tabIndex?: number;
|
|
51
|
+
/** Native tooltip; passed through. */
|
|
31
52
|
title?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Visual variant (`'default'`, `'primary'`, `'text'`, `'link'`, `'dashed'`),
|
|
55
|
+
* not the HTML `type`. Use `submit` for a submit button.
|
|
56
|
+
*/
|
|
32
57
|
type?: ButtonTypeValue;
|
|
33
58
|
} & ButtonVariant>;
|
|
59
|
+
/**
|
|
60
|
+
* Clickable action with a visual variant, optional icons, and a loading state.
|
|
61
|
+
* Renders a `<div role="button">`, or a native submit `<button>` when `submit` is set.
|
|
62
|
+
*/
|
|
34
63
|
export declare const Button: ({ ariaLabel, ariaExpanded, ariaControls, children, className: classNameProp, danger, disabled, form, loading, onClick, prefix: Prefix, radius, submit, suffix: Suffix, success, tabIndex, title, type, }: ButtonProps) => import("react").JSX.Element;
|
|
35
64
|
export type { ButtonTypeValue, ButtonRadiusValue };
|
|
36
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/button/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAe,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAc,eAAe,EAAgB,iBAAiB,EAAY,MAAM,YAAY,CAAC;AAEpG,KAAK,aAAa,GACd;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/button/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAe,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAc,eAAe,EAAgB,iBAAiB,EAAY,MAAM,YAAY,CAAC;AAEpG,KAAK,aAAa,GACd;IACE,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC7B,GACD;IACE,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAC/C;IACE;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qFAAqF;IACrF,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,gGAAgG;IAChG,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,qFAAqF;IACrF,MAAM,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;CACxB,GAAG,aAAa,CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,6MAmBhB,WAAW,gCAwFb,CAAC;AAEF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -4,6 +4,10 @@ import { useCallback } from 'react';
|
|
|
4
4
|
import { useFormStatus } from 'react-dom';
|
|
5
5
|
import { SpinnerIcon } from '../../icon/index.js';
|
|
6
6
|
import { ButtonType, ButtonRadius, useStyle } from './style.js';
|
|
7
|
+
/**
|
|
8
|
+
* Clickable action with a visual variant, optional icons, and a loading state.
|
|
9
|
+
* Renders a `<div role="button">`, or a native submit `<button>` when `submit` is set.
|
|
10
|
+
*/
|
|
7
11
|
export const Button = ({ ariaLabel, ariaExpanded, ariaControls, children, className: classNameProp, danger = false, disabled = false, form, loading = false, onClick = () => { }, prefix: Prefix, radius = ButtonRadius.Background, submit = false, suffix: Suffix, success = false, tabIndex, title, type = ButtonType.Default, }) => {
|
|
8
12
|
const styles = useStyle();
|
|
9
13
|
// Safe to call unconditionally: outside a <form> action, useFormStatus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/button/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAiB,WAAW,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAa,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAmB,YAAY,EAAqB,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/button/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAiB,WAAW,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAa,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAmB,YAAY,EAAqB,QAAQ,EAAE,MAAM,YAAY,CAAC;AA+DpG;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,SAAS,EAAE,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Z,YAAY,mBACZ,cAAc,IAAI,SAAS,EAC1C,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EACxC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,KAAK,aAEX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,IACP,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { ComponentType, useCallback } from 'react';\nimport { useFormStatus } from 'react-dom';\n\nimport { IconProps, SpinnerIcon } from '../../icon/index.js';\nimport { ButtonType, ButtonTypeValue, ButtonRadius, ButtonRadiusValue, useStyle } from './style.js';\n\ntype ButtonVariant =\n | {\n /** Red treatment for destructive actions. Mutually exclusive with `success`. */\n danger?: boolean;\n success?: false | undefined;\n }\n | {\n /** Green treatment. Mutually exclusive with `danger`. */\n success?: boolean;\n danger?: false | undefined;\n };\n\nexport type ButtonProps = React.PropsWithChildren<\n {\n /**\n * Accessible name when the visible children are not distinguishing enough\n * on their own — several \"Remove\" buttons in a list, each belonging to a\n * different row.\n */\n ariaLabel?: string;\n /** For a disclosure button: the state of what it controls, and its id. */\n ariaExpanded?: boolean;\n /** For a disclosure button: the id of the element it controls. */\n ariaControls?: string;\n /** Extra class; win specificity with `'&&'` in your sheet, never `!important`. */\n className?: string;\n /** Greys the button out and blocks clicks. */\n disabled?: boolean;\n /** Id of the `<form>` to submit, for a `submit` button outside its form. */\n form?: string;\n /** Shows a spinner in place of the icons and blocks clicks. */\n loading?: boolean;\n /**\n * Applies to the default (div) mode only. In submit mode it is ignored:\n * native form submission (driven by the associated <form>) fires instead.\n * Receives no event.\n */\n onClick?: () => void;\n /** Icon component shown before the label (`prefix={SearchIcon}`), not an element. */\n prefix?: ComponentType<IconProps>;\n /** The surface the button sits on: `'background'` (default), `'card'`, `'inset'`, `'modal'`. */\n radius?: ButtonRadiusValue;\n /**\n * Render a native `<button type=\"submit\">`; also spins while the enclosing\n * form action is pending. `onClick` is then ignored.\n */\n submit?: boolean;\n /** Icon component shown after the label (`suffix={ChevronIcon}`), not an element. */\n suffix?: ComponentType<IconProps>;\n /** Passed through; forced to -1 while disabled or loading (div mode). */\n tabIndex?: number;\n /** Native tooltip; passed through. */\n title?: string;\n /**\n * Visual variant (`'default'`, `'primary'`, `'text'`, `'link'`, `'dashed'`),\n * not the HTML `type`. Use `submit` for a submit button.\n */\n type?: ButtonTypeValue;\n } & ButtonVariant\n>;\n\n/**\n * Clickable action with a visual variant, optional icons, and a loading state.\n * Renders a `<div role=\"button\">`, or a native submit `<button>` when `submit` is set.\n */\nexport const Button = ({\n ariaLabel,\n ariaExpanded,\n ariaControls,\n children,\n className: classNameProp,\n danger = false,\n disabled = false,\n form,\n loading = false,\n onClick = () => {},\n prefix: Prefix,\n radius = ButtonRadius.Background as ButtonRadiusValue,\n submit = false,\n suffix: Suffix,\n success = false,\n tabIndex,\n title,\n type = ButtonType.Default as ButtonTypeValue,\n}: ButtonProps) => {\n const styles = useStyle();\n // Safe to call unconditionally: outside a <form> action, useFormStatus\n // returns a default { pending: false }. Only consulted in submit mode.\n const { pending } = useFormStatus();\n const busy = loading || (submit && pending);\n\n const className = cx(\n styles.root,\n styles[type],\n styles[radius],\n { [styles.danger]: danger },\n { [styles.loading]: busy },\n { [styles.disabled]: disabled },\n { [styles.success]: success },\n classNameProp\n );\n\n const loadingIcon = busy ? <SpinnerIcon className={styles.spinner} /> : null;\n const prefixIcon = !busy && Prefix ? <Prefix className={styles.buttonIcon} /> : null;\n const suffixIcon = !busy && Suffix ? <Suffix className={styles.buttonIcon} /> : null;\n\n // Hoisted above the `if (submit)` branch (rather than left after the early\n // return, as in the naive version) so hook order never depends on the\n // `submit` branch taken during a given render. Both hooks are cheap and\n // simply unused in submit mode.\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (!disabled && !busy) {\n event.stopPropagation();\n onClick();\n }\n },\n [busy, disabled, onClick]\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!disabled && !busy && (event.key === 'Enter' || event.key === ' ')) {\n event.stopPropagation();\n onClick();\n }\n },\n [busy, disabled, onClick]\n );\n\n if (submit) {\n return (\n <button\n type=\"submit\"\n aria-label={ariaLabel}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n form={form}\n className={className}\n disabled={disabled || busy}\n title={title}\n tabIndex={tabIndex}\n >\n {loadingIcon}\n {prefixIcon}\n {children}\n {suffixIcon}\n </button>\n );\n }\n\n const nonInteractive = disabled || busy;\n\n return (\n <div\n role=\"button\"\n aria-label={ariaLabel}\n aria-expanded={ariaExpanded}\n aria-controls={ariaControls}\n aria-disabled={nonInteractive || undefined}\n tabIndex={nonInteractive ? -1 : tabIndex}\n className={className}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n title={title}\n >\n {loadingIcon}\n {prefixIcon}\n {children}\n {suffixIcon}\n </div>\n );\n};\n\nexport type { ButtonTypeValue, ButtonRadiusValue };\n"]}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import type { Theme } from '../../theme/index.js';
|
|
2
|
+
/** A chip colour family: a key of `theme.color.chip` (`'subject'`, `'user'`, `'neutral'`, …). */
|
|
2
3
|
export type ChipColor = keyof Theme['color']['chip'];
|
|
3
4
|
export type ChipsInputProps = {
|
|
5
|
+
/** The chips. Controlled: you own the array. */
|
|
4
6
|
value: string[];
|
|
7
|
+
/** Suggestion pool (pass `[]` for none); chosen values are hidden, matching is case-insensitive substring. */
|
|
5
8
|
suggestions: string[];
|
|
9
|
+
/** Receives the whole new array, not an event. */
|
|
6
10
|
onChange: (values: string[]) => void;
|
|
11
|
+
/** Shown only while there are no chips. */
|
|
7
12
|
placeholder?: string;
|
|
13
|
+
/** Enter or Tab adds the typed text as a chip (default `true`); `false` allows suggestions only. */
|
|
8
14
|
allowCustom?: boolean;
|
|
15
|
+
/** Disables typing and the chip remove buttons. */
|
|
9
16
|
disabled?: boolean;
|
|
17
|
+
/** Field label. Ignored in the default `block` layout; set `layout` to show it. */
|
|
10
18
|
label?: string;
|
|
19
|
+
/** `'block'` (default) is the bare box with no label; `'horizontal'`/`'vertical'` add the label row. */
|
|
11
20
|
layout?: 'horizontal' | 'vertical' | 'block';
|
|
21
|
+
/** Set on the text input only: form data gets the half-typed text, not the chips. */
|
|
12
22
|
name?: string;
|
|
23
|
+
/** Chip colour family from `theme.color.chip`. Default `'subject'`. */
|
|
13
24
|
chipColor?: ChipColor;
|
|
25
|
+
/**
|
|
26
|
+
* Matches the control's height to a standard form input (removes the roomier
|
|
27
|
+
* min-height and slims the chips). Used when the field sits inline with other
|
|
28
|
+
* inputs, e.g. the device form; the book-edit Subjects field leaves it off.
|
|
29
|
+
*/
|
|
14
30
|
dense?: boolean;
|
|
15
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Controlled tag field: chips inside an input box with a filtered suggestion
|
|
34
|
+
* dropdown. Enter adds a chip; Backspace on an empty field removes the last.
|
|
35
|
+
*/
|
|
16
36
|
export declare const ChipsInput: ({ value, suggestions, onChange, placeholder, allowCustom, disabled, label, layout, name, chipColor, dense, }: ChipsInputProps) => import("react").JSX.Element;
|
|
17
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/chips-input/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD,MAAM,MAAM,SAAS,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,C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gCAgIjB,CAAC"}
|
|
@@ -4,6 +4,10 @@ import { useId, useRef, useState } from 'react';
|
|
|
4
4
|
import { XIcon } from '../../icon/index.js';
|
|
5
5
|
import { Popover } from '../popover/index.js';
|
|
6
6
|
import { useStyle } from './style.js';
|
|
7
|
+
/**
|
|
8
|
+
* Controlled tag field: chips inside an input box with a filtered suggestion
|
|
9
|
+
* dropdown. Enter adds a chip; Backspace on an empty field removes the last.
|
|
10
|
+
*/
|
|
7
11
|
export const ChipsInput = ({ value, suggestions, onChange, placeholder, allowCustom = true, disabled = false, label, layout = 'block', name, chipColor = 'subject', dense = false, }) => {
|
|
8
12
|
const style = useStyle({ chipColor, dense });
|
|
9
13
|
// A per-instance DOM id keeps label/input association unique even when two
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/chips-input/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAqBtC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,MAAM,GAAG,OAAO,EAChB,IAAI,EACJ,SAAS,GAAG,SAAS,EACrB,KAAK,GAAG,KAAK,GACG,EAAE,EAAE;IACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,2EAA2E;IAC3E,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM,OAAO,GAAG,KAAK,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,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;4BAC9B,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC1B,CAAC,EACD,SAAS,EAAE,aAAa,GACxB,IACE,EACN,KAAC,OAAO,IAAC,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,YAAY,YACvD,aAAI,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAC,SAAS,YAC1C,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACjC,aAEE,IAAI,EAAC,QAAQ,mBACE,CAAC,KAAK,gBAAgB,EACrC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,gBAAgB,EAAE,CAAC,EAClF,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;4BACjB,CAAC,CAAC,cAAc,EAAE,CAAC;4BACnB,OAAO,CAAC,CAAC,CAAC,CAAC;wBACb,CAAC,YAEA,CAAC,IATG,CAAC,CAUH,CACN,CAAC,GACC,GACG,IACN,CACP,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAC3C,gBAAO,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,YAC5C,KAAK,GACA,EACP,OAAO,IACJ,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { useId, useRef, useState } from 'react';\n\nimport { XIcon } from '../../icon/index.js';\nimport type { Theme } from '../../theme/index.js';\nimport { Popover } from '../popover/index.js';\nimport { useStyle } from './style.js';\n\nexport type ChipColor = keyof Theme['color']['chip'];\n\nexport type ChipsInputProps = {\n value: string[];\n suggestions: string[];\n onChange: (values: string[]) => void;\n placeholder?: string;\n allowCustom?: boolean;\n disabled?: boolean;\n label?: string;\n layout?: 'horizontal' | 'vertical' | 'block';\n name?: string;\n chipColor?: ChipColor;\n // Matches the control's height to a standard form input (removes the roomier\n // min-height and slims the chips). Used when the field sits inline with other\n // inputs, e.g. the device form; the book-edit Subjects field leaves it off.\n dense?: boolean;\n};\n\nexport const ChipsInput = ({\n value,\n suggestions,\n onChange,\n placeholder,\n allowCustom = true,\n disabled = false,\n label,\n layout = 'block',\n name,\n chipColor = 'subject',\n dense = false,\n}: ChipsInputProps) => {\n const style = useStyle({ chipColor, dense });\n // A per-instance DOM id keeps label/input association unique even when two\n // forms with the same `name` mount at once (e.g. the create form plus a row\n // being edited on the device list). `name` stays form-data only.\n const inputId = useId();\n const [inputValue, setInputValue] = useState('');\n const [highlightedIndex, setHighlightedIndex] = useState(-1);\n const chipsContainerRef = useRef<HTMLDivElement>(null);\n\n const filteredSuggestions = suggestions.filter(\n (s) => !value.includes(s) && s.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n const showDropdown = !disabled && inputValue.length > 0 && filteredSuggestions.length > 0;\n\n function addChip(chip: string) {\n const trimmed = chip.trim();\n // Case-insensitive so a custom-typed chip can't duplicate an existing one\n // (or a suggestion) that differs only by letter case.\n if (!trimmed || value.some((v) => v.toLowerCase() === trimmed.toLowerCase())) return;\n onChange([...value, trimmed]);\n setInputValue('');\n setHighlightedIndex(-1);\n }\n\n function removeChip(chip: string) {\n if (disabled) return;\n onChange(value.filter((s) => s !== chip));\n }\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n if (disabled) return;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlightedIndex((prev) => (prev < filteredSuggestions.length - 1 ? prev + 1 : prev));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : -1));\n } else if (e.key === 'Enter' || e.key === 'Tab') {\n const highlighted = filteredSuggestions[highlightedIndex];\n if (highlightedIndex >= 0 && highlighted) {\n e.preventDefault();\n addChip(highlighted);\n } else if (allowCustom && inputValue.trim()) {\n e.preventDefault();\n addChip(inputValue);\n } else if (e.key === 'Enter' && inputValue.trim()) {\n // Nothing to add (e.g. allowCustom={false} with an unmatched token) but\n // the user is mid-token: swallow the Enter so it doesn't bubble up and\n // submit the surrounding form. Tab still falls through to move focus.\n e.preventDefault();\n }\n } else if (e.key === 'Backspace' && inputValue === '' && value.length > 0) {\n removeChip(value[value.length - 1]!);\n }\n }\n\n const control = (\n <div className={style.controlRoot}>\n <div\n ref={chipsContainerRef}\n className={cx(style.chipsContainer, { [style.disabled]: disabled })}\n >\n {value.map((chip) => (\n <span key={chip} className={style.chip}>\n {chip}\n <button\n type=\"button\"\n className={style.chipRemove}\n aria-label={`Remove ${chip}`}\n disabled={disabled}\n tabIndex={disabled ? -1 : 0}\n onClick={disabled ? undefined : () => removeChip(chip)}\n >\n <XIcon />\n </button>\n </span>\n ))}\n <input\n id={inputId}\n name={name}\n autoComplete=\"off\"\n className={style.input}\n type=\"text\"\n value={inputValue}\n placeholder={value.length === 0 ? placeholder : ''}\n disabled={disabled}\n onChange={(e) => {\n setInputValue(e.target.value);\n setHighlightedIndex(-1);\n }}\n onKeyDown={handleKeyDown}\n />\n </div>\n <Popover anchorRef={chipsContainerRef} open={showDropdown}>\n <ul className={style.dropdown} role=\"listbox\">\n {filteredSuggestions.map((s, i) => (\n <li\n key={s}\n role=\"option\"\n aria-selected={i === highlightedIndex}\n className={cx(style.dropdownItem, { [style.highlighted]: i === highlightedIndex })}\n onMouseDown={(e) => {\n e.preventDefault();\n addChip(s);\n }}\n >\n {s}\n </li>\n ))}\n </ul>\n </Popover>\n </div>\n );\n\n if (!label || layout === 'block') {\n return control;\n }\n\n return (\n <div className={cx(style.root, style[layout])}>\n <label className={style.label} htmlFor={inputId}>\n {label}\n </label>\n {control}\n </div>\n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EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,gBAAgB,EAAE,CAAC,EAClF,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;4BACjB,CAAC,CAAC,cAAc,EAAE,CAAC;4BACnB,OAAO,CAAC,CAAC,CAAC,CAAC;wBACb,CAAC,YAEA,CAAC,IATG,CAAC,CAUH,CACN,CAAC,GACC,GACG,IACN,CACP,CAAC;IAEF,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,aAC3C,gBAAO,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,YAC5C,KAAK,GACA,EACP,OAAO,IACJ,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { useId, useRef, useState } from 'react';\n\nimport { XIcon } from '../../icon/index.js';\nimport type { Theme } from '../../theme/index.js';\nimport { Popover } from '../popover/index.js';\nimport { useStyle } from './style.js';\n\n/** A chip colour family: a key of `theme.color.chip` (`'subject'`, `'user'`, `'neutral'`, …). */\nexport type ChipColor = keyof Theme['color']['chip'];\n\nexport type ChipsInputProps = {\n /** The chips. Controlled: you own the array. */\n value: string[];\n /** Suggestion pool (pass `[]` for none); chosen values are hidden, matching is case-insensitive substring. */\n suggestions: string[];\n /** Receives the whole new array, not an event. */\n onChange: (values: string[]) => void;\n /** Shown only while there are no chips. */\n placeholder?: string;\n /** Enter or Tab adds the typed text as a chip (default `true`); `false` allows suggestions only. */\n allowCustom?: boolean;\n /** Disables typing and the chip remove buttons. */\n disabled?: boolean;\n /** Field label. Ignored in the default `block` layout; set `layout` to show it. */\n label?: string;\n /** `'block'` (default) is the bare box with no label; `'horizontal'`/`'vertical'` add the label row. */\n layout?: 'horizontal' | 'vertical' | 'block';\n /** Set on the text input only: form data gets the half-typed text, not the chips. */\n name?: string;\n /** Chip colour family from `theme.color.chip`. Default `'subject'`. */\n chipColor?: ChipColor;\n /**\n * Matches the control's height to a standard form input (removes the roomier\n * min-height and slims the chips). Used when the field sits inline with other\n * inputs, e.g. the device form; the book-edit Subjects field leaves it off.\n */\n dense?: boolean;\n};\n\n/**\n * Controlled tag field: chips inside an input box with a filtered suggestion\n * dropdown. Enter adds a chip; Backspace on an empty field removes the last.\n */\nexport const ChipsInput = ({\n value,\n suggestions,\n onChange,\n placeholder,\n allowCustom = true,\n disabled = false,\n label,\n layout = 'block',\n name,\n chipColor = 'subject',\n dense = false,\n}: ChipsInputProps) => {\n const style = useStyle({ chipColor, dense });\n // A per-instance DOM id keeps label/input association unique even when two\n // forms with the same `name` mount at once (e.g. the create form plus a row\n // being edited on the device list). `name` stays form-data only.\n const inputId = useId();\n const [inputValue, setInputValue] = useState('');\n const [highlightedIndex, setHighlightedIndex] = useState(-1);\n const chipsContainerRef = useRef<HTMLDivElement>(null);\n\n const filteredSuggestions = suggestions.filter(\n (s) => !value.includes(s) && s.toLowerCase().includes(inputValue.toLowerCase())\n );\n\n const showDropdown = !disabled && inputValue.length > 0 && filteredSuggestions.length > 0;\n\n function addChip(chip: string) {\n const trimmed = chip.trim();\n // Case-insensitive so a custom-typed chip can't duplicate an existing one\n // (or a suggestion) that differs only by letter case.\n if (!trimmed || value.some((v) => v.toLowerCase() === trimmed.toLowerCase())) return;\n onChange([...value, trimmed]);\n setInputValue('');\n setHighlightedIndex(-1);\n }\n\n function removeChip(chip: string) {\n if (disabled) return;\n onChange(value.filter((s) => s !== chip));\n }\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n if (disabled) return;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlightedIndex((prev) => (prev < filteredSuggestions.length - 1 ? prev + 1 : prev));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlightedIndex((prev) => (prev > 0 ? prev - 1 : -1));\n } else if (e.key === 'Enter' || e.key === 'Tab') {\n const highlighted = filteredSuggestions[highlightedIndex];\n if (highlightedIndex >= 0 && highlighted) {\n e.preventDefault();\n addChip(highlighted);\n } else if (allowCustom && inputValue.trim()) {\n e.preventDefault();\n addChip(inputValue);\n } else if (e.key === 'Enter' && inputValue.trim()) {\n // Nothing to add (e.g. allowCustom={false} with an unmatched token) but\n // the user is mid-token: swallow the Enter so it doesn't bubble up and\n // submit the surrounding form. Tab still falls through to move focus.\n e.preventDefault();\n }\n } else if (e.key === 'Backspace' && inputValue === '' && value.length > 0) {\n removeChip(value[value.length - 1]!);\n }\n }\n\n const control = (\n <div className={style.controlRoot}>\n <div\n ref={chipsContainerRef}\n className={cx(style.chipsContainer, { [style.disabled]: disabled })}\n >\n {value.map((chip) => (\n <span key={chip} className={style.chip}>\n {chip}\n <button\n type=\"button\"\n className={style.chipRemove}\n aria-label={`Remove ${chip}`}\n disabled={disabled}\n tabIndex={disabled ? -1 : 0}\n onClick={disabled ? undefined : () => removeChip(chip)}\n >\n <XIcon />\n </button>\n </span>\n ))}\n <input\n id={inputId}\n name={name}\n autoComplete=\"off\"\n className={style.input}\n type=\"text\"\n value={inputValue}\n placeholder={value.length === 0 ? placeholder : ''}\n disabled={disabled}\n onChange={(e) => {\n setInputValue(e.target.value);\n setHighlightedIndex(-1);\n }}\n onKeyDown={handleKeyDown}\n />\n </div>\n <Popover anchorRef={chipsContainerRef} open={showDropdown}>\n <ul className={style.dropdown} role=\"listbox\">\n {filteredSuggestions.map((s, i) => (\n <li\n key={s}\n role=\"option\"\n aria-selected={i === highlightedIndex}\n className={cx(style.dropdownItem, { [style.highlighted]: i === highlightedIndex })}\n onMouseDown={(e) => {\n e.preventDefault();\n addChip(s);\n }}\n >\n {s}\n </li>\n ))}\n </ul>\n </Popover>\n </div>\n );\n\n if (!label || layout === 'block') {\n return control;\n }\n\n return (\n <div className={cx(style.root, style[layout])}>\n <label className={style.label} htmlFor={inputId}>\n {label}\n </label>\n {control}\n </div>\n );\n};\n"]}
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { IconProps } from '../../icon/index.js';
|
|
3
|
-
type ConfirmModalProps = PropsWithChildren<{
|
|
3
|
+
export type ConfirmModalProps = PropsWithChildren<{
|
|
4
|
+
/** Cancel button label. Default `'Cancel'`. */
|
|
4
5
|
cancelText?: string;
|
|
6
|
+
/** Disables only the Confirm button (e.g. until a checkbox is ticked). */
|
|
5
7
|
confirmDisabled?: boolean;
|
|
8
|
+
/** Confirm button label. Default `'Confirm'`. */
|
|
6
9
|
confirmText?: string;
|
|
10
|
+
/** Red Confirm button; also tints `icon` red. */
|
|
7
11
|
danger?: boolean;
|
|
12
|
+
/** Icon component shown before the title (`icon={AlertOctagonIcon}`), not an element. */
|
|
8
13
|
icon?: React.ComponentType<IconProps>;
|
|
14
|
+
/** Controls visibility. Keep the modal mounted and toggle this. */
|
|
9
15
|
isOpen?: boolean;
|
|
16
|
+
/** Spinner on Confirm; disables both buttons and blocks Escape and backdrop dismissal. */
|
|
10
17
|
loading?: boolean;
|
|
18
|
+
/** Called by Cancel, Escape, and a backdrop click; receives no event. Close the modal here. */
|
|
11
19
|
onCancel?: () => void;
|
|
20
|
+
/** Receives no event and does not close the modal: set `isOpen` to `false` yourself. */
|
|
12
21
|
onConfirm?: () => void;
|
|
22
|
+
/** Header text. Default `'Confirm action'`. */
|
|
13
23
|
title?: string;
|
|
14
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Ready-made yes/no modal on a native `<dialog>`: title, body (`children`),
|
|
27
|
+
* Cancel and Confirm. Always mounted; controlled by `isOpen`.
|
|
28
|
+
*/
|
|
15
29
|
export declare function ConfirmModal({ cancelText, children, confirmDisabled, confirmText, danger, icon: Icon, isOpen, loading, onCancel, onConfirm, title, }: ConfirmModalProps): import("react").JSX.Element;
|
|
16
|
-
export {};
|
|
17
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/confirm-modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/confirm-modal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;IAChD,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yFAAyF;IACzF,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACtC,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,UAAqB,EACrB,QAAQ,EACR,eAAuB,EACvB,WAAuB,EACvB,MAAc,EACd,IAAI,EAAE,IAAI,EACV,MAAc,EACd,OAAe,EACf,QAAmB,EACnB,SAAoB,EACpB,KAAwB,GACzB,EAAE,iBAAiB,+BA8CnB"}
|
|
@@ -3,6 +3,10 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import { Button } from '../button/index.js';
|
|
4
4
|
import { useModalDialog } from '../use-modal-dialog/index.js';
|
|
5
5
|
import { useStyle } from './style.js';
|
|
6
|
+
/**
|
|
7
|
+
* Ready-made yes/no modal on a native `<dialog>`: title, body (`children`),
|
|
8
|
+
* Cancel and Confirm. Always mounted; controlled by `isOpen`.
|
|
9
|
+
*/
|
|
6
10
|
export function ConfirmModal({ cancelText = 'Cancel', children, confirmDisabled = false, confirmText = 'Confirm', danger = false, icon: Icon, isOpen = false, loading = false, onCancel = () => { }, onConfirm = () => { }, title = 'Confirm action', }) {
|
|
7
11
|
const styles = useStyle();
|
|
8
12
|
const handleCancel = useCallback(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/confirm-modal/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/confirm-modal/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,WAAW,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAyBtC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,UAAU,GAAG,QAAQ,EACrB,QAAQ,EACR,eAAe,GAAG,KAAK,EACvB,WAAW,GAAG,SAAS,EAC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S,EAAE,MAAM,CAAC,MAAM,aAC3B,KAAC,MAAM,IAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,OAAO,YACzE,UAAU,GACJ,EACT,KAAC,MAAM,IACL,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,eAAe,IAAI,OAAO,EACpC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAC,SAAS,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAC,OAAO,YAEb,WAAW,GACL,IACL,IACF,GACC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import { PropsWithChildren, useCallback } from 'react';\n\nimport { IconProps } from '../../icon/index.js';\nimport { Button } from '../button/index.js';\nimport { useModalDialog } from '../use-modal-dialog/index.js';\nimport { useStyle } from './style.js';\n\nexport type ConfirmModalProps = PropsWithChildren<{\n /** Cancel button label. Default `'Cancel'`. */\n cancelText?: string;\n /** Disables only the Confirm button (e.g. until a checkbox is ticked). */\n confirmDisabled?: boolean;\n /** Confirm button label. Default `'Confirm'`. */\n confirmText?: string;\n /** Red Confirm button; also tints `icon` red. */\n danger?: boolean;\n /** Icon component shown before the title (`icon={AlertOctagonIcon}`), not an element. */\n icon?: React.ComponentType<IconProps>;\n /** Controls visibility. Keep the modal mounted and toggle this. */\n isOpen?: boolean;\n /** Spinner on Confirm; disables both buttons and blocks Escape and backdrop dismissal. */\n loading?: boolean;\n /** Called by Cancel, Escape, and a backdrop click; receives no event. Close the modal here. */\n onCancel?: () => void;\n /** Receives no event and does not close the modal: set `isOpen` to `false` yourself. */\n onConfirm?: () => void;\n /** Header text. Default `'Confirm action'`. */\n title?: string;\n}>;\n\n/**\n * Ready-made yes/no modal on a native `<dialog>`: title, body (`children`),\n * Cancel and Confirm. Always mounted; controlled by `isOpen`.\n */\nexport function ConfirmModal({\n cancelText = 'Cancel',\n children,\n confirmDisabled = false,\n confirmText = 'Confirm',\n danger = false,\n icon: Icon,\n isOpen = false,\n loading = false,\n onCancel = () => {},\n onConfirm = () => {},\n title = 'Confirm action',\n}: ConfirmModalProps) {\n const styles = useStyle();\n\n const handleCancel = useCallback(() => {\n onCancel();\n }, [onCancel]);\n const handleConfirm = useCallback(() => {\n onConfirm();\n }, [onConfirm]);\n // Escape dismisses the modal, except while the action is in flight — the\n // Cancel button is disabled then, so Escape is gated to match.\n const modalRef = useModalDialog(isOpen, handleCancel, !loading);\n const handleClickDialog = useCallback((event: React.MouseEvent) => {\n event.stopPropagation();\n }, []);\n\n return (\n <dialog ref={modalRef} className={styles.root} onClick={handleClickDialog}>\n <div className={styles.dialog} onClick={handleClickDialog}>\n <div className={styles.header}>\n {Icon && (\n <div className={styles.icon}>\n <Icon className={danger ? styles.iconDanger : undefined} />\n </div>\n )}\n {title}\n </div>\n <div className={styles.body}>{children}</div>\n <div className={styles.footer}>\n <Button onClick={handleCancel} disabled={loading} type=\"text\" radius=\"modal\">\n {cancelText}\n </Button>\n <Button\n onClick={handleConfirm}\n disabled={confirmDisabled || loading}\n loading={loading}\n type=\"primary\"\n danger={danger}\n radius=\"modal\"\n >\n {confirmText}\n </Button>\n </div>\n </div>\n </dialog>\n );\n}\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export type DateTimeInputProps = {
|
|
2
|
+
/** Linked to the date input; the time input is labelled `${label} time` (or `Time`). */
|
|
2
3
|
label?: string;
|
|
4
|
+
/** Default `'horizontal'`; `horizontal`/`vertical` paint a card-header row. */
|
|
3
5
|
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
6
|
+
/** The date input's `name`; the time input is `${name}Time`. Form data holds two fields, not the composed value. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** Receives the recomposed ISO string (time in UTC), or `undefined` when the date is cleared; not an event. */
|
|
5
9
|
onChange?: (newValue: string | undefined) => void;
|
|
6
10
|
/**
|
|
7
11
|
* An ISO 8601 date string as the server stores it: a bare date, a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/date-time-input/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,8CAMvB,kBAAkB,gCA8DpB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/date-time-input/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC9C,oHAAoH;IACpH,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,8CAMvB,kBAAkB,gCA8DpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/date-time-input/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,cAAc,EAA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C,QAAQ,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,EAC3B,IAAI,EAAE,GAAG,IAAI,MAAM,EACnB,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,KAAK,CAAC,IAAI,GACjB,IACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import cx from 'classnames';\nimport { useCallback, useId, useState } from 'react';\n\nimport { composeIsoDate, splitIsoDate } from './iso-date.js';\nimport { useStyle } from './style.js';\n\nexport type DateTimeInputProps = {\n /** Linked to the date input; the time input is labelled `${label} time` (or `Time`). */\n label?: string;\n /** Default `'horizontal'`; `horizontal`/`vertical` paint a card-header row. */\n layout?: 'horizontal' | 'vertical' | 'inline';\n /** The date input's `name`; the time input is `${name}Time`. Form data holds two fields, not the composed value. */\n name: string;\n /** Receives the recomposed ISO string (time in UTC), or `undefined` when the date is cleared; not an event. */\n onChange?: (newValue: string | undefined) => void;\n /**\n * An ISO 8601 date string as the server stores it: a bare date, a\n * timestamp, or a lower-precision year / year-month. `undefined` and `''`\n * both mean \"no date\".\n */\n value: string | undefined;\n};\n\n/**\n * A date with an optional time, edited through the browser's native pickers\n * so the user never has to know the stored format. The two inputs are\n * independent: a time can only be set once there is a date, and clearing the\n * date takes the time with it. `onChange` receives the recomposed string\n * (`composeIsoDate`), or `undefined` when the date is cleared.\n */\nexport const DateTimeInput = ({\n label,\n layout = 'horizontal',\n name,\n onChange = () => {},\n value,\n}: DateTimeInputProps) => {\n const style = useStyle();\n const dateId = useId();\n\n const [parts, setParts] = useState(() => splitIsoDate(value));\n const [prevValue, setPrevValue] = useState(value);\n if (value !== prevValue) {\n setPrevValue(value);\n setParts(splitIsoDate(value));\n }\n\n const update = useCallback(\n (next: { date: string; time: string }) => {\n setParts(next);\n onChange(composeIsoDate(next.date, next.time));\n },\n [onChange]\n );\n\n const handleDateChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const date = event.target.value;\n update({ date, time: date === '' ? '' : parts.time });\n },\n [parts.time, update]\n );\n\n const handleTimeChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n update({ date: parts.date, time: event.target.value });\n },\n [parts.date, update]\n );\n\n return (\n <div className={cx(style.root, style[layout])}>\n {label && (\n <label className={style.label} htmlFor={dateId}>\n {label}\n </label>\n )}\n <div className={style.inputContainer}>\n <input\n className={cx(style.input, style.date)}\n id={dateId}\n name={name}\n onChange={handleDateChange}\n type=\"date\"\n value={parts.date}\n />\n <input\n aria-label={label ? `${label} time` : 'Time'}\n className={cx(style.input, style.time)}\n disabled={parts.date === ''}\n name={`${name}Time`}\n onChange={handleTimeChange}\n type=\"time\"\n value={parts.time}\n />\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One column of a `FieldList`: a `TextInput` (`'text'`) or `NumberInput`
|
|
3
|
+
* (`'number'`) per row, keyed by `key`. `validate` receives the raw text.
|
|
4
|
+
*/
|
|
1
5
|
export type ColumnDescriptor = {
|
|
2
6
|
type: 'text';
|
|
3
7
|
key: string;
|
|
@@ -9,18 +13,32 @@ export type ColumnDescriptor = {
|
|
|
9
13
|
placeholder?: string;
|
|
10
14
|
validate?: (v: string) => boolean;
|
|
11
15
|
};
|
|
16
|
+
/** A `FieldList` row: a stable unique `_key` plus one value per column key. */
|
|
12
17
|
export type FieldRow = {
|
|
13
18
|
_key: string;
|
|
14
19
|
} & Record<string, string | number | undefined>;
|
|
15
|
-
type FieldListProps = {
|
|
20
|
+
export type FieldListProps = {
|
|
21
|
+
/** Text of the dashed add button ("Add identifier"). */
|
|
16
22
|
addLabel: string;
|
|
23
|
+
/** One input per column per row; inputs have no labels, so use `placeholder`. */
|
|
17
24
|
columns: ColumnDescriptor[];
|
|
25
|
+
/** Append a row with a fresh `_key`. Receives no event. */
|
|
18
26
|
onAdd: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* `string` from a text column, `number` from a number column, `undefined`
|
|
29
|
+
* when emptied. Not called while that field's `validate` fails.
|
|
30
|
+
*/
|
|
19
31
|
onChange: (rowKey: string, fieldKey: string, newValue: string | number | undefined) => void;
|
|
32
|
+
/** Remove the row with this `_key`. */
|
|
20
33
|
onRemove: (rowKey: string) => void;
|
|
34
|
+
/** `fieldName` is `${rowKey}.${columnKey}`. Fires only when validity flips. */
|
|
21
35
|
onValidChange?: (fieldName: string, isValid: boolean) => void;
|
|
36
|
+
/** `_key` must be stable and unique: it is the React key and part of each input's `name`. */
|
|
22
37
|
rows: FieldRow[];
|
|
23
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Editable list of rows, each a set of text/number inputs with a remove button,
|
|
41
|
+
* plus a dashed add button. Belongs in a `Card` body (add button is `radius="card"`).
|
|
42
|
+
*/
|
|
24
43
|
export declare const FieldList: ({ addLabel, columns, onAdd, onChange, onRemove, onValidChange, rows, }: FieldListProps) => import("react").JSX.Element;
|
|
25
|
-
export {};
|
|
26
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/control/field-list/index.tsx"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,GACtF;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,G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QAAQ,EAAE,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,2EAQnB,cAAc,gCA+ChB,CAAC"}
|
|
@@ -4,6 +4,10 @@ import { Button } from '../button/index.js';
|
|
|
4
4
|
import { NumberInput } from '../number-input/index.js';
|
|
5
5
|
import { TextInput } from '../text-input/index.js';
|
|
6
6
|
import { useStyle } from './style.js';
|
|
7
|
+
/**
|
|
8
|
+
* Editable list of rows, each a set of text/number inputs with a remove button,
|
|
9
|
+
* plus a dashed add button. Belongs in a `Card` body (add button is `radius="card"`).
|
|
10
|
+
*/
|
|
7
11
|
export const FieldList = ({ addLabel, columns, onAdd, onChange, onRemove, onValidChange, rows, }) => {
|
|
8
12
|
const style = useStyle();
|
|
9
13
|
return (_jsxs("div", { className: style.root, children: [_jsx("div", { className: style.rowContainer, children: rows.map((row) => (_jsxs("div", { className: style.row, children: [_jsx("div", { className: style.fields, children: columns.map((col) => (_jsx("div", { className: style.field, children: col.type === 'text' ? (_jsx(TextInput, { name: `${row._key}.${col.key}`, placeholder: col.placeholder, validate: col.validate, value: row[col.key] !== undefined ? String(row[col.key]) : '', onChange: (newValue) => onChange(row._key, col.key, newValue), onValidChange: onValidChange })) : (_jsx(NumberInput, { label: undefined, name: `${row._key}.${col.key}`, placeholder: col.placeholder, validate: col.validate, value: typeof row[col.key] === 'number' ? row[col.key] : undefined, onChange: (newValue) => onChange(row._key, col.key, newValue), onValidChange: onValidChange })) }, col.key))) }), _jsx(Button, { type: "link", danger: true, title: "Remove row", onClick: () => onRemove(row._key), children: _jsx(RowRemoveIcon, { height: 20, width: 20, strokeWidth: 2 }) })] }, row._key))) }), _jsx(Button, { type: "dashed", onClick: onAdd, radius: "card", children: addLabel })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/control/field-list/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC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AC,IAAI,CAgClC,CACP,CAAC,GACE,EACN,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,YAChD,QAAQ,GACF,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { RowRemoveIcon } from '../../icon/index.js';\nimport { Button } from '../button/index.js';\nimport { NumberInput } from '../number-input/index.js';\nimport { TextInput } from '../text-input/index.js';\nimport { useStyle } from './style.js';\n\n/**\n * One column of a `FieldList`: a `TextInput` (`'text'`) or `NumberInput`\n * (`'number'`) per row, keyed by `key`. `validate` receives the raw text.\n */\nexport type ColumnDescriptor =\n | { type: 'text'; key: string; placeholder?: string; validate?: (v: string) => boolean }\n | { type: 'number'; key: string; placeholder?: string; validate?: (v: string) => boolean };\n\n/** A `FieldList` row: a stable unique `_key` plus one value per column key. */\nexport type FieldRow = { _key: string } & Record<string, string | number | undefined>;\n\nexport type FieldListProps = {\n /** Text of the dashed add button (\"Add identifier\"). */\n addLabel: string;\n /** One input per column per row; inputs have no labels, so use `placeholder`. */\n columns: ColumnDescriptor[];\n /** Append a row with a fresh `_key`. Receives no event. */\n onAdd: () => void;\n /**\n * `string` from a text column, `number` from a number column, `undefined`\n * when emptied. Not called while that field's `validate` fails.\n */\n onChange: (rowKey: string, fieldKey: string, newValue: string | number | undefined) => void;\n /** Remove the row with this `_key`. */\n onRemove: (rowKey: string) => void;\n /** `fieldName` is `${rowKey}.${columnKey}`. Fires only when validity flips. */\n onValidChange?: (fieldName: string, isValid: boolean) => void;\n /** `_key` must be stable and unique: it is the React key and part of each input's `name`. */\n rows: FieldRow[];\n};\n\n/**\n * Editable list of rows, each a set of text/number inputs with a remove button,\n * plus a dashed add button. Belongs in a `Card` body (add button is `radius=\"card\"`).\n */\nexport const FieldList = ({\n addLabel,\n columns,\n onAdd,\n onChange,\n onRemove,\n onValidChange,\n rows,\n}: FieldListProps) => {\n const style = useStyle();\n\n return (\n <div className={style.root}>\n <div className={style.rowContainer}>\n {rows.map((row) => (\n <div className={style.row} key={row._key}>\n <div className={style.fields}>\n {columns.map((col) => (\n <div className={style.field} key={col.key}>\n {col.type === 'text' ? (\n <TextInput\n name={`${row._key}.${col.key}`}\n placeholder={col.placeholder}\n validate={col.validate}\n value={row[col.key] !== undefined ? String(row[col.key]) : ''}\n onChange={(newValue) => onChange(row._key, col.key, newValue)}\n onValidChange={onValidChange}\n />\n ) : (\n <NumberInput\n label={undefined}\n name={`${row._key}.${col.key}`}\n placeholder={col.placeholder}\n validate={col.validate}\n value={\n typeof row[col.key] === 'number' ? (row[col.key] as number) : undefined\n }\n onChange={(newValue) => onChange(row._key, col.key, newValue)}\n onValidChange={onValidChange}\n />\n )}\n </div>\n ))}\n </div>\n <Button type=\"link\" danger title=\"Remove row\" onClick={() => onRemove(row._key)}>\n <RowRemoveIcon height={20} width={20} strokeWidth={2} />\n </Button>\n </div>\n ))}\n </div>\n <Button type=\"dashed\" onClick={onAdd} radius=\"card\">\n {addLabel}\n </Button>\n </div>\n );\n};\n"]}
|
package/dist/control/index.d.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
export { BackButton } from './back-button/index.js';
|
|
2
|
-
export { Button } from './button/index.js';
|
|
3
|
-
export { ChipsInput } from './chips-input/index.js';
|
|
4
|
-
export { ConfirmModal } from './confirm-modal/index.js';
|
|
5
|
-
export { DateTimeInput } from './date-time-input/index.js';
|
|
6
|
-
export { FieldList } from './field-list/index.js';
|
|
7
|
-
export { NumberInput } from './number-input/index.js';
|
|
8
|
-
export { PageActionsBar } from './page-actions-bar/index.js';
|
|
9
|
-
export { PageActionsMenu } from './page-actions-menu/index.js';
|
|
10
|
-
export { PageFooterActions } from './page-footer-actions/index.js';
|
|
11
|
-
export { Popover } from './popover/index.js';
|
|
12
|
-
export { Select } from './select/index.js';
|
|
13
|
-
export { SegmentedControl } from './segmented-control/index.js';
|
|
14
|
-
export { Switch } from './switch/index.js';
|
|
15
|
-
export { TextArea } from './text-area/index.js';
|
|
16
|
-
export { TextInput } from './text-input/index.js';
|
|
1
|
+
export { BackButton, type BackButtonProps } from './back-button/index.js';
|
|
2
|
+
export { Button, type ButtonProps, type ButtonRadiusValue, type ButtonTypeValue, } from './button/index.js';
|
|
3
|
+
export { ChipsInput, type ChipColor, type ChipsInputProps } from './chips-input/index.js';
|
|
4
|
+
export { ConfirmModal, type ConfirmModalProps } from './confirm-modal/index.js';
|
|
5
|
+
export { DateTimeInput, type DateTimeInputProps } from './date-time-input/index.js';
|
|
6
|
+
export { FieldList, type ColumnDescriptor, type FieldListProps, type FieldRow, } from './field-list/index.js';
|
|
7
|
+
export { NumberInput, type NumberInputProps } from './number-input/index.js';
|
|
8
|
+
export { PageActionsBar, type PageActionsBarProps } from './page-actions-bar/index.js';
|
|
9
|
+
export { PageActionsMenu, type PageActionIntentProps, type PageActionItem, type PageActionsMenuProps, } from './page-actions-menu/index.js';
|
|
10
|
+
export { PageFooterActions, type FooterAction, type PageFooterActionsProps, } from './page-footer-actions/index.js';
|
|
11
|
+
export { Popover, type PopoverProps } from './popover/index.js';
|
|
12
|
+
export { Select, type SelectOption, type SelectProps } from './select/index.js';
|
|
13
|
+
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption, } from './segmented-control/index.js';
|
|
14
|
+
export { Switch, type SwitchProps, type SwitchRadiusValue } from './switch/index.js';
|
|
15
|
+
export { TextArea, type TextAreaProps } from './text-area/index.js';
|
|
16
|
+
export { TextInput, type TextInputAction, type TextInputProps } from './text-input/index.js';
|
|
17
17
|
export { useModalDialog } from './use-modal-dialog/index.js';
|
|
18
|
-
export type { DateTimeInputProps } from './date-time-input/index.js';
|
|
19
|
-
export type { ColumnDescriptor, FieldRow } from './field-list/index.js';
|
|
20
|
-
export type { FooterAction } from './page-footer-actions/index.js';
|
|
21
|
-
export type { PageActionIntentProps, PageActionItem } from './page-actions-menu/index.js';
|
|
22
|
-
export type { SelectOption, SelectProps } from './select/index.js';
|
|
23
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,MAAM,EACN,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,QAAQ,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/control/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { BackButton } from './back-button/index.js';
|
|
2
|
-
export { Button } from './button/index.js';
|
|
2
|
+
export { Button, } from './button/index.js';
|
|
3
3
|
export { ChipsInput } from './chips-input/index.js';
|
|
4
4
|
export { ConfirmModal } from './confirm-modal/index.js';
|
|
5
5
|
export { DateTimeInput } from './date-time-input/index.js';
|
|
6
|
-
export { FieldList } from './field-list/index.js';
|
|
6
|
+
export { FieldList, } from './field-list/index.js';
|
|
7
7
|
export { NumberInput } from './number-input/index.js';
|
|
8
8
|
export { PageActionsBar } from './page-actions-bar/index.js';
|
|
9
|
-
export { PageActionsMenu } from './page-actions-menu/index.js';
|
|
10
|
-
export { PageFooterActions } from './page-footer-actions/index.js';
|
|
9
|
+
export { PageActionsMenu, } from './page-actions-menu/index.js';
|
|
10
|
+
export { PageFooterActions, } from './page-footer-actions/index.js';
|
|
11
11
|
export { Popover } from './popover/index.js';
|
|
12
12
|
export { Select } from './select/index.js';
|
|
13
|
-
export { SegmentedControl } from './segmented-control/index.js';
|
|
13
|
+
export { SegmentedControl, } from './segmented-control/index.js';
|
|
14
14
|
export { Switch } from './switch/index.js';
|
|
15
15
|
export { TextArea } from './text-area/index.js';
|
|
16
16
|
export { TextInput } from './text-input/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EACL,MAAM,GAIP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAwC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAA0B,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,aAAa,EAA2B,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,SAAS,GAIV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAyB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,cAAc,EAA4B,MAAM,6BAA6B,CAAC;AACvF,OAAO,EACL,eAAe,GAIhB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAqB,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAuC,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,gBAAgB,GAGjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAA4C,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAsB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,SAAS,EAA6C,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["export { BackButton, type BackButtonProps } from './back-button/index.js';\nexport {\n Button,\n type ButtonProps,\n type ButtonRadiusValue,\n type ButtonTypeValue,\n} from './button/index.js';\nexport { ChipsInput, type ChipColor, type ChipsInputProps } from './chips-input/index.js';\nexport { ConfirmModal, type ConfirmModalProps } from './confirm-modal/index.js';\nexport { DateTimeInput, type DateTimeInputProps } from './date-time-input/index.js';\nexport {\n FieldList,\n type ColumnDescriptor,\n type FieldListProps,\n type FieldRow,\n} from './field-list/index.js';\nexport { NumberInput, type NumberInputProps } from './number-input/index.js';\nexport { PageActionsBar, type PageActionsBarProps } from './page-actions-bar/index.js';\nexport {\n PageActionsMenu,\n type PageActionIntentProps,\n type PageActionItem,\n type PageActionsMenuProps,\n} from './page-actions-menu/index.js';\nexport {\n PageFooterActions,\n type FooterAction,\n type PageFooterActionsProps,\n} from './page-footer-actions/index.js';\nexport { Popover, type PopoverProps } from './popover/index.js';\nexport { Select, type SelectOption, type SelectProps } from './select/index.js';\nexport {\n SegmentedControl,\n type SegmentedControlProps,\n type SegmentedOption,\n} from './segmented-control/index.js';\nexport { Switch, type SwitchProps, type SwitchRadiusValue } from './switch/index.js';\nexport { TextArea, type TextAreaProps } from './text-area/index.js';\nexport { TextInput, type TextInputAction, type TextInputProps } from './text-input/index.js';\nexport { useModalDialog } from './use-modal-dialog/index.js';\n"]}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
export type NumberInputProps = {
|
|
2
|
+
/** Required key: pass `label={undefined}` for none. Not linked to the input (no `htmlFor`). */
|
|
2
3
|
label: string | undefined;
|
|
4
|
+
/** Default `'horizontal'`; `horizontal`/`vertical` paint a card-header row. */
|
|
3
5
|
layout?: 'horizontal' | 'vertical' | 'inline';
|
|
6
|
+
/** The input's `name` and the key passed to `onValidChange`. */
|
|
4
7
|
name: string;
|
|
8
|
+
/** Receives `parseFloat(text)`, or `undefined` when emptied; not called while `validate` fails. */
|
|
5
9
|
onChange?: (newValue: number | undefined) => void;
|
|
10
|
+
/** Called with `name` and the new validity; fires only when validity flips. */
|
|
6
11
|
onValidChange?: (fieldName: string, newValid: boolean) => void;
|
|
12
|
+
/** Placeholder text for the input. */
|
|
7
13
|
placeholder?: string;
|
|
14
|
+
/** Receives the raw text. Replacing it drops the default empty-or-numeric check, so include one. */
|
|
8
15
|
validate?: (newValue: string) => boolean;
|
|
16
|
+
/** Current number. Re-syncs into the field only when the prop changes. */
|
|
9
17
|
value: number | undefined;
|
|
10
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Text field that reports a number: a plain `<input>` (no `type="number"`)
|
|
21
|
+
* that calls `onChange` with the parsed value while the text validates.
|
|
22
|
+
*/
|
|
11
23
|
export declare const NumberInput: ({ label, layout, name, onChange, onValidChange, placeholder, validate, value, }: NumberInputProps) => import("react").JSX.Element;
|
|
12
24
|
//# sourceMappingURL=index.d.ts.map
|