@manakind/ui-core 0.8.0 → 0.10.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 CHANGED
@@ -68,6 +68,7 @@ separately, so an app can load only what it renders.
68
68
  | `@manakind/ui-core/progress` | `Progress` |
69
69
  | `@manakind/ui-core/select` | `Select` |
70
70
  | `@manakind/ui-core/switch` | `Switch` |
71
+ | `@manakind/ui-core/field` | `Field`, `Input`, `Textarea`, `useFieldControl` |
71
72
  | `@manakind/ui-core/tabs` | `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent` |
72
73
  | `@manakind/ui-core/css/alert` | Alert structural CSS; its icon also needs `css/icon` |
73
74
  | `@manakind/ui-core/css/badge` | Badge structural CSS |
@@ -80,6 +81,7 @@ separately, so an app can load only what it renders.
80
81
  | `@manakind/ui-core/css/progress` | Progress structural CSS |
81
82
  | `@manakind/ui-core/css/select` | Select structural CSS |
82
83
  | `@manakind/ui-core/css/switch` | Switch structural CSS |
84
+ | `@manakind/ui-core/css/field` | Field, Input and Textarea structural CSS |
83
85
  | `@manakind/ui-core/css/tabs` | Tabs structural CSS |
84
86
 
85
87
  Structural CSS is only half of what a component needs — it consumes `--ds-*` custom
