@aleph-alpha/ui-library 6.2.1 → 6.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/system/components/UiButtonGroup/index.d.ts +1 -0
  2. package/dist/system/components/UiDialog/types.d.ts +3 -2
  3. package/dist/system/components/UiInputGroup/UiInputGroup.vue.d.ts +20 -0
  4. package/dist/system/components/UiInputGroup/UiInputGroupAddon.vue.d.ts +20 -0
  5. package/dist/system/components/UiInputGroup/UiInputGroupButton.vue.d.ts +17 -0
  6. package/dist/system/components/UiInputGroup/UiInputGroupInput.vue.d.ts +11 -0
  7. package/dist/system/components/UiInputGroup/UiInputGroupTextarea.vue.d.ts +11 -0
  8. package/dist/system/components/UiInputGroup/index.d.ts +7 -0
  9. package/dist/system/components/UiInputGroup/types.d.ts +151 -0
  10. package/dist/system/components/UiLabel/UiLabel.vue.d.ts +3 -1
  11. package/dist/system/components/UiLabel/types.d.ts +7 -0
  12. package/dist/system/components/core/input-group/InputGroup.vue.d.ts +25 -0
  13. package/dist/system/components/core/input-group/InputGroupAddon.vue.d.ts +25 -0
  14. package/dist/system/components/core/input-group/InputGroupButton.vue.d.ts +28 -0
  15. package/dist/system/components/core/input-group/InputGroupInput.vue.d.ts +12 -0
  16. package/dist/system/components/core/input-group/InputGroupText.vue.d.ts +21 -0
  17. package/dist/system/components/core/input-group/InputGroupTextarea.vue.d.ts +12 -0
  18. package/dist/system/components/core/input-group/index.d.ts +18 -0
  19. package/dist/system/components/index.d.ts +1 -0
  20. package/dist/system/lib.js +14622 -14279
  21. package/package.json +2 -2
  22. package/src/components/UiButtonGroup/index.ts +4 -0
  23. package/src/components/UiDialog/UiDialog.stories.ts +151 -54
  24. package/src/components/UiDialog/UiDialogContent.vue +23 -32
  25. package/src/components/UiDialog/types.ts +3 -2
  26. package/src/components/UiField/UiField.stories.ts +329 -52
  27. package/src/components/UiField/UiFieldLabelInfo.vue +1 -1
  28. package/src/components/UiInput/UiInput.stories.ts +3 -1
  29. package/src/components/UiInput/UiInput.vue +26 -5
  30. package/src/components/UiInputGroup/UiInputGroup.stories.ts +2083 -0
  31. package/src/components/UiInputGroup/UiInputGroup.vue +18 -0
  32. package/src/components/UiInputGroup/UiInputGroupAddon.vue +18 -0
  33. package/src/components/UiInputGroup/UiInputGroupButton.vue +30 -0
  34. package/src/components/UiInputGroup/UiInputGroupInput.vue +16 -0
  35. package/src/components/UiInputGroup/UiInputGroupTextarea.vue +16 -0
  36. package/src/components/UiInputGroup/__tests__/UiInputGroup.test.ts +195 -0
  37. package/src/components/UiInputGroup/index.ts +10 -0
  38. package/src/components/UiInputGroup/types.ts +171 -0
  39. package/src/components/UiLabel/UiLabel.vue +7 -2
  40. package/src/components/UiLabel/types.ts +8 -0
  41. package/src/components/core/button/index.ts +23 -13
  42. package/src/components/core/button-group/ButtonGroupText.vue +4 -0
  43. package/src/components/core/button-group/index.ts +6 -2
  44. package/src/components/core/field/FieldError.vue +1 -1
  45. package/src/components/core/field/FieldLabel.vue +1 -1
  46. package/src/components/core/field/index.ts +7 -1
  47. package/src/components/core/input/Input.vue +4 -1
  48. package/src/components/core/input-group/InputGroup.vue +27 -0
  49. package/src/components/core/input-group/InputGroupAddon.vue +53 -0
  50. package/src/components/core/input-group/InputGroupButton.vue +35 -0
  51. package/src/components/core/input-group/InputGroupInput.vue +65 -0
  52. package/src/components/core/input-group/InputGroupText.vue +26 -0
  53. package/src/components/core/input-group/InputGroupTextarea.vue +62 -0
  54. package/src/components/core/input-group/index.ts +103 -0
  55. package/src/components/core/label/Label.vue +1 -1
  56. package/src/components/index.ts +1 -0
  57. package/src/theme/Typography.stories.ts +144 -6
  58. package/src/theme/__tests__/typography.test.ts +136 -0
