@manakind/ui-core 0.9.0 → 0.11.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
@@ -0,0 +1,146 @@
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
+ /*
42
+ * Block, not inline: an inline-level input sits on its line's baseline
43
+ * and leaves a font-metric gap below it that differs between renderers,
44
+ * so screenshots of the same control disagreed by a pixel.
45
+ */
46
+ display: block;
47
+ box-sizing: border-box;
48
+ width: 100%;
49
+ border: 1px solid var(--ds-input-border);
50
+ border-radius: var(--ds-input-radius);
51
+ background-color: var(--ds-input-bg);
52
+ color: var(--ds-input-text);
53
+ font-family: inherit;
54
+ font-weight: inherit;
55
+ line-height: inherit;
56
+ transition:
57
+ background-color 150ms cubic-bezier(0, 0, 0.2, 1),
58
+ border-color 150ms cubic-bezier(0, 0, 0.2, 1),
59
+ box-shadow 150ms cubic-bezier(0, 0, 0.2, 1);
60
+
61
+ /*
62
+ * Firefox dims placeholders to 0.54 by default, which would void the
63
+ * measured placeholder contrast; a percentage is what the lint allows.
64
+ */
65
+ &::placeholder {
66
+ color: var(--ds-input-placeholder);
67
+ opacity: 100%;
68
+ }
69
+
70
+ /*
71
+ * The same signals as Select's trigger, so a form reads as one family:
72
+ * invalid is red AND 2px, hover is darker AND 2px, because colour alone
73
+ * is a weak signal on a control and one of them has to survive a
74
+ * red-green colour deficiency. The second pixel is a ring outside the
75
+ * border rather than a wider border: a textarea is sized by its rows,
76
+ * so a wider border would grow it and shift what sits below.
77
+ */
78
+ &[data-invalid] {
79
+ border-color: var(--ds-input-border-invalid);
80
+ box-shadow: 0 0 0 1px var(--ds-input-border-invalid);
81
+ }
82
+
83
+ &:hover:not(:disabled, [readonly]) {
84
+ background-color: var(--ds-input-bg-hover);
85
+
86
+ &:not([data-invalid]) {
87
+ border-color: var(--ds-input-border-hover);
88
+ box-shadow: 0 0 0 1px var(--ds-input-border-hover);
89
+ }
90
+ }
91
+
92
+ &:focus-visible {
93
+ outline: 2px solid var(--ds-input-focus-ring);
94
+ outline-offset: 3px;
95
+ }
96
+
97
+ &:disabled {
98
+ opacity: var(--ds-opacity-disabled);
99
+ cursor: not-allowed;
100
+ }
101
+
102
+ &[readonly] {
103
+ cursor: default;
104
+ }
105
+
106
+ /*
107
+ * A single-line input centres its text in its height, so it takes no
108
+ * block padding: with it, text plus padding plus border outgrew the
109
+ * control height and the input stood taller than the Select beside it.
110
+ * The textarea is sized by its rows and takes the block padding below.
111
+ */
112
+ &.ds-input--sm {
113
+ min-height: var(--ds-input-size-sm-height);
114
+ padding-inline: var(--ds-input-size-sm-padding-inline);
115
+ font-size: var(--ds-input-size-sm-font-size);
116
+ }
117
+
118
+ &.ds-input--md {
119
+ min-height: var(--ds-input-size-md-height);
120
+ padding-inline: var(--ds-input-size-md-padding-inline);
121
+ font-size: var(--ds-input-size-md-font-size);
122
+ }
123
+
124
+ &.ds-input--lg {
125
+ min-height: var(--ds-input-size-lg-height);
126
+ padding-inline: var(--ds-input-size-lg-padding-inline);
127
+ font-size: var(--ds-input-size-lg-font-size);
128
+ }
129
+ }
130
+
131
+ .ds-textarea {
132
+ resize: vertical;
133
+
134
+ &.ds-input--sm {
135
+ padding-block: var(--ds-input-size-sm-padding-block);
136
+ }
137
+
138
+ &.ds-input--md {
139
+ padding-block: var(--ds-input-size-md-padding-block);
140
+ }
141
+
142
+ &.ds-input--lg {
143
+ padding-block: var(--ds-input-size-lg-padding-block);
144
+ }
145
+ }
146
+ }
@@ -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;AAsBF;;;;;;;;;;;;;;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,2CAkBZ"}
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Field as ArkField, useFieldContext } from '@ark-ui/react/field';
3
+ import './field.css';
4
+ import { cx } from '../cx';
5
+ /**
6
+ * A `<label for>` activates only a labelable element. A control a product
7
+ * composes itself (a rich-text editor, see `useFieldControl`) is a `div`,
8
+ * so a click on its label would do nothing. This gives such a control the
9
+ * focus the label promises; a native control keeps the browser's behaviour.
10
+ */
11
+ function FieldLabel({ children }) {
12
+ const field = useFieldContext();
13
+ const focusCustomControl = () => {
14
+ const control = document.getElementById(field.ids.control);
15
+ if (control instanceof HTMLElement && !('labels' in control))
16
+ control.focus();
17
+ };
18
+ return (_jsxs(ArkField.Label, { className: "ds-field__label", onClick: focusCustomControl, children: [children, _jsx(ArkField.RequiredIndicator, { className: "ds-field__indicator" })] }));
19
+ }
20
+ /**
21
+ * A labelled form control with optional hint and error, built on Ark UI.
22
+ *
23
+ * Ark owns the wiring: the label's `for`, the control's `aria-describedby`
24
+ * (hint and, when shown, error), `aria-invalid`, `required`, `disabled` and
25
+ * `readOnly`. This wrapper decides what renders and contributes the
26
+ * `ds-field` classes and the `--ds-field-*` bindings. The control is whatever
27
+ * you put inside: an `Input`, a `Textarea`, or a future Ark field part.
28
+ *
29
+ * ```tsx
30
+ * <Field label="Title" hint="Short and specific." error={errors.title?.message}>
31
+ * <Input {...register('title')} />
32
+ * </Field>
33
+ * ```
34
+ */
35
+ export function Field({ label, children, hint, error, invalid, required, disabled, readOnly, id, className, }) {
36
+ const hasHint = Boolean(hint);
37
+ const hasError = Boolean(error);
38
+ return (_jsxs(ArkField.Root, { id: id, invalid: invalid ?? hasError, required: required, disabled: disabled, readOnly: readOnly, className: cx('ds-field', className), children: [_jsx(FieldLabel, { children: label }), children, hasHint && _jsx(ArkField.HelperText, { className: "ds-field__hint", children: hint }), hasError && _jsx(ArkField.ErrorText, { className: "ds-field__message", children: error })] }));
39
+ }
40
+ //# 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,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAuC3B;;;;;GAKG;AACH,SAAS,UAAU,CAAC,EAAE,QAAQ,EAA2B;IACvD,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,kBAAkB,GAAG,GAAG,EAAE;QAC9B,MAAM,OAAO,GAAG,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,OAAO,YAAY,WAAW,IAAI,CAAC,CAAC,QAAQ,IAAI,OAAO,CAAC;YAAE,OAAO,CAAC,KAAK,EAAE,CAAC;IAChF,CAAC,CAAC;IACF,OAAO,CACL,MAAC,QAAQ,CAAC,KAAK,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,kBAAkB,aACpE,QAAQ,EACT,KAAC,QAAQ,CAAC,iBAAiB,IAAC,SAAS,EAAC,qBAAqB,GAAG,IAC/C,CAClB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;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,KAAC,UAAU,cAAE,KAAK,GAAc,EAC/B,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"}
@@ -111,8 +111,9 @@
111
111
  gap: var(--ds-select-content-padding);
112
112
 
113
113
  & .ds-select__label {
114
- color: var(--ds-select-trigger-text);
115
- font-size: var(--ds-select-size-md-font-size);
114
+ color: var(--ds-select-label-text);
115
+ font-size: var(--ds-select-label-font-size);
116
+ font-weight: var(--ds-select-label-font-weight);
116
117
  }
117
118
 
118
119
  & .ds-select__trigger {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manakind/ui-core",
3
- "version": "0.9.0",
3
+ "version": "0.11.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.10.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",