@@ -25,8 +25,8 @@ export interface DialogProps {
25
25
  actions?: ReactNode;
26
26
  /**
27
27
  * The one element that opens the dialog, such as a `Button`. Focus returns
28
- * to it when the dialog closes. Leave it out to open the dialog with
29
- * `open` from elsewhere.
28
+ * to it when the dialog closes, unless `finalFocusRef` names another
29
+ * element. Leave it out to open the dialog with `open` from elsewhere.
30
30
  */
31
31
  trigger?: ReactElement;
32
32
  /** Controlled open state. Pair with `onOpenChange`. */
@@ -54,6 +54,19 @@ export interface DialogProps {
54
54
  * destructive action.
55
55
  */
56
56
  initialFocusRef?: RefObject<HTMLElement | null>;
57
+ /**
58
+ * Where focus lands when the dialog closes, in place of the trigger. Use it
59
+ * when the confirmed action removes the trigger, such as a row's Remove
60
+ * button: focus would return to an element that is about to unmount and
61
+ * fall to the page body. Point it at something that stays, such as the
62
+ * list's heading, which needs `tabIndex={-1}` to take focus.
63
+ *
64
+ * The ref is read as the dialog closes, however it closes. Fill it in the
65
+ * committing action, so Cancel and Escape still return focus to the
66
+ * trigger, which is still there. While the ref holds no element, focus
67
+ * returns to the trigger as usual.
68
+ */
69
+ finalFocusRef?: RefObject<HTMLElement | null>;
57
70
  /** Accessible name of the close button. Translate it with the rest of the UI. */
58
71
  closeLabel?: string;
59
72
  /**
@@ -68,8 +81,8 @@ export interface DialogProps {
68
81
  /**
69
82
  * A modal dialog: a raised panel over a dimmed page, built on Ark UI.
70
83
  *
71
- * Ark owns the behaviour: the focus trap, focus returning to the trigger,
72
- * Escape, the page's scroll lock, `aria-modal`, and the title and
84
+ * Ark owns the behaviour: the focus trap, focus returning to the trigger
85
+ * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and
73
86
  * description wiring. This wrapper adds the `ds-` classes, the
74
87
  * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
75
88
  *
@@ -100,5 +113,5 @@ export interface DialogProps {
100
113
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
101
114
  * 60, above it. Nothing is mounted while the dialog is closed.
102
115
  */
103
- export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, closeLabel, closeIcon, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
116
+ export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
104
117
  //# sourceMappingURL=dialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAEf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EACf,aAAa,EACb,UAAoB,EACpB,SAAiB,EACjB,SAAS,GACV,EAAE,WAAW,2CAyDb"}
@@ -10,8 +10,8 @@ import { Cross } from '../fallback-glyphs';
10
10
  /**
11
11
  * A modal dialog: a raised panel over a dimmed page, built on Ark UI.
12
12
  *
13
- * Ark owns the behaviour: the focus trap, focus returning to the trigger,
14
- * Escape, the page's scroll lock, `aria-modal`, and the title and
13
+ * Ark owns the behaviour: the focus trap, focus returning to the trigger
14
+ * (or to `finalFocusRef`), Escape, the page's scroll lock, `aria-modal`, and the title and
15
15
  * description wiring. This wrapper adds the `ds-` classes, the
16
16
  * `--ds-dialog-*` bindings, and a slot API in place of Ark's anatomy.
17
17
  *
@@ -42,7 +42,7 @@ import { Cross } from '../fallback-glyphs';
42
42
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
43
43
  * 60, above it. Nothing is mounted while the dialog is closed.
44
44
  */
45
- export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, closeLabel = 'Close', closeIcon = Cross, className, }) {
45
+ export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon = Cross, className, }) {
46
46
  const dismissible = role === 'dialog';
47
47
  const panelRef = useRef(null);
48
48
  const handleOpenChange = (details) => onOpenChange?.(details.open);
@@ -50,7 +50,8 @@ export function Dialog({ title, description, children, actions, trigger, open, d
50
50
  // reads undefined as "the first focusable element" and, given null, fails
51
51
  // to start at all, leaving the page reachable by Tab.
52
52
  const initialFocusEl = (() => initialFocusRef?.current ?? undefined);
53
- return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, closeOnInteractOutside: dismissible, initialFocusEl: initialFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(ArkDialog.Trigger, { asChild: true, children: trigger }), _jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', className), children: _jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }) }) })] })] }));
53
+ const finalFocusEl = () => finalFocusRef?.current ?? null;
54
+ return (_jsxs(ArkDialog.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: handleOpenChange, role: role, closeOnInteractOutside: dismissible, initialFocusEl: initialFocusEl, finalFocusEl: finalFocusEl, lazyMount: true, unmountOnExit: true, children: [trigger && _jsx(ArkDialog.Trigger, { asChild: true, children: trigger }), _jsxs(Portal, { children: [_jsx(ArkDialog.Backdrop, { className: "ds-dialog__backdrop" }), _jsx(ArkDialog.Positioner, { className: "ds-dialog__positioner", children: _jsx(ArkDialog.Content, { ref: panelRef, className: cx('ds-dialog', className), children: _jsxs(PortalContainerContext.Provider, { value: panelRef, children: [_jsxs("div", { className: "ds-dialog__header", children: [_jsxs("div", { className: "ds-dialog__heading", children: [_jsx(ArkDialog.Title, { className: "ds-dialog__title", children: title }), description && (_jsx(ArkDialog.Description, { className: "ds-dialog__description", children: description }))] }), dismissible && (_jsx(ArkDialog.CloseTrigger, { asChild: true, children: _jsx(IconButton, { icon: closeIcon, "aria-label": closeLabel, variant: "tertiary", size: "sm", className: "ds-dialog__close" }) }))] }), children && _jsx(DialogBody, { children: children }), actions && _jsx("div", { className: "ds-dialog__actions", children: actions })] }) }) })] })] }));
54
55
  }
55
56
  /**
56
57
  * The scrolling body. While its content overflows it joins the tab order, so
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAIL,WAAW,EACX,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAoE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,QAAQ,EACf,eAAe,EACf,UAAU,GAAG,OAAO,EACpB,SAAS,GAAG,KAAK,EACjB,SAAS,GACG;IACZ,MAAM,WAAW,GAAG,IAAI,KAAK,QAAQ,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,MAAM,gBAAgB,GAAG,CAAC,OAA0B,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtF,uEAAuE;IACvE,0EAA0E;IAC1E,sDAAsD;IACtD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,OAAO,IAAI,SAAS,CAA6B,CAAC;IAEjG,OAAO,CACL,MAAC,SAAS,CAAC,IAAI,IACb,I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;QACF,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,iBAAiB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,YACjF,cAAK,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAO,GACrD,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,122 @@
1
+ @layer components {
2
+ .ds-field {
3
+ display: flex;
4
+ flex-direction: column;
5
+ align-items: stretch;
6
+ gap: var(--ds-field-gap);
7
+
8
+ & .ds-field__label {
9
+ display: inline-flex;
10
+ align-items: baseline;
11
+ gap: var(--ds-field-gap);
12
+ color: var(--ds-field-label-text);
13
+ font-size: var(--ds-field-label-font-size);
14
+ font-weight: var(--ds-field-label-font-weight);
15
+
16
+ &[data-disabled] {
17
+ opacity: var(--ds-opacity-disabled);
18
+ }
19
+ }
20
+
21
+ & .ds-field__indicator {
22
+ color: var(--ds-field-indicator-text);
23
+ }
24
+
25
+ & .ds-field__hint {
26
+ color: var(--ds-field-hint-text);
27
+ font-size: var(--ds-field-hint-font-size);
28
+
29
+ &[data-disabled] {
30
+ opacity: var(--ds-opacity-disabled);
31
+ }
32
+ }
33
+
34
+ & .ds-field__message {
35
+ color: var(--ds-field-message-text);
36
+ font-size: var(--ds-field-message-font-size);
37
+ }
38
+ }
39
+
40
+ .ds-input {
41
+ box-sizing: border-box;
42
+ width: 100%;
43
+ border: 1px solid var(--ds-input-border);
44
+ border-radius: var(--ds-input-radius);
45
+ background-color: var(--ds-input-bg);
46
+ color: var(--ds-input-text);
47
+ font-family: inherit;
48
+ font-weight: inherit;
49
+ line-height: inherit;
50
+ transition:
51
+ background-color 150ms cubic-bezier(0, 0, 0.2, 1),
52
+ border-color 150ms cubic-bezier(0, 0, 0.2, 1),
53
+ box-shadow 150ms cubic-bezier(0, 0, 0.2, 1);
54
+
55
+ /*
56
+ * Firefox dims placeholders to 0.54 by default, which would void the
57
+ * measured placeholder contrast; a percentage is what the lint allows.
58
+ */
59
+ &::placeholder {
60
+ color: var(--ds-input-placeholder);
61
+ opacity: 100%;
62
+ }
63
+
64
+ /*
65
+ * The same signals as Select's trigger, so a form reads as one family:
66
+ * invalid is red AND 2px, hover is darker AND 2px, because colour alone
67
+ * is a weak signal on a control and one of them has to survive a
68
+ * red-green colour deficiency. The second pixel is a ring outside the
69
+ * border rather than a wider border: a textarea is sized by its rows,
70
+ * so a wider border would grow it and shift what sits below.
71
+ */
72
+ &[data-invalid] {
73
+ border-color: var(--ds-input-border-invalid);
74
+ box-shadow: 0 0 0 1px var(--ds-input-border-invalid);
75
+ }
76
+
77
+ &:hover:not(:disabled, [readonly]) {
78
+ background-color: var(--ds-input-bg-hover);
79
+
80
+ &:not([data-invalid]) {
81
+ border-color: var(--ds-input-border-hover);
82
+ box-shadow: 0 0 0 1px var(--ds-input-border-hover);
83
+ }
84
+ }
85
+
86
+ &:focus-visible {
87
+ outline: 2px solid var(--ds-input-focus-ring);
88
+ outline-offset: 3px;
89
+ }
90
+
91
+ &:disabled {
92
+ opacity: var(--ds-opacity-disabled);
93
+ cursor: not-allowed;
94
+ }
95
+
96
+ &[readonly] {
97
+ cursor: default;
98
+ }
99
+
100
+ &.ds-input--sm {
101
+ min-height: var(--ds-input-size-sm-height);
102
+ padding: var(--ds-input-size-sm-padding-block) var(--ds-input-size-sm-padding-inline);
103
+ font-size: var(--ds-input-size-sm-font-size);
104
+ }
105
+
106
+ &.ds-input--md {
107
+ min-height: var(--ds-input-size-md-height);
108
+ padding: var(--ds-input-size-md-padding-block) var(--ds-input-size-md-padding-inline);
109
+ font-size: var(--ds-input-size-md-font-size);
110
+ }
111
+
112
+ &.ds-input--lg {
113
+ min-height: var(--ds-input-size-lg-height);
114
+ padding: var(--ds-input-size-lg-padding-block) var(--ds-input-size-lg-padding-inline);
115
+ font-size: var(--ds-input-size-lg-font-size);
116
+ }
117
+ }
118
+
119
+ .ds-textarea {
120
+ resize: vertical;
121
+ }
122
+ }
@@ -0,0 +1,2 @@
1
+ /* AUTOGENERATED: types for the stylesheet beside it. */
2
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { ReactNode } from 'react';
2
+ import './field.css';
3
+ export type FieldProps = {
4
+ /** Visible label. The field's control is named by it, so it is required. */
5
+ label: ReactNode;
6
+ /**
7
+ * The control: an `Input`, a `Textarea`, or any Ark field part. It picks up
8
+ * the label, the hint, the error and the states from the field.
9
+ */
10
+ children: ReactNode;
11
+ /** Help the user reads before typing. Sits under the control, muted. */
12
+ hint?: ReactNode;
13
+ /**
14
+ * What is wrong with the value. Shown under the control in the danger
15
+ * colour, and its presence marks the field invalid: the control gets
16
+ * `aria-invalid` and points at the message through `aria-describedby`.
17
+ * `false`, `''` and `undefined` all mean no error, so a form library's
18
+ * `errors.title?.message` goes straight in.
19
+ */
20
+ error?: ReactNode;
21
+ /**
22
+ * Marks the field invalid without a message, for a summary shown elsewhere.
23
+ * Defaults to whether `error` has content. An explicit `false` wins over
24
+ * `error`, and the message is then not shown: the control is only
25
+ * described by an error while it is invalid.
26
+ */
27
+ invalid?: boolean;
28
+ /** Marks the control required and shows the indicator after the label. */
29
+ required?: boolean;
30
+ /** Disables the control and dims it, the label and the hint. */
31
+ disabled?: boolean;
32
+ /** Shows the value without letting the user change it. */
33
+ readOnly?: boolean;
34
+ /** Id for the control. Generated when omitted; the label's `for` follows it. */
35
+ id?: string;
36
+ /** Extra class names appended after `ds-field`. */
37
+ className?: string;
38
+ };
39
+ /**
40
+ * A labelled form control with optional hint and error, built on Ark UI.
41
+ *
42
+ * Ark owns the wiring: the label's `for`, the control's `aria-describedby`
43
+ * (hint and, when shown, error), `aria-invalid`, `required`, `disabled` and
44
+ * `readOnly`. This wrapper decides what renders and contributes the
45
+ * `ds-field` classes and the `--ds-field-*` bindings. The control is whatever
46
+ * you put inside: an `Input`, a `Textarea`, or a future Ark field part.
47
+ *
48
+ * ```tsx
49
+ * <Field label="Title" hint="Short and specific." error={errors.title?.message}>
50
+ * <Input {...register('title')} />
51
+ * </Field>
52
+ * ```
53
+ */
54
+ export declare function Field({ label, children, hint, error, invalid, required, disabled, readOnly, id, className, }: FieldProps): import("react/jsx-runtime").JSX.Element;
55
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/field/field.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,aAAa,CAAC;AAGrB,MAAM,MAAM,UAAU,GAAG;IACvB,4EAA4E;IAC5E,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB,wEAAwE;IACxE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,SAAS,GACV,EAAE,UAAU,2CAqBZ"}
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Field as ArkField } from '@ark-ui/react/field';
3
+ import './field.css';
4
+ import { cx } from '../cx';
5
+ /**
6
+ * A labelled form control with optional hint and error, built on Ark UI.
7
+ *
8
+ * Ark owns the wiring: the label's `for`, the control's `aria-describedby`
9
+ * (hint and, when shown, error), `aria-invalid`, `required`, `disabled` and
10
+ * `readOnly`. This wrapper decides what renders and contributes the
11
+ * `ds-field` classes and the `--ds-field-*` bindings. The control is whatever
12
+ * you put inside: an `Input`, a `Textarea`, or a future Ark field part.
13
+ *
14
+ * ```tsx
15
+ * <Field label="Title" hint="Short and specific." error={errors.title?.message}>
16
+ * <Input {...register('title')} />
17
+ * </Field>
18
+ * ```
19
+ */
20
+ export function Field({ label, children, hint, error, invalid, required, disabled, readOnly, id, className, }) {
21
+ const hasHint = Boolean(hint);
22
+ const hasError = Boolean(error);
23
+ return (_jsxs(ArkField.Root, { id: id, invalid: invalid ?? hasError, required: required, disabled: disabled, readOnly: readOnly, className: cx('ds-field', className), children: [_jsxs(ArkField.Label, { className: "ds-field__label", children: [label, _jsx(ArkField.RequiredIndicator, { className: "ds-field__indicator" })] }), children, hasHint && _jsx(ArkField.HelperText, { className: "ds-field__hint", children: hint }), hasError && _jsx(ArkField.ErrorText, { className: "ds-field__message", children: error })] }));
24
+ }
25
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../src/field/field.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAuC3B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,EACpB,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,SAAS,GACE;IACX,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,CACL,MAAC,QAAQ,CAAC,IAAI,IACZ,EAAE,EAAE,EAAE,EACN,OAAO,EAAE,OAAO,IAAI,QAAQ,EAC5B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,aAEpC,MAAC,QAAQ,CAAC,KAAK,IAAC,SAAS,EAAC,iBAAiB,aACxC,KAAK,EACN,KAAC,QAAQ,CAAC,iBAAiB,IAAC,SAAS,EAAC,qBAAqB,GAAG,IAC/C,EAChB,QAAQ,EACR,OAAO,IAAI,KAAC,QAAQ,CAAC,UAAU,IAAC,SAAS,EAAC,gBAAgB,YAAE,IAAI,GAAuB,EACvF,QAAQ,IAAI,KAAC,QAAQ,CAAC,SAAS,IAAC,SAAS,EAAC,mBAAmB,YAAE,KAAK,GAAsB,IAC7E,CACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ export type { FieldProps } from './field';
2
+ export { Field } from './field';
3
+ export type { InputProps, InputSize } from './input';
4
+ export { Input } from './input';
5
+ export type { TextareaProps } from './textarea';
6
+ export { Textarea } from './textarea';
7
+ export type { FieldControl } from './use-field-control';
8
+ export { useFieldControl } from './use-field-control';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Field } from './field';
2
+ export { Input } from './input';
3
+ export { Textarea } from './textarea';
4
+ export { useFieldControl } from './use-field-control';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/field/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { ComponentProps } from 'react';
2
+ import './field.css';
3
+ export type InputSize = 'sm' | 'md' | 'lg';
4
+ export type InputProps = Omit<ComponentProps<'input'>, 'size'> & {
5
+ /** Control height and type scale. Matches `Select` and `Button`. */
6
+ size?: InputSize;
7
+ /**
8
+ * Marks the control invalid on its own, outside a `Field`. Inside one, the
9
+ * field's `error` or `invalid` does this and the prop is not needed.
10
+ */
11
+ invalid?: boolean;
12
+ };
13
+ /**
14
+ * Single-line text control, built on Ark UI's field input.
15
+ *
16
+ * Inside a `Field` it takes the label, the hint, the error and the states
17
+ * from the field, which also owns its `id`; an `aria-describedby` of its own
18
+ * is added to the field's. On its own it is a plain `<input>` with the
19
+ * `ds-input` look, so it still needs a name: a visible label elsewhere or
20
+ * `aria-label`.
21
+ *
22
+ * ```tsx
23
+ * <Field label="Title">
24
+ * <Input placeholder="e.g. Run a marathon" />
25
+ * </Field>
26
+ * ```
27
+ */
28
+ export declare function Input({ size, invalid, className, ...props }: InputProps): import("react/jsx-runtime").JSX.Element;
29
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/field/input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,aAAa,CAAC;AAIrB,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG;IAC/D,oEAAoE;IACpE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAW,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,UAAU,2CAS9E"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Field as ArkField } from '@ark-ui/react/field';
3
+ import './field.css';
4
+ import { cx } from '../cx';
5
+ import { useFieldControlProps } from './use-field-control';
6
+ /**
7
+ * Single-line text control, built on Ark UI's field input.
8
+ *
9
+ * Inside a `Field` it takes the label, the hint, the error and the states
10
+ * from the field, which also owns its `id`; an `aria-describedby` of its own
11
+ * is added to the field's. On its own it is a plain `<input>` with the
12
+ * `ds-input` look, so it still needs a name: a visible label elsewhere or
13
+ * `aria-label`.
14
+ *
15
+ * ```tsx
16
+ * <Field label="Title">
17
+ * <Input placeholder="e.g. Run a marathon" />
18
+ * </Field>
19
+ * ```
20
+ */
21
+ export function Input({ size = 'md', invalid, className, ...props }) {
22
+ return (_jsx(ArkField.Input, { className: cx('ds-input', `ds-input--${size}`, className), "aria-invalid": invalid || undefined, "data-invalid": invalid ? '' : undefined, ...useFieldControlProps(props) }));
23
+ }
24
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/field/input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAc3D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAc;IAC7E,OAAO,CACL,KAAC,QAAQ,CAAC,KAAK,IACb,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,aAAa,IAAI,EAAE,EAAE,SAAS,CAAC,kBAC3C,OAAO,IAAI,SAAS,kBACpB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAClC,oBAAoB,CAAC,KAAK,CAAC,GAC/B,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ComponentProps } from 'react';
2
+ import './field.css';
3
+ import type { InputSize } from './input';
4
+ export type TextareaProps = ComponentProps<'textarea'> & {
5
+ /** Type scale and padding. Matches `Input`. */
6
+ size?: InputSize;
7
+ /** Marks the control invalid on its own, outside a `Field`. */
8
+ invalid?: boolean;
9
+ /** Grows with its content instead of scrolling, and takes away the resize handle. */
10
+ autoresize?: boolean;
11
+ };
12
+ /**
13
+ * Multi-line text control, built on Ark UI's field textarea.
14
+ *
15
+ * Same contract as `Input`: inside a `Field` it is named and described by the
16
+ * field; on its own it needs `aria-label`. Three rows by default, resizable
17
+ * vertically; `autoresize` grows it with the text instead and drops the handle.
18
+ *
19
+ * ```tsx
20
+ * <Field label="Description">
21
+ * <Textarea rows={4} placeholder="Describe your goal…" />
22
+ * </Field>
23
+ * ```
24
+ */
25
+ export declare function Textarea({ size, invalid, autoresize, rows, className, ...props }: TextareaProps): import("react/jsx-runtime").JSX.Element;
26
+ //# sourceMappingURL=textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/field/textarea.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG;IACvD,+CAA+C;IAC/C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qFAAqF;IACrF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAW,EACX,OAAO,EACP,UAAkB,EAClB,IAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,2CAWf"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Field as ArkField } from '@ark-ui/react/field';
3
+ import './field.css';
4
+ import { cx } from '../cx';
5
+ import { useFieldControlProps } from './use-field-control';
6
+ /**
7
+ * Multi-line text control, built on Ark UI's field textarea.
8
+ *
9
+ * Same contract as `Input`: inside a `Field` it is named and described by the
10
+ * field; on its own it needs `aria-label`. Three rows by default, resizable
11
+ * vertically; `autoresize` grows it with the text instead and drops the handle.
12
+ *
13
+ * ```tsx
14
+ * <Field label="Description">
15
+ * <Textarea rows={4} placeholder="Describe your goal…" />
16
+ * </Field>
17
+ * ```
18
+ */
19
+ export function Textarea({ size = 'md', invalid, autoresize = false, rows = 3, className, ...props }) {
20
+ return (_jsx(ArkField.Textarea, { className: cx('ds-input', 'ds-textarea', `ds-input--${size}`, className), "aria-invalid": invalid || undefined, "data-invalid": invalid ? '' : undefined, autoresize: autoresize, rows: rows, ...useFieldControlProps(props) }));
21
+ }
22
+ //# sourceMappingURL=textarea.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../src/field/textarea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAW3D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,IAAI,GAAG,IAAI,EACX,OAAO,EACP,UAAU,GAAG,KAAK,EAClB,IAAI,GAAG,CAAC,EACR,SAAS,EACT,GAAG,KAAK,EACM;IACd,OAAO,CACL,KAAC,QAAQ,CAAC,QAAQ,IAChB,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,aAAa,IAAI,EAAE,EAAE,SAAS,CAAC,kBAC1D,OAAO,IAAI,SAAS,kBACpB,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EACtC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,KACN,oBAAoB,CAAC,KAAK,CAAC,GAC/B,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,41 @@
1
+ type ControlProps = {
2
+ id?: string;
3
+ 'aria-describedby'?: string;
4
+ };
5
+ /**
6
+ * Inside a `Field`, the field owns the control's `id` (the label's `for`
7
+ * points at it) and its description (the hint and the error). Ark lets any
8
+ * prop on the element replace the context's, so a consumer `id` would split
9
+ * the label from the control and a consumer `aria-describedby` would drop
10
+ * the hint and the error. This keeps the field's id and adds the consumer's
11
+ * description to the field's instead of replacing it. Outside a field the
12
+ * props pass through untouched.
13
+ */
14
+ export declare function useFieldControlProps<P extends ControlProps>(props: P): P;
15
+ export type FieldControl = {
16
+ /** Id the field's label points at. Put it on the element that takes the value. */
17
+ id: string;
18
+ /** Id of the field's label, for `aria-labelledby` on an element a `<label for>` cannot name. */
19
+ labelId: string;
20
+ /** Ids of the hint and, while invalid, the error. Put it in `aria-describedby`. */
21
+ describedBy: string | undefined;
22
+ invalid: boolean;
23
+ disabled: boolean;
24
+ readOnly: boolean;
25
+ required: boolean;
26
+ };
27
+ /**
28
+ * The field's wiring for a control that is not an `Input` or a `Textarea`:
29
+ * a rich-text editor, a slider, anything a product composes itself. Returns
30
+ * `null` outside a `Field`.
31
+ *
32
+ * ```tsx
33
+ * const field = useFieldControl();
34
+ * <div role="textbox" aria-multiline="true" id={field?.id}
35
+ * aria-labelledby={field?.labelId} aria-describedby={field?.describedBy}
36
+ * aria-invalid={field?.invalid || undefined} />
37
+ * ```
38
+ */
39
+ export declare function useFieldControl(): FieldControl | null;
40
+ export {};
41
+ //# sourceMappingURL=use-field-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-control.d.ts","sourceRoot":"","sources":["../../src/field/use-field-control.ts"],"names":[],"mappings":"AAEA,KAAK,YAAY,GAAG;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAKxE;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,kFAAkF;IAClF,EAAE,EAAE,MAAM,CAAC;IACX,gGAAgG;IAChG,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAYrD"}
@@ -0,0 +1,44 @@
1
+ import { useFieldContext } from '@ark-ui/react/field';
2
+ /**
3
+ * Inside a `Field`, the field owns the control's `id` (the label's `for`
4
+ * points at it) and its description (the hint and the error). Ark lets any
5
+ * prop on the element replace the context's, so a consumer `id` would split
6
+ * the label from the control and a consumer `aria-describedby` would drop
7
+ * the hint and the error. This keeps the field's id and adds the consumer's
8
+ * description to the field's instead of replacing it. Outside a field the
9
+ * props pass through untouched.
10
+ */
11
+ export function useFieldControlProps(props) {
12
+ const field = useFieldContext();
13
+ if (!field)
14
+ return props;
15
+ const describedBy = [field.ariaDescribedby, props['aria-describedby']].filter(Boolean).join(' ');
16
+ return { ...props, id: field.ids.control, 'aria-describedby': describedBy || undefined };
17
+ }
18
+ /**
19
+ * The field's wiring for a control that is not an `Input` or a `Textarea`:
20
+ * a rich-text editor, a slider, anything a product composes itself. Returns
21
+ * `null` outside a `Field`.
22
+ *
23
+ * ```tsx
24
+ * const field = useFieldControl();
25
+ * <div role="textbox" aria-multiline="true" id={field?.id}
26
+ * aria-labelledby={field?.labelId} aria-describedby={field?.describedBy}
27
+ * aria-invalid={field?.invalid || undefined} />
28
+ * ```
29
+ */
30
+ export function useFieldControl() {
31
+ const field = useFieldContext();
32
+ if (!field)
33
+ return null;
34
+ return {
35
+ id: field.ids.control,
36
+ labelId: field.ids.label,
37
+ describedBy: field.ariaDescribedby,
38
+ invalid: field.invalid,
39
+ disabled: field.disabled,
40
+ readOnly: field.readOnly,
41
+ required: field.required,
42
+ };
43
+ }
44
+ //# sourceMappingURL=use-field-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-control.js","sourceRoot":"","sources":["../../src/field/use-field-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtD;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAyB,KAAQ;IACnE,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjG,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,kBAAkB,EAAE,WAAW,IAAI,SAAS,EAAE,CAAC;AAC3F,CAAC;AAeD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO;QACrB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK;QACxB,WAAW,EAAE,KAAK,CAAC,eAAe;QAClC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './card';
5
5
  export { cx } from './cx';
