@manakind/ui-core 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/button/button.css +16 -10
- package/dist/button/button.d.ts +3 -2
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.js +4 -4
- package/dist/button/button.js.map +1 -1
- package/dist/button/icon-button.d.ts +6 -1
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/menu/index.d.ts +2 -2
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/index.js.map +1 -1
- package/dist/menu/menu.css +53 -0
- package/dist/menu/menu.d.ts +32 -1
- package/dist/menu/menu.d.ts.map +1 -1
- package/dist/menu/menu.js +23 -1
- package/dist/menu/menu.js.map +1 -1
- package/dist/reorder-control/index.d.ts +2 -0
- package/dist/reorder-control/index.d.ts.map +1 -0
- package/dist/reorder-control/index.js +2 -0
- package/dist/reorder-control/index.js.map +1 -0
- package/dist/reorder-control/reorder-control.css +44 -0
- package/dist/reorder-control/reorder-control.css.d.ts +2 -0
- package/dist/reorder-control/reorder-control.d.ts +68 -0
- package/dist/reorder-control/reorder-control.d.ts.map +1 -0
- package/dist/reorder-control/reorder-control.js +57 -0
- package/dist/reorder-control/reorder-control.js.map +1 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -65,11 +65,12 @@ separately, so an app can load only what it renders.
|
|
|
65
65
|
| `@manakind/ui-core/dialog` | `Dialog` + `DialogClose` |
|
|
66
66
|
| `@manakind/ui-core/icon` | `Icon` |
|
|
67
67
|
| `@manakind/ui-core/illustration` | `Illustration` + `illustrationPaint` |
|
|
68
|
-
| `@manakind/ui-core/menu` | `Menu` |
|
|
68
|
+
| `@manakind/ui-core/menu` | `Menu`, `MenuTrigger` |
|
|
69
69
|
| `@manakind/ui-core/popover` | `Popover` |
|
|
70
70
|
| `@manakind/ui-core/checkbox` | `Checkbox` |
|
|
71
71
|
| `@manakind/ui-core/date-input` | `DateInput` |
|
|
72
72
|
| `@manakind/ui-core/progress` | `Progress` |
|
|
73
|
+
| `@manakind/ui-core/reorder-control` | `ReorderControl` |
|
|
73
74
|
| `@manakind/ui-core/segment-group` | `SegmentGroup` |
|
|
74
75
|
| `@manakind/ui-core/select` | `Select` |
|
|
75
76
|
| `@manakind/ui-core/switch` | `Switch` |
|
|
@@ -88,6 +89,7 @@ separately, so an app can load only what it renders.
|
|
|
88
89
|
| `@manakind/ui-core/css/checkbox` | Checkbox structural CSS |
|
|
89
90
|
| `@manakind/ui-core/css/date-input` | DateInput structural CSS |
|
|
90
91
|
| `@manakind/ui-core/css/progress` | Progress structural CSS |
|
|
92
|
+
| `@manakind/ui-core/css/reorder-control` | ReorderControl structural CSS; its handle and input also need `css/button`, `css/icon` and `css/field` |
|
|
91
93
|
| `@manakind/ui-core/css/segment-group` | SegmentGroup structural CSS |
|
|
92
94
|
| `@manakind/ui-core/css/select` | Select structural CSS |
|
|
93
95
|
| `@manakind/ui-core/css/switch` | Switch structural CSS |
|
package/dist/button/button.css
CHANGED
|
@@ -128,29 +128,35 @@
|
|
|
128
128
|
|
|
129
129
|
&.ds-button--icon-only {
|
|
130
130
|
aspect-ratio: 1;
|
|
131
|
+
padding: 0;
|
|
131
132
|
|
|
132
133
|
/*
|
|
133
134
|
* A circle at every size, rather than inheriting the button radius.
|
|
134
|
-
* `--ds-button-radius` is a fixed 16px while icon buttons are 32/
|
|
135
|
-
* square, so 16px
|
|
136
|
-
* above it — the shape
|
|
137
|
-
* the size grew. A percentage tracks the box instead of fighting it.
|
|
135
|
+
* `--ds-button-radius` is a fixed 16px while icon buttons are 32/40/48px
|
|
136
|
+
* square, so 16px would be exactly half at `sm` and less than half
|
|
137
|
+
* above it — the shape would drift from a circle to a rounded rectangle
|
|
138
|
+
* as the size grew. A percentage tracks the box instead of fighting it.
|
|
138
139
|
*/
|
|
139
140
|
border-radius: 50%;
|
|
140
141
|
|
|
142
|
+
/*
|
|
143
|
+
* The square is its own ramp, not the text button's height: the icon
|
|
144
|
+
* is the label, so it takes the icon scale's step for the size and the
|
|
145
|
+
* square keeps the same inset around it at every size.
|
|
146
|
+
*/
|
|
141
147
|
&.ds-button--sm {
|
|
142
|
-
|
|
143
|
-
min-width: var(--ds-button-size-sm-
|
|
148
|
+
min-height: var(--ds-button-size-sm-icon-only-size);
|
|
149
|
+
min-width: var(--ds-button-size-sm-icon-only-size);
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
&.ds-button--md {
|
|
147
|
-
|
|
148
|
-
min-width: var(--ds-button-size-md-
|
|
153
|
+
min-height: var(--ds-button-size-md-icon-only-size);
|
|
154
|
+
min-width: var(--ds-button-size-md-icon-only-size);
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
&.ds-button--lg {
|
|
152
|
-
|
|
153
|
-
min-width: var(--ds-button-size-lg-
|
|
158
|
+
min-height: var(--ds-button-size-lg-icon-only-size);
|
|
159
|
+
min-width: var(--ds-button-size-lg-icon-only-size);
|
|
154
160
|
}
|
|
155
161
|
}
|
|
156
162
|
|
package/dist/button/button.d.ts
CHANGED
|
@@ -12,8 +12,9 @@ interface ButtonOwnProps {
|
|
|
12
12
|
/**
|
|
13
13
|
* Decorative icon rendered before the label.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* The icon sits beside text, so it is always the `sm` step of the icon
|
|
16
|
+
* scale whatever the button size, and it inherits the button's text
|
|
17
|
+
* color via `currentColor`. The icon is
|
|
17
18
|
* always rendered as decorative — the accessible name comes from the
|
|
18
19
|
* button's children.
|
|
19
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":"AAAA,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M,CAAC,EAAE,SAAS,CAAC,CAAC;AAEzE,UAAU,mBAAoB,SAAQ,cAAc,EAAE,cAAc;IAClE,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,UAAU,kBAAmB,SAAQ,cAAc;IACjD;;;OAGG;IACH,OAAO,EAAE,IAAI,CAAC;IACd;;;;OAIG;IACH,QAAQ,EAAE,YAAY,CAAC;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACrE,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAuFnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,2CAExC"}
|
package/dist/button/button.js
CHANGED
|
@@ -4,8 +4,8 @@ import { cloneElement, Fragment, isValidElement, } from 'react';
|
|
|
4
4
|
import { Icon } from '../icon/icon';
|
|
5
5
|
import './button.css';
|
|
6
6
|
import { cx } from '../cx';
|
|
7
|
-
function ButtonContent({
|
|
8
|
-
return (_jsxs(_Fragment, { children: [loading && _jsx("span", { className: "ds-button__spinner", "aria-hidden": "true" }), leadingIcon && (_jsx(Icon, { source: leadingIcon, size:
|
|
7
|
+
function ButtonContent({ loading, leadingIcon, trailingIcon, children }) {
|
|
8
|
+
return (_jsxs(_Fragment, { children: [loading && _jsx("span", { className: "ds-button__spinner", "aria-hidden": "true" }), leadingIcon && (_jsx(Icon, { source: leadingIcon, size: "sm", decorative: true, className: "ds-button__icon ds-button__icon--leading" })), _jsx("span", { className: "ds-button__label", children: children }), trailingIcon && (_jsx(Icon, { source: trailingIcon, size: "sm", decorative: true, className: "ds-button__icon ds-button__icon--trailing" }))] }));
|
|
9
9
|
}
|
|
10
10
|
function classesFor(variant, size, className) {
|
|
11
11
|
return cx('ds-button', `ds-button--${variant}`, `ds-button--${size}`, className);
|
|
@@ -14,11 +14,11 @@ function ButtonAsChild({ variant = 'primary', size = 'md', leadingIcon, trailing
|
|
|
14
14
|
if (!isValidElement(children) || children.type === Fragment) {
|
|
15
15
|
throw new Error('Button asChild needs exactly one element as its child, such as <a> or a router link.');
|
|
16
16
|
}
|
|
17
|
-
const content = (_jsx(ButtonContent, {
|
|
17
|
+
const content = (_jsx(ButtonContent, { loading: false, leadingIcon: leadingIcon, trailingIcon: trailingIcon, children: children.props.children }));
|
|
18
18
|
return cloneElement(children, { className: cx(classesFor(variant, size, className), children.props.className) }, content);
|
|
19
19
|
}
|
|
20
20
|
function ButtonAsButton({ variant = 'primary', size = 'md', loading = false, disabled, leadingIcon, trailingIcon, className, children, ...props }) {
|
|
21
|
-
return (_jsx(ark.button, { disabled: disabled || loading, className: cx(classesFor(variant, size, className), loading && 'ds-button--loading'), ...props, children: _jsx(ButtonContent, {
|
|
21
|
+
return (_jsx(ark.button, { disabled: disabled || loading, className: cx(classesFor(variant, size, className), loading && 'ds-button--loading'), ...props, children: _jsx(ButtonContent, { loading: loading, leadingIcon: leadingIcon, trailingIcon: trailingIcon, children: children }) }));
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Shared base button for the Manakind design system.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../src/button/button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAEL,YAAY,EACZ,QAAQ,EACR,cAAc,GAGf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAoE3B,SAAS,aAAa,CAAC,EAAE,
|
|
1
|
+
{"version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vF,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,CACd,KAAC,aAAa,IAAC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,YAChF,QAAQ,CAAC,KAAK,CAAC,QAAQ,GACV,CACjB,CAAC;IAEF,OAAO,YAAY,CACjB,QAAQ,EACR,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,EACjF,OAAO,CACR,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,EACtB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACY;IACpB,OAAO,CACL,KAAC,GAAG,CAAC,MAAM,IACT,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAC7B,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO,IAAI,oBAAoB,CAAC,KAChF,KAAK,YAET,KAAC,aAAa,IAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,YAClF,QAAQ,GACK,GACL,CACd,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAC,aAAa,OAAK,KAAK,GAAI,CAAC,CAAC,CAAC,KAAC,cAAc,OAAK,KAAK,GAAI,CAAC;AACtF,CAAC"}
|
|
@@ -13,7 +13,12 @@ export interface IconButtonProps extends Omit<ComponentProps<typeof ark.button>,
|
|
|
13
13
|
'aria-label': string;
|
|
14
14
|
/** Visual style variant. Shared with {@link Button}. */
|
|
15
15
|
variant?: ButtonVariant;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Size preset. The icon is the label, so it takes the icon scale's step of
|
|
18
|
+
* the same name (16 / 24 / 32px) and the circle keeps the same inset around
|
|
19
|
+
* it (32 / 40 / 48px). The circle is taller than a text `Button` of the
|
|
20
|
+
* same size from `md` up.
|
|
21
|
+
*/
|
|
17
22
|
size?: ButtonSize;
|
|
18
23
|
/** Show loading spinner and disable interaction. */
|
|
19
24
|
loading?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,cAAc,CAAC;AAGtB,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;IACtF,kDAAkD;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,cAAc,CAAC;AAGtB,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;IACtF,kDAAkD;IAClD,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,OAAmB,EACnB,IAAW,EACX,OAAe,EACf,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,eAAe,2CAkBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../src/button/icon-button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAwB3B;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,IAAI,EACJ,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACQ;IAChB,OAAO,CACL,MAAC,GAAG,CAAC,MAAM,IACT,QAAQ,EAAE,QAAQ,IAAI,OAAO,EAC7B,SAAS,EAAE,EAAE,CACX,WAAW,EACX,sBAAsB,EACtB,cAAc,OAAO,EAAE,EACvB,cAAc,IAAI,EAAE,EACpB,OAAO,IAAI,oBAAoB,EAC/B,SAAS,CACV,KACG,KAAK,aAER,OAAO,IAAI,eAAM,SAAS,EAAC,oBAAoB,iBAAa,MAAM,GAAG,EACtE,KAAC,IAAI,IAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,QAAC,SAAS,EAAC,iBAAiB,GAAG,IAC9D,CACd,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,WAAW,IAAI,mBAAmB,EAClC,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/menu/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { MenuItem, MenuProps } from './menu';
|
|
2
|
-
export { Menu } from './menu';
|
|
1
|
+
export type { MenuItem, MenuProps, MenuTriggerProps } from './menu';
|
|
2
|
+
export { Menu, MenuTrigger } from './menu';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/menu/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/menu/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Menu } from './menu';
|
|
1
|
+
export { Menu, MenuTrigger } from './menu';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/menu/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/menu/menu.css
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
@layer components {
|
|
2
|
+
/*
|
|
3
|
+
* No border and no height of its own: the trigger is as tall as what it
|
|
4
|
+
* wraps, so a badge row keeps its measurements with or without a menu.
|
|
5
|
+
*/
|
|
6
|
+
.ds-menu__trigger {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: var(--ds-menu-trigger-gap);
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
overflow-wrap: anywhere;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0 var(--ds-menu-trigger-padding-inline);
|
|
14
|
+
border: 0;
|
|
15
|
+
border-radius: var(--ds-menu-trigger-radius);
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
color: inherit;
|
|
18
|
+
font: inherit;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: background-color 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
21
|
+
|
|
22
|
+
&:hover:not(:disabled),
|
|
23
|
+
&[data-state="open"] {
|
|
24
|
+
background-color: var(--ds-menu-trigger-bg-hover);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:focus-visible {
|
|
28
|
+
outline: 2px solid var(--ds-menu-focus-ring);
|
|
29
|
+
outline-offset: 3px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&:disabled {
|
|
33
|
+
opacity: var(--ds-opacity-disabled);
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
& .ds-menu__trigger-indicator {
|
|
38
|
+
color: var(--ds-menu-trigger-indicator-color);
|
|
39
|
+
transform: rotate(90deg);
|
|
40
|
+
transition: transform 150ms cubic-bezier(0, 0, 0.2, 1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&[data-state="open"] .ds-menu__trigger-indicator {
|
|
44
|
+
transform: rotate(-90deg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@media (prefers-reduced-motion: reduce) {
|
|
48
|
+
&,
|
|
49
|
+
& .ds-menu__trigger-indicator {
|
|
50
|
+
transition: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
2
55
|
/*
|
|
3
56
|
* The popup renders in a portal, so it is not a descendant of the trigger
|
|
4
57
|
* in the DOM and is styled at the top level, as Select's listbox is.
|
package/dist/menu/menu.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
1
|
+
import { type ComponentProps, type ReactElement } from 'react';
|
|
2
2
|
import { type IconSource } from '../icon/icon';
|
|
3
3
|
import './menu.css';
|
|
4
4
|
export interface MenuItem<V extends string = string> {
|
|
@@ -56,6 +56,37 @@ export interface MenuProps<V extends string = string> {
|
|
|
56
56
|
/** Extra class names on the menu's popup. */
|
|
57
57
|
className?: string;
|
|
58
58
|
}
|
|
59
|
+
export interface MenuTriggerProps extends Omit<ComponentProps<'button'>, 'type'> {
|
|
60
|
+
/**
|
|
61
|
+
* Glyph after the content saying it opens a menu. Must point RIGHT, as
|
|
62
|
+
* Select's indicator does: the trigger turns it down while closed and up
|
|
63
|
+
* while open, so one glyph serves both states.
|
|
64
|
+
*
|
|
65
|
+
* Defaults to a plain built-in chevron. Products override it with their
|
|
66
|
+
* own icon set.
|
|
67
|
+
*/
|
|
68
|
+
indicator?: IconSource;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A quiet, compact trigger for a `Menu`: the content it is given, then a
|
|
72
|
+
* chevron, with a fill on hover and while open, and the focus ring.
|
|
73
|
+
*
|
|
74
|
+
* For a trigger that wraps something with its own look, such as a status
|
|
75
|
+
* `Badge`, where a `Button` would add a second frame and its own height. It
|
|
76
|
+
* takes the size of its content and inherits its font and colour.
|
|
77
|
+
*
|
|
78
|
+
* ```tsx
|
|
79
|
+
* <Menu
|
|
80
|
+
* trigger={
|
|
81
|
+
* <MenuTrigger aria-label={`Status: ${status}. Change status`}>
|
|
82
|
+
* <Badge variant="info" appearance="plain">{status}</Badge>
|
|
83
|
+
* </MenuTrigger>
|
|
84
|
+
* }
|
|
85
|
+
* …
|
|
86
|
+
* />
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function MenuTrigger({ indicator, className, children, ...props }: MenuTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
59
90
|
/**
|
|
60
91
|
* A menu of mutually exclusive choices, opened from a trigger and applied
|
|
61
92
|
* at once, built on Ark UI's Menu.
|
package/dist/menu/menu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAA2B,MAAM,OAAO,CAAC;AAGxF,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,YAAY,CAAC;AAEpB,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACjD,0EAA0E;IAC1E,KAAK,EAAE,CAAC,CAAC;IACT,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IAClD;;;;;;;;;;OAUG;IACH,OAAO,EAAE,YAAY,CAAC;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB;;;;OAIG;IACH,KAAK,EAAE,CAAC,CAAC;IACT;;;;OAIG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAClC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC9E;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAwB,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,gBAAgB,2CAOlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAC9C,OAAO,EACP,KAAK,EACL,KAAK,EACL,KAAK,EACL,aAAa,EACb,aAAqB,EACrB,SAAS,GACV,EAAE,SAAS,CAAC,CAAC,CAAC,2CA6Cd"}
|
package/dist/menu/menu.js
CHANGED
|
@@ -3,10 +3,32 @@ import { Menu as ArkMenu } from '@ark-ui/react/menu';
|
|
|
3
3
|
import { Portal } from '@ark-ui/react/portal';
|
|
4
4
|
import { useCallback, useContext } from 'react';
|
|
5
5
|
import { cx } from '../cx';
|
|
6
|
-
import { Check } from '../fallback-glyphs';
|
|
6
|
+
import { Check, ChevronRight } from '../fallback-glyphs';
|
|
7
7
|
import { Icon } from '../icon/icon';
|
|
8
8
|
import { PortalContainerContext } from '../portal-container';
|
|
9
9
|
import './menu.css';
|
|
10
|
+
/**
|
|
11
|
+
* A quiet, compact trigger for a `Menu`: the content it is given, then a
|
|
12
|
+
* chevron, with a fill on hover and while open, and the focus ring.
|
|
13
|
+
*
|
|
14
|
+
* For a trigger that wraps something with its own look, such as a status
|
|
15
|
+
* `Badge`, where a `Button` would add a second frame and its own height. It
|
|
16
|
+
* takes the size of its content and inherits its font and colour.
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <Menu
|
|
20
|
+
* trigger={
|
|
21
|
+
* <MenuTrigger aria-label={`Status: ${status}. Change status`}>
|
|
22
|
+
* <Badge variant="info" appearance="plain">{status}</Badge>
|
|
23
|
+
* </MenuTrigger>
|
|
24
|
+
* }
|
|
25
|
+
* …
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function MenuTrigger({ indicator = ChevronRight, className, children, ...props }) {
|
|
30
|
+
return (_jsxs("button", { type: "button", className: cx('ds-menu__trigger', className), ...props, children: [children, _jsx(Icon, { source: indicator, size: "sm", decorative: true, className: "ds-menu__trigger-indicator" })] }));
|
|
31
|
+
}
|
|
10
32
|
/**
|
|
11
33
|
* A menu of mutually exclusive choices, opened from a trigger and applied
|
|
12
34
|
* at once, built on Ark UI's Menu.
|
package/dist/menu/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/menu/menu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAA0C,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxF,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,YAAY,CAAC;AAuEpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,SAAS,GAAG,YAAY,EACxB,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACS;IACjB,OAAO,CACL,kB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iB,aACpE,KAAC,OAAO,CAAC,cAAc,IAAC,SAAS,EAAC,gBAAgB,YAAE,KAAK,GAA0B,EAClF,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,MAAC,OAAO,CAAC,SAAS,IAEhB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,KAAK,EACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,SAAS,EAAC,eAAe,aAEzB,KAAC,OAAO,CAAC,QAAQ,cAAE,IAAI,CAAC,KAAK,GAAoB,EACjD,KAAC,OAAO,CAAC,aAAa,IAAC,SAAS,EAAC,yBAAyB,YACxD,KAAC,IAAI,IAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC9B,KATnB,IAAI,CAAC,KAAK,CAUG,CACrB,CAAC,IACqB,GACT,GACC,GACd,IACI,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reorder-control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reorder-control/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAIf,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-reorder-control {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: var(--ds-reorder-control-gap);
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
overflow-wrap: anywhere;
|
|
9
|
+
|
|
10
|
+
&.ds-reorder-control--vertical {
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* A pointer drag starts on the handle, so it says so, and claims the
|
|
16
|
+
* touch: with the browser's panning left on, a finger dragging the
|
|
17
|
+
* handle would scroll the page instead.
|
|
18
|
+
*/
|
|
19
|
+
& .ds-reorder-control__handle {
|
|
20
|
+
cursor: grab;
|
|
21
|
+
touch-action: none;
|
|
22
|
+
|
|
23
|
+
&:active:not(:disabled) {
|
|
24
|
+
cursor: grabbing;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&:disabled {
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* Raised over the small input's own padding and width, which are sized
|
|
34
|
+
* for words: this box holds only a few centred digits.
|
|
35
|
+
*/
|
|
36
|
+
& .ds-input.ds-reorder-control__input {
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
width: var(--ds-reorder-control-input-inline-size);
|
|
39
|
+
padding-inline: var(--ds-reorder-control-input-padding-inline);
|
|
40
|
+
font-variant-numeric: tabular-nums;
|
|
41
|
+
text-align: center;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import './reorder-control.css';
|
|
3
|
+
import type { IconSource } from '../icon/icon';
|
|
4
|
+
/**
|
|
5
|
+
* What a drag library puts on the handle: its ref, ARIA attributes and
|
|
6
|
+
* pointer and keyboard listeners. The handle's name, look and disabled state
|
|
7
|
+
* stay the control's own.
|
|
8
|
+
*/
|
|
9
|
+
export type ReorderHandleProps = Omit<ComponentProps<'button'>, 'children' | 'aria-label' | 'className' | 'disabled' | 'type'>;
|
|
10
|
+
/** How the handle and the position stand: side by side, or the handle above. */
|
|
11
|
+
export type ReorderControlOrientation = 'horizontal' | 'vertical';
|
|
12
|
+
export interface ReorderControlProps {
|
|
13
|
+
/** The item's name. The handle is named "Reorder …" and the input "Position of …". */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Where the item sits in its list, counting from 1. */
|
|
16
|
+
position: number;
|
|
17
|
+
/** How many items the list holds. A typed position is clamped to 1 through this. */
|
|
18
|
+
count: number;
|
|
19
|
+
/** Called with a typed position, once it is committed and only if it moved. */
|
|
20
|
+
onPositionChange: (position: number) => void;
|
|
21
|
+
/** Glyph on the drag handle, supplied by the product. */
|
|
22
|
+
handleIcon: IconSource;
|
|
23
|
+
/**
|
|
24
|
+
* Spread onto the drag handle, so a drag library can drive it: with
|
|
25
|
+
* dnd-kit, `{ ref: setActivatorNodeRef, ...attributes, ...listeners }`.
|
|
26
|
+
*/
|
|
27
|
+
handleProps?: ReorderHandleProps;
|
|
28
|
+
/**
|
|
29
|
+
* `horizontal` (default) sets the position after the handle, for a row of
|
|
30
|
+
* text. `vertical` stacks it under the handle, half as wide, for a column
|
|
31
|
+
* beside a card, where a phone's row has little width to give.
|
|
32
|
+
*/
|
|
33
|
+
orientation?: ReorderControlOrientation;
|
|
34
|
+
/**
|
|
35
|
+
* Disables the handle and the input. The drag library's own listeners and
|
|
36
|
+
* ARIA come in through `handleProps`, so give it the same flag (dnd-kit:
|
|
37
|
+
* `useSortable({ id, disabled })`), or a pointer can still start a drag.
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/** Extra class names appended after `ds-reorder-control`. */
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Two ways to move an item in an ordered list: a drag handle, then the
|
|
45
|
+
* item's position as a number to retype.
|
|
46
|
+
*
|
|
47
|
+
* The handle is a button the product's drag library drives through
|
|
48
|
+
* `handleProps`; the control only names it and gives it the grab cursor and
|
|
49
|
+
* `touch-action: none` a pointer drag needs. The input is the way that does
|
|
50
|
+
* not need a pointer or a drag library's keyboard mode: it keeps what is
|
|
51
|
+
* typed (digits only) as a draft, selects its text on focus so a new number
|
|
52
|
+
* replaces the old, and commits on Enter or blur. Enter only commits: in a
|
|
53
|
+
* form it does not also submit it. A committed position is
|
|
54
|
+
* clamped to the list and reported only if it moved; Escape drops the draft.
|
|
55
|
+
*
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <ReorderControl
|
|
58
|
+
* label={item.title}
|
|
59
|
+
* position={index + 1}
|
|
60
|
+
* count={items.length}
|
|
61
|
+
* onPositionChange={(position) => move(item.id, position)}
|
|
62
|
+
* handleIcon={DragHandle}
|
|
63
|
+
* handleProps={{ ref: setActivatorNodeRef, ...attributes, ...listeners }}
|
|
64
|
+
* />
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function ReorderControl({ label, position, count, onPositionChange, handleIcon, handleProps, orientation, disabled, className, }: ReorderControlProps): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
//# sourceMappingURL=reorder-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorder-control.d.ts","sourceRoot":"","sources":["../../src/reorder-control/reorder-control.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAgC,MAAM,OAAO,CAAC;AAC1E,OAAO,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,cAAc,CAAC,QAAQ,CAAC,EACxB,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAC9D,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,yBAAyB,GAAG,YAAY,GAAG,UAAU,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,yDAAyD;IACzD,UAAU,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAA0B,EAC1B,QAAgB,EAChB,SAAS,GACV,EAAE,mBAAmB,2CA+CrB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import './reorder-control.css';
|
|
4
|
+
import { IconButton } from '../button/icon-button';
|
|
5
|
+
import { cx } from '../cx';
|
|
6
|
+
import { Input } from '../field/input';
|
|
7
|
+
function clampPosition(value, count) {
|
|
8
|
+
return Math.min(Math.max(value, 1), count);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Two ways to move an item in an ordered list: a drag handle, then the
|
|
12
|
+
* item's position as a number to retype.
|
|
13
|
+
*
|
|
14
|
+
* The handle is a button the product's drag library drives through
|
|
15
|
+
* `handleProps`; the control only names it and gives it the grab cursor and
|
|
16
|
+
* `touch-action: none` a pointer drag needs. The input is the way that does
|
|
17
|
+
* not need a pointer or a drag library's keyboard mode: it keeps what is
|
|
18
|
+
* typed (digits only) as a draft, selects its text on focus so a new number
|
|
19
|
+
* replaces the old, and commits on Enter or blur. Enter only commits: in a
|
|
20
|
+
* form it does not also submit it. A committed position is
|
|
21
|
+
* clamped to the list and reported only if it moved; Escape drops the draft.
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <ReorderControl
|
|
25
|
+
* label={item.title}
|
|
26
|
+
* position={index + 1}
|
|
27
|
+
* count={items.length}
|
|
28
|
+
* onPositionChange={(position) => move(item.id, position)}
|
|
29
|
+
* handleIcon={DragHandle}
|
|
30
|
+
* handleProps={{ ref: setActivatorNodeRef, ...attributes, ...listeners }}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function ReorderControl({ label, position, count, onPositionChange, handleIcon, handleProps, orientation = 'horizontal', disabled = false, className, }) {
|
|
35
|
+
const [draft, setDraft] = useState(null);
|
|
36
|
+
const commit = () => {
|
|
37
|
+
if (draft === null)
|
|
38
|
+
return;
|
|
39
|
+
setDraft(null);
|
|
40
|
+
const typed = Number.parseInt(draft, 10);
|
|
41
|
+
if (Number.isNaN(typed))
|
|
42
|
+
return;
|
|
43
|
+
const next = clampPosition(typed, count);
|
|
44
|
+
if (next !== position)
|
|
45
|
+
onPositionChange(next);
|
|
46
|
+
};
|
|
47
|
+
const handleKeyDown = (event) => {
|
|
48
|
+
if (event.key === 'Enter') {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
commit();
|
|
51
|
+
}
|
|
52
|
+
if (event.key === 'Escape')
|
|
53
|
+
setDraft(null);
|
|
54
|
+
};
|
|
55
|
+
return (_jsxs("div", { className: cx('ds-reorder-control', `ds-reorder-control--${orientation}`, className), children: [_jsx(IconButton, { ...handleProps, type: "button", className: "ds-reorder-control__handle", variant: "tertiary", size: "sm", icon: handleIcon, "aria-label": `Reorder ${label}`, disabled: disabled }), _jsx(Input, { className: "ds-reorder-control__input", size: "sm", inputMode: "numeric", autoComplete: "off", "aria-label": `Position of ${label}`, value: draft ?? String(position), onChange: (event) => setDraft(event.target.value.replace(/\D/g, '')), onFocus: (event) => event.target.select(), onBlur: commit, onKeyDown: handleKeyDown, disabled: disabled })] }));
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=reorder-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reorder-control.js","sourceRoot":"","sources":["../../src/reorder-control/reorder-control.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA2C,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAgDvC,SAAS,aAAa,CAAC,KAAa,EAAE,KAAa;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,cAAc,CAAC,EAC7B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,WAAW,GAAG,YAAY,EAC1B,QAAQ,GAAG,KAAK,EAChB,SAAS,GACW;IACpB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAExD,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAAE,OAAO;QAChC,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzC,IAAI,IAAI,KAAK,QAAQ;YAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC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"0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"types": "./dist/progress/index.d.ts",
|
|
81
81
|
"import": "./dist/progress/index.js"
|
|
82
82
|
},
|
|
83
|
+
"./reorder-control": {
|
|
84
|
+
"types": "./dist/reorder-control/index.d.ts",
|
|
85
|
+
"import": "./dist/reorder-control/index.js"
|
|
86
|
+
},
|
|
83
87
|
"./segment-group": {
|
|
84
88
|
"types": "./dist/segment-group/index.d.ts",
|
|
85
89
|
"import": "./dist/segment-group/index.js"
|
|
@@ -152,6 +156,10 @@
|
|
|
152
156
|
"types": "./dist/progress/progress.css.d.ts",
|
|
153
157
|
"default": "./dist/progress/progress.css"
|
|
154
158
|
},
|
|
159
|
+
"./css/reorder-control": {
|
|
160
|
+
"types": "./dist/reorder-control/reorder-control.css.d.ts",
|
|
161
|
+
"default": "./dist/reorder-control/reorder-control.css"
|
|
162
|
+
},
|
|
155
163
|
"./css/segment-group": {
|
|
156
164
|
"types": "./dist/segment-group/segment-group.css.d.ts",
|
|
157
165
|
"default": "./dist/segment-group/segment-group.css"
|
|
@@ -187,7 +195,7 @@
|
|
|
187
195
|
},
|
|
188
196
|
"devDependencies": {
|
|
189
197
|
"@manakind/ds-config": "*",
|
|
190
|
-
"@manakind/manuia-tokens": "0.
|
|
198
|
+
"@manakind/manuia-tokens": "0.17.0",
|
|
191
199
|
"@testing-library/jest-dom": "^6.9.1",
|
|
192
200
|
"@testing-library/react": "^16.3.2",
|
|
193
201
|
"@testing-library/user-event": "^14.6.1",
|