@@ -0,0 +1,18 @@
1
+ <script setup lang="ts">
2
+ import { InputGroup as ShadcnInputGroup } from '@/components/core/input-group';
3
+ import type { UiInputGroupProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiInputGroup',
7
+ });
8
+
9
+ withDefaults(defineProps<UiInputGroupProps>(), {
10
+ type: 'input',
11
+ });
12
+ </script>
13
+
14
+ <template>
15
+ <ShadcnInputGroup :type="type">
16
+ <slot />
17
+ </ShadcnInputGroup>
18
+ </template>
@@ -0,0 +1,18 @@
1
+ <script setup lang="ts">
2
+ import { InputGroupAddon as ShadcnInputGroupAddon } from '@/components/core/input-group';
3
+ import type { UiInputGroupAddonProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiInputGroupAddon',
7
+ });
8
+
9
+ withDefaults(defineProps<UiInputGroupAddonProps>(), {
10
+ align: 'inline-start',
11
+ });
12
+ </script>
13
+
14
+ <template>
15
+ <ShadcnInputGroupAddon :align="align">
16
+ <slot />
17
+ </ShadcnInputGroupAddon>
18
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+ import { InputGroupButton as ShadcnInputGroupButton } from '@/components/core/input-group';
4
+ import type { UiInputGroupButtonProps } from './types';
5
+
6
+ defineOptions({
7
+ name: 'UiInputGroupButton',
8
+ });
9
+
10
+ // The props are a discriminated union (icon-only sizes require ariaLabel),
11
+ // which `withDefaults` cannot express — defaults are applied via computed
12
+ // fallbacks instead.
13
+ const props = defineProps<UiInputGroupButtonProps>();
14
+
15
+ const variant = computed(() => props.variant ?? 'ghost');
16
+ const size = computed(() => props.size ?? 'xs');
17
+ const type = computed(() => props.type ?? 'button');
18
+ </script>
19
+
20
+ <template>
21
+ <ShadcnInputGroupButton
22
+ :variant="variant"
23
+ :size="size"
24
+ :type="type"
25
+ :disabled="props.disabled ?? false"
26
+ :aria-label="props.ariaLabel"
27
+ >
28
+ <slot />
29
+ </ShadcnInputGroupButton>
30
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { InputGroupInput as ShadcnInputGroupInput } from '@/components/core/input-group';
3
+ import type { UiInputGroupInputProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiInputGroupInput',
7
+ });
8
+
9
+ defineProps<UiInputGroupInputProps>();
10
+
11
+ const model = defineModel<string | number>();
12
+ </script>
13
+
14
+ <template>
15
+ <ShadcnInputGroupInput v-model="model" />
16
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { InputGroupTextarea as ShadcnInputGroupTextarea } from '@/components/core/input-group';
3
+ import type { UiInputGroupTextareaProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiInputGroupTextarea',
7
+ });
8
+
9
+ defineProps<UiInputGroupTextareaProps>();
10
+
11
+ const model = defineModel<string | number>();
12
+ </script>
13
+
14
+ <template>
15
+ <ShadcnInputGroupTextarea v-model="model" />
16
+ </template>
@@ -0,0 +1,195 @@
1
+ import { render } from '@testing-library/vue';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { describe, expect, test } from 'vitest';
4
+ import UiInputGroup from '../UiInputGroup.vue';
5
+ import UiInputGroupAddon from '../UiInputGroupAddon.vue';
6
+ import UiInputGroupButton from '../UiInputGroupButton.vue';
7
+ import UiInputGroupInput from '../UiInputGroupInput.vue';
8
+ import UiInputGroupTextarea from '../UiInputGroupTextarea.vue';
9
+
10
+ describe('UiInputGroup', () => {
11
+ test('renders as a group and defaults to type="input"', () => {
12
+ const { getByRole } = render(UiInputGroup, {
13
+ slots: { default: '<input />' },
14
+ });
15
+ const group = getByRole('group');
16
+ expect(group).toBeInTheDocument();
17
+ expect(group).toHaveAttribute('data-type', 'input');
18
+ });
19
+
20
+ describe('Type (contract test)', () => {
21
+ const types = ['input', 'textarea'] as const;
22
+
23
+ test.each(types)('accepts type="%s"', (type) => {
24
+ const { getByRole } = render(UiInputGroup, {
25
+ props: { type },
26
+ slots: { default: '<input />' },
27
+ });
28
+ expect(getByRole('group')).toHaveAttribute('data-type', type);
29
+ });
30
+ });
31
+
32
+ test('forwards class and aria-label to the group container', () => {
33
+ const { getByRole } = render(UiInputGroup, {
34
+ attrs: { class: 'custom-class', 'aria-label': 'Email field' },
35
+ slots: { default: '<input />' },
36
+ });
37
+ const group = getByRole('group');
38
+ expect(group).toHaveClass('custom-class');
39
+ expect(group).toHaveAccessibleName('Email field');
40
+ });
41
+ });
42
+
43
+ describe('UiInputGroupAddon', () => {
44
+ test('defaults to align="inline-start"', () => {
45
+ const { getByText } = render(UiInputGroupAddon, {
46
+ slots: { default: 'USD' },
47
+ });
48
+ expect(
49
+ getByText('USD').closest('[data-slot=input-group-addon]'),
50
+ ).toHaveAttribute('data-align', 'inline-start');
51
+ });
52
+
53
+ describe('Align (contract test)', () => {
54
+ const aligns = [
55
+ 'inline-start',
56
+ 'inline-end',
57
+ 'block-start',
58
+ 'block-end',
59
+ ] as const;
60
+
61
+ test.each(aligns)('accepts align="%s"', (align) => {
62
+ const { getByText } = render(UiInputGroupAddon, {
63
+ props: { align },
64
+ slots: { default: 'USD' },
65
+ });
66
+ expect(
67
+ getByText('USD').closest('[data-slot=input-group-addon]'),
68
+ ).toHaveAttribute('data-align', align);
69
+ });
70
+ });
71
+
72
+ test('clicking the addon focuses the control of the group', async () => {
73
+ const { getByText, getByRole } = render({
74
+ components: { UiInputGroup, UiInputGroupAddon, UiInputGroupInput },
75
+ template: `
76
+ <UiInputGroup>
77
+ <UiInputGroupInput aria-label="Amount" />
78
+ <UiInputGroupAddon>USD</UiInputGroupAddon>
79
+ </UiInputGroup>
80
+ `,
81
+ });
82
+ await userEvent.click(getByText('USD'));
83
+ expect(getByRole('textbox', { name: 'Amount' })).toHaveFocus();
84
+ });
85
+
86
+ test('clicking a button inside the addon does not move focus to the control', async () => {
87
+ const { getByRole } = render({
88
+ components: {
89
+ UiInputGroup,
90
+ UiInputGroupAddon,
91
+ UiInputGroupButton,
92
+ UiInputGroupInput,
93
+ },
94
+ template: `
95
+ <UiInputGroup>
96
+ <UiInputGroupInput aria-label="Amount" />
97
+ <UiInputGroupAddon align="inline-end">
98
+ <UiInputGroupButton>Clear</UiInputGroupButton>
99
+ </UiInputGroupAddon>
100
+ </UiInputGroup>
101
+ `,
102
+ });
103
+ await userEvent.click(getByRole('button', { name: 'Clear' }));
104
+ expect(getByRole('textbox', { name: 'Amount' })).not.toHaveFocus();
105
+ });
106
+ });
107
+
108
+ describe('UiInputGroupButton', () => {
109
+ test('defaults to type="button", ghost variant, and size "xs"', () => {
110
+ const { getByRole } = render(UiInputGroupButton, {
111
+ slots: { default: 'Search' },
112
+ });
113
+ const button = getByRole('button');
114
+ expect(button).toHaveAttribute('type', 'button');
115
+ expect(button).toHaveAttribute('data-size', 'xs');
116
+ });
117
+
118
+ test('exposes ariaLabel as the accessible name for icon-only buttons', () => {
119
+ const { getByRole } = render(UiInputGroupButton, {
120
+ props: { size: 'icon-xs', ariaLabel: 'Copy link' },
121
+ slots: { default: '<svg />' },
122
+ });
123
+ expect(getByRole('button')).toHaveAccessibleName('Copy link');
124
+ });
125
+
126
+ test('does not emit click when disabled', async () => {
127
+ const { getByRole, emitted } = render(UiInputGroupButton, {
128
+ props: { disabled: true },
129
+ slots: { default: 'Send' },
130
+ });
131
+ const button = getByRole('button');
132
+ expect(button).toBeDisabled();
133
+ await userEvent.click(button, { pointerEventsCheck: 0 });
134
+ expect(emitted('click')).toBeUndefined();
135
+ });
136
+ });
137
+
138
+ describe('UiInputGroupInput', () => {
139
+ test('emits update:modelValue while typing', async () => {
140
+ const { getByRole, emitted } = render(UiInputGroupInput, {
141
+ attrs: { 'aria-label': 'Search' },
142
+ });
143
+ await userEvent.type(getByRole('textbox'), 'abc');
144
+ expect(emitted('update:modelValue')?.at(-1)).toEqual(['abc']);
145
+ });
146
+
147
+ test('marks itself as the group control for focus and error handling', () => {
148
+ const { getByRole } = render(UiInputGroupInput, {
149
+ attrs: { 'aria-label': 'Search' },
150
+ });
151
+ expect(getByRole('textbox')).toHaveAttribute(
152
+ 'data-slot',
153
+ 'input-group-control',
154
+ );
155
+ });
156
+
157
+ describe('aria-invalid normalization (contract test)', () => {
158
+ test.each([
159
+ ['bare attribute (empty string)', '', 'true'],
160
+ ['boolean true', true, 'true'],
161
+ ['string "true"', 'true', 'true'],
162
+ ['token "grammar" passes through', 'grammar', 'grammar'],
163
+ ['string "false" passes through', 'false', 'false'],
164
+ ])('%s renders aria-invalid="%s"', (_label, value, expected) => {
165
+ const { getByRole } = render(UiInputGroupInput, {
166
+ attrs: { 'aria-label': 'Search', 'aria-invalid': value },
167
+ });
168
+ expect(getByRole('textbox')).toHaveAttribute('aria-invalid', expected);
169
+ });
170
+
171
+ test('omits aria-invalid when not provided', () => {
172
+ const { getByRole } = render(UiInputGroupInput, {
173
+ attrs: { 'aria-label': 'Search' },
174
+ });
175
+ expect(getByRole('textbox')).not.toHaveAttribute('aria-invalid');
176
+ });
177
+ });
178
+ });
179
+
180
+ describe('UiInputGroupTextarea', () => {
181
+ test('emits update:modelValue while typing', async () => {
182
+ const { getByRole, emitted } = render(UiInputGroupTextarea, {
183
+ attrs: { 'aria-label': 'Message' },
184
+ });
185
+ await userEvent.type(getByRole('textbox'), 'hi');
186
+ expect(emitted('update:modelValue')?.at(-1)).toEqual(['hi']);
187
+ });
188
+
189
+ test('normalizes bare aria-invalid to the canonical "true"', () => {
190
+ const { getByRole } = render(UiInputGroupTextarea, {
191
+ attrs: { 'aria-label': 'Message', 'aria-invalid': '' },
192
+ });
193
+ expect(getByRole('textbox')).toHaveAttribute('aria-invalid', 'true');
194
+ });
195
+ });
@@ -0,0 +1,10 @@
1
+ export { default as UiInputGroup } from './UiInputGroup.vue';
2
+ export { default as UiInputGroupAddon } from './UiInputGroupAddon.vue';
3
+ export { default as UiInputGroupButton } from './UiInputGroupButton.vue';
4
+ export { default as UiInputGroupInput } from './UiInputGroupInput.vue';
5
+ export { default as UiInputGroupTextarea } from './UiInputGroupTextarea.vue';
6
+
7
+ // Pure presentational wrapper with no extra logic — re-exported from core.
8
+ export { InputGroupText as UiInputGroupText } from '@/components/core/input-group';
9
+
10
+ export type * from './types';
@@ -0,0 +1,171 @@
1
+ import type { UiButtonVariant } from '../UiButton';
2
+
3
+ /**
4
+ * The kind of control hosted by a `UiInputGroup`.
5
+ * - `'input'` — single-line control; the group renders as a fixed-height row.
6
+ * - `'textarea'` — multi-line control; the group grows with its content.
7
+ */
8
+ export type UiInputGroupType = 'input' | 'textarea';
9
+
10
+ /**
11
+ * Placement of a `UiInputGroupAddon` relative to the control.
12
+ * - `'inline-start'` / `'inline-end'` — same row as the control (for inputs).
13
+ * - `'block-start'` / `'block-end'` — own row above/below the control (for textareas).
14
+ */
15
+ export type UiInputGroupAddonAlign =
16
+ | 'inline-start'
17
+ | 'inline-end'
18
+ | 'block-start'
19
+ | 'block-end';
20
+
21
+ /**
22
+ * Compact button sizes available inside input group addons. `icon-*` sizes
23
+ * render icon-only buttons and require an accessible label.
24
+ */
25
+ export type UiInputGroupButtonSize = 'xs' | 'sm' | 'icon-xs' | 'icon-sm';
26
+
27
+ /**
28
+ * Attaches addons — icons, text affixes, keyboard shortcuts, buttons, or
29
+ * status — to an input or textarea inside one shared field boundary. The
30
+ * group renders a `role="group"` container that carries the border, focus
31
+ * ring, and error ring for the control inside it, so the field and its
32
+ * addons read as a single control.
33
+ * @category Form Inputs
34
+ * @useCases search field with shortcut, currency input, url input with prefix, input with copy button, chat textarea with actions, loading input
35
+ * @keywords input group, addon, prefix, suffix, affix, adornment, input actions, field
36
+ * @related UiInput, UiTextarea, UiButtonGroup, UiField
37
+ */
38
+ export interface UiInputGroupProps {
39
+ /**
40
+ * The kind of control the group hosts. Use `'textarea'` together with
41
+ * `UiInputGroupTextarea` so the group grows with its content instead of
42
+ * staying a fixed-height row.
43
+ * @default 'input'
44
+ */
45
+ type?: UiInputGroupType;
46
+ }
47
+
48
+ /**
49
+ * Positions icons, text, buttons, or status elements alongside the control
50
+ * of a `UiInputGroup`. Clicking a non-interactive addon focuses the group's
51
+ * control. Place addons after the control in the markup so the control keeps
52
+ * the first tab stop.
53
+ * @category Form Inputs
54
+ * @useCases input icon, currency prefix, unit suffix, inline field actions, textarea toolbar
55
+ * @keywords addon, adornment, prefix, suffix, inline, block
56
+ * @related UiInputGroup, UiInputGroupButton, UiInputGroupText
57
+ */
58
+ export interface UiInputGroupAddonProps {
59
+ /**
60
+ * Where the addon sits relative to the control. Use the `inline-*` values
61
+ * next to `UiInputGroupInput` and the `block-*` values with
62
+ * `UiInputGroupTextarea` (own row above/below the control).
63
+ * @default 'inline-start'
64
+ */
65
+ align?: UiInputGroupAddonAlign;
66
+ }
67
+
68
+ /** Props shared by every `UiInputGroupButton` size. */
69
+ interface UiInputGroupButtonBaseProps {
70
+ /**
71
+ * The visual style of the button.
72
+ * @default 'ghost'
73
+ */
74
+ variant?: UiButtonVariant;
75
+
76
+ /**
77
+ * The native button type.
78
+ * @default 'button'
79
+ */
80
+ type?: 'button' | 'submit' | 'reset';
81
+
82
+ /**
83
+ * Disables the button.
84
+ */
85
+ disabled?: boolean;
86
+ }
87
+
88
+ /** Text button sizes: the slot content provides the accessible name. */
89
+ export interface UiInputGroupButtonTextProps extends UiInputGroupButtonBaseProps {
90
+ /**
91
+ * The size of the button. `xs`/`sm` render text buttons.
92
+ * @default 'xs'
93
+ */
94
+ size?: 'xs' | 'sm';
95
+
96
+ /**
97
+ * Accessible label for the button. Optional for text sizes — the visible
98
+ * label already names the button.
99
+ */
100
+ ariaLabel?: string;
101
+ }
102
+
103
+ /** Icon-only button sizes: an accessible label is mandatory. */
104
+ export interface UiInputGroupButtonIconProps extends UiInputGroupButtonBaseProps {
105
+ /**
106
+ * The size of the button. `icon-xs`/`icon-sm` render icon-only buttons.
107
+ */
108
+ size: 'icon-xs' | 'icon-sm';
109
+
110
+ /**
111
+ * Accessible label for the button. **Required** for the icon-only sizes —
112
+ * without it the button has no accessible name.
113
+ */
114
+ ariaLabel: string;
115
+ }
116
+
117
+ /**
118
+ * A compact action button sized for use inside `UiInputGroupAddon` — clear,
119
+ * copy, submit, visibility toggles, and similar actions on the value.
120
+ * The props form a discriminated union on `size`: the icon-only sizes
121
+ * (`icon-xs`, `icon-sm`) require `ariaLabel`, so an icon button without an
122
+ * accessible name is a type error.
123
+ * @category Form Inputs
124
+ * @useCases copy input value, clear field, submit search, toggle password visibility, send message
125
+ * @keywords input button, inline action, field action, compact button
126
+ * @related UiInputGroup, UiInputGroupAddon, UiButton
127
+ */
128
+ export type UiInputGroupButtonProps =
129
+ | UiInputGroupButtonTextProps
130
+ | UiInputGroupButtonIconProps;
131
+
132
+ /**
133
+ * The single-line text control of a `UiInputGroup`. Replaces `UiInput`
134
+ * inside a group: the border, background, and focus ring are drawn by the
135
+ * group container instead of the control. Native input attributes
136
+ * (`type`, `placeholder`, `disabled`, `required`, `name`, …) are forwarded
137
+ * to the underlying `<input>`.
138
+ * @category Form Inputs
139
+ * @useCases text entry inside input group, search field, url field, currency amount
140
+ * @keywords input, group input, control, textbox
141
+ * @related UiInputGroup, UiInput
142
+ */
143
+ export interface UiInputGroupInputProps {
144
+ /**
145
+ * The text value of the control.
146
+ * - Omit for uncontrolled mode
147
+ * - Use `v-model` for controlled mode
148
+ */
149
+ modelValue?: string | number;
150
+ }
151
+
152
+ /**
153
+ * The multi-line text control of a `UiInputGroup`. Replaces `UiTextarea`
154
+ * inside a group: the border, background, and focus ring are drawn by the
155
+ * group container instead of the control. Pair with
156
+ * `<UiInputGroup type="textarea">` and `block-start`/`block-end` addons.
157
+ * Native textarea attributes (`placeholder`, `disabled`, `rows`, …) are
158
+ * forwarded to the underlying `<textarea>`.
159
+ * @category Form Inputs
160
+ * @useCases chat message box with actions, code editor field, comment box with counter
161
+ * @keywords textarea, group textarea, control, multiline
162
+ * @related UiInputGroup, UiTextarea
163
+ */
164
+ export interface UiInputGroupTextareaProps {
165
+ /**
166
+ * The text value of the control.
167
+ * - Omit for uncontrolled mode
168
+ * - Use `v-model` for controlled mode
169
+ */
170
+ modelValue?: string | number;
171
+ }
@@ -6,11 +6,16 @@ defineOptions({
6
6
  name: 'UiLabel',
7
7
  });