6
6
  export * from './dialog';
7
7
  export { Check as FallbackCheck, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
8
+ export * from './field';
8
9
  export * from './icon';
9
10
  export * from './illustration';
10
11
  export * from './menu';
@@ -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,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,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,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,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,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './card';
5
5
  export { cx } from './cx';
6
6
  export * from './dialog';
7
7
  export { Check as FallbackCheck, ChevronRight as FallbackChevronRight, Cross as FallbackCross, } from './fallback-glyphs';
8
+ export * from './field';
8
9
  export * from './icon';
9
10
  export * from './illustration';
10
11
  export * from './menu';
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,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,YAAY,IAAI,oBAAoB,EACpC,KAAK,IAAI,aAAa,GACvB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,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,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,KAAK,IAAI,aAAa,EACtB,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,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -88,6 +88,10 @@
88
88
  "types": "./dist/switch/switch.css.d.ts",
89
89
  "default": "./dist/switch/switch.css"
90
90
  },
91
+ "./css/field": {
92
+ "types": "./dist/field/field.css.d.ts",
93
+ "default": "./dist/field/field.css"
94
+ },
91
95
  "./css/tabs": {
92
96
  "types": "./dist/tabs/tabs.css.d.ts",
93
97
  "default": "./dist/tabs/tabs.css"
@@ -116,6 +120,10 @@
116
120
  "types": "./dist/switch/index.d.ts",
117
121
  "import": "./dist/switch/index.js"
118
122
  },
123
+ "./field": {
124
+ "types": "./dist/field/index.d.ts",
125
+ "import": "./dist/field/index.js"
126
+ },
119
127
  "./tabs": {
120
128
  "types": "./dist/tabs/index.d.ts",
121
129
  "import": "./dist/tabs/index.js"
@@ -138,7 +146,7 @@
138
146
  },
139
147
  "devDependencies": {
140
148
  "@manakind/ds-config": "*",
141
- "@manakind/manuia-tokens": "0.8.0",
149
+ "@manakind/manuia-tokens": "0.9.0",
142
150
  "@testing-library/jest-dom": "^6.9.1",
143
151
  "@testing-library/react": "^16.3.2",
144
152
  "@testing-library/user-event": "^14.6.1",