8
8
 
9
- const props = defineProps<UiLabelProps>();
9
+ const props = withDefaults(defineProps<UiLabelProps>(), {
10
+ error: false,
11
+ });
10
12
  </script>
11
13
 
12
14
  <template>
13
- <ShadcnLabel :for="props.for">
15
+ <ShadcnLabel
16
+ :for="props.for"
17
+ :class="props.error ? 'text-border-input-error' : ''"
18
+ >
14
19
  <slot />
15
20
  </ShadcnLabel>
16
21
  </template>
@@ -12,4 +12,12 @@ export interface UiLabelProps {
12
12
  * When provided, clicking the label will focus the associated element.
13
13
  */
14
14
  for: string;
15
+
16
+ /**
17
+ * Renders the label in the error color (`border/input/error`) to match an
18
+ * invalid control. Inside a `UiField` with `data-invalid` the label colors
19
+ * automatically; use this prop for labels outside a field.
20
+ * @default false
21
+ */
22
+ error?: boolean;
15
23
  }
@@ -3,8 +3,20 @@ import { cva } from 'class-variance-authority';
3
3
 
4
4
  export { default as Button } from './Button.vue';
5
5
 
6
+ // Buttons carry no fixed height: like the inputs, they grow from the content
7
+ // (label line-height or icon size) plus vertical padding. The 1px boundary is
8
+ // painted as an inset outline instead of a border — an outline takes no layout
9
+ // space (Figma "inside stroke"), so the computed heights stay exact:
10
+ // sm 14px line + 2×4px = 22px → floored to 24px by `min-h-6`
11
+ // (WCAG 2.5.8 minimum touch target; flex centering absorbs the gap)
12
+ // default 20px line + 2×8px = 36px (was h-9)
13
+ // lg 20px line + 2×10px = 40px (was h-10)
14
+ // icon-xs 12px icon + 2×6px = 24px icon 20px icon + 2×8px = 36px
15
+ // icon-sm 16px icon + 2×4px = 24px icon-lg 24px icon + 2×8px = 40px
16
+ // The focus treatment is the outline-based companion (`ui-focus-ring-outline`)
17
+ // since there is no border left to recolor.
6
18
  export const buttonVariants = cva(
7
- 'inline-flex items-center justify-center whitespace-nowrap border border-transparent transition-all relative disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 ui-focus-ring aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
19
+ 'inline-flex items-center justify-center whitespace-nowrap outline outline-1 -outline-offset-1 outline-transparent transition-all relative disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 ui-focus-ring-outline aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:outline-border-input-error',
8
20
  {
9
21
  variants: {
10
22
  variant: {
@@ -13,7 +25,7 @@ export const buttonVariants = cva(
13
25
  destructive:
14
26
  'bg-background-button-danger-button text-content-on-button-danger-button hover-layer hover-layer-default',
15
27
  outline:
16
- 'border border-input bg-transparent text-foreground hover:bg-background-surface-muted-subtle',
28
+ 'outline-input bg-transparent text-foreground hover:bg-background-surface-muted-subtle',
17
29
  secondary:
18
30
  'bg-background-button-secondary-button text-content-on-button-secondary-button hover-layer hover-layer-default',
19
31
  ghost: 'text-foreground hover:bg-background-surface-muted-subtle',
@@ -21,21 +33,19 @@ export const buttonVariants = cva(
21
33
  },
22
34
  size: {
23
35
  // Text sizes — render label with optional start/end icons.
24
- // Heights are pinned via `h-*` (spacing token = 4px × N) so buttons
25
- // line up with their icon-only counterparts (default↔icon, lg↔icon-lg).
26
- sm: 'rounded-sm gap-1 px-2 py-1 label-12-medium [&_svg]:size-3',
27
- default: 'h-9 rounded-md gap-2 px-4 py-2 body-14-medium [&_svg]:size-4',
28
- lg: 'h-10 rounded-md gap-2 px-6 py-2 body-14-medium [&_svg]:size-4',
36
+ sm: 'rounded-sm gap-1 min-h-6 px-2 py-1 label-12-medium [&_svg]:size-3',
37
+ default: 'rounded-md gap-2 px-4 py-2 body-14-medium [&_svg]:size-4',
38
+ lg: 'rounded-md gap-2 px-6 py-2.5 body-14-medium [&_svg]:size-4',
29
39
 
30
40
  // Icon-only sizes — render a single icon (no label, no gap).
31
- // The outer square is pinned via `size-*` (spacing token = 4px × N);
41
+ // The square derives from the icon plus equal padding on every side;
32
42
  // the inner `[&_svg]:size-*` controls the icon itself.
33
43
  // `icon-xs` and `icon-sm-no-padding` are intended for the `ghost` variant only.
34
- 'icon-sm-no-padding': 'size-4 rounded-sm p-0 [&_svg]:size-4',
35
- 'icon-xs': 'size-6 rounded-sm p-0 [&_svg]:size-3',
36
- 'icon-sm': 'size-6 rounded-sm p-0 [&_svg]:size-4',
37
- icon: 'size-9 rounded-sm p-0 [&_svg]:size-5',
38
- 'icon-lg': 'size-10 rounded-md p-0 [&_svg]:size-6',
44
+ 'icon-sm-no-padding': 'rounded-sm p-0 [&_svg]:size-4',
45
+ 'icon-xs': 'rounded-sm p-1.5 [&_svg]:size-3',
46
+ 'icon-sm': 'rounded-sm p-1 [&_svg]:size-4',
47
+ icon: 'rounded-sm p-2 [&_svg]:size-5',
48
+ 'icon-lg': 'rounded-md p-2 [&_svg]:size-6',
39
49
  },
40
50
  },
41
51
  defaultVariants: {
@@ -5,6 +5,10 @@ import type { ButtonGroupVariants } from '.';
5
5
  import { Primitive } from 'reka-ui';
6
6
  import { cn } from '@/lib/utils';
7
7
 
8
+ defineOptions({
9
+ name: 'UiButtonGroupText',
10
+ });
11
+
8
12
  interface Props extends PrimitiveProps {
9
13
  class?: HTMLAttributes['class'];
10
14
  orientation?: ButtonGroupVariants['orientation'];
@@ -10,10 +10,14 @@ export const buttonGroupVariants = cva(
10
10
  {
11
11
  variants: {
12
12
  orientation: {
13
+ // `border-l-0` / `border-t-0` collapse the seams of bordered children
14
+ // (text affixes, select triggers, inputs). Buttons paint their boundary
15
+ // as an inset outline (no layout border), so adjacent buttons instead
16
+ // overlap by 1px to merge their outlines into a single seam.
13
17
  horizontal:
14
- '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
18
+ '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none [&>[data-slot=button]+[data-slot=button]]:-ml-px',
15
19
  vertical:
16
- 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none',
20
+ 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none [&>[data-slot=button]+[data-slot=button]]:-mt-px',
17
21
  },
18
22
  },
19
23
  defaultVariants: {
@@ -59,7 +59,7 @@ const hasDefaultSlotContent = computed(() =>
59
59
  v-if="hasDefaultSlotContent || getContent()"
60
60
  role="alert"
61
61
  data-slot="field-error"
62
- :class="cn('body-14-regular text-destructive', props.class)"
62
+ :class="cn('body-14-regular text-border-input-error', props.class)"
63
63
  >
64
64
  <slot v-if="hasDefaultSlotContent" />
65
65
 
@@ -16,7 +16,7 @@ const props = defineProps<{
16
16
  :for="props.for"
17
17
  :class="
18
18
  cn(
19
- 'group/field-label peer/field-label flex w-fit items-center gap-2 leading-snug text-content-on-surface-muted body-14-medium group-data-[disabled=true]/field:opacity-50',
19
+ 'group/field-label peer/field-label flex w-fit items-center gap-2 leading-snug text-content-on-surface-muted body-14-medium group-data-[disabled=true]/field:opacity-50 group-data-[invalid=true]/field:text-border-input-error',
20
20
  'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:border-border-input-default',
21
21
  'has-data-[state=checked]:bg-background-surface-selected has-data-[state=checked]:border-transparent',
22
22
  '[&>[data-slot=field]]:p-4',
@@ -1,8 +1,14 @@
1
1
  import type { VariantProps } from 'class-variance-authority';
2
2
  import { cva } from 'class-variance-authority';
3
3
 
4
+ // `data-[invalid=true]` is the single error switch: it sets the error color at
5
+ // the top and everything inside follows via CSS — inheriting children (plain
6
+ // text, input values, filenames) pick it up directly, and children with their
7
+ // own color (labels, addons, input-group buttons, control borders) override it
8
+ // through `group-data-[invalid=true]/field:*` variants. Placeholders keep
9
+ // their muted color.
4
10
  export const fieldVariants = cva(
5
- 'group/field flex w-full gap-3 data-[invalid=true]:text-destructive',
11
+ 'group/field flex w-full gap-3 data-[invalid=true]:text-border-input-error',
6
12
  {
7
13
  variants: {
8
14
  orientation: {
@@ -27,7 +27,10 @@ const modelValue = useVModel(props, 'modelValue', emits, {
27
27
  cn(
28
28
  'file:text-foreground placeholder:text-content-on-surface-muted selection:bg-primary selection:text-primary-foreground border-input h-9 w-full min-w-0 rounded-md border bg-background-input-default px-3 py-1 label-16-regular transition-[color] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:label-14-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:label-14-regular',
29
29
  'ui-focus-ring',
30
- 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
30
+ 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-border-input-error',
31
+ // Cascaded error state from a `data-invalid` UiField (text color is
32
+ // inherited from the field root; the placeholder keeps its own color).
33
+ 'group-data-[invalid=true]/field:border-border-input-error',
31
34
  props.class,
32
35
  )
33
36
  "