@lostgradient/cinder 0.13.0 → 0.15.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +6 -6
  3. package/components.json +49 -1
  4. package/dist/components/chat/conversation-model.d.ts +1 -1
  5. package/dist/components/chat/index.d.ts +5 -3
  6. package/dist/components/chat/index.js +110 -96
  7. package/dist/components/chat-conversation-header/index.js +3 -3
  8. package/dist/components/diff-viewer/index.js +32 -32
  9. package/dist/components/json-schema-editor/index.js +32 -32
  10. package/dist/components/markdown-editor/index.js +20 -20
  11. package/dist/components/review-editor/index.js +88 -88
  12. package/dist/components/selectable-row/index.d.ts +5 -0
  13. package/dist/components/selectable-row/index.js +288 -0
  14. package/dist/components/selectable-row/selectable-row.css +128 -0
  15. package/dist/components/selectable-row/selectable-row.css.d.ts +1 -0
  16. package/dist/components/selectable-row/selectable-row.schema.d.ts +3 -0
  17. package/dist/components/selectable-row/selectable-row.schema.js +155 -0
  18. package/dist/components/selectable-row/selectable-row.svelte.d.ts +24 -0
  19. package/dist/components/selectable-row/selectable-row.types.d.ts +84 -0
  20. package/dist/components/selectable-row/selectable-row.variables.d.ts +2 -0
  21. package/dist/components/selectable-row/selectable-row.variables.js +68 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +3946 -3712
  24. package/dist/server/components/chat/index.js +14 -4
  25. package/dist/server/components/chat-conversation-header/index.js +2 -2
  26. package/dist/server/components/diff-viewer/index.js +2 -2
  27. package/dist/server/components/json-schema-editor/index.js +2 -2
  28. package/dist/server/components/markdown-editor/index.js +1 -1
  29. package/dist/server/components/review-editor/index.js +51 -51
  30. package/dist/server/components/selectable-row/index.js +12 -0
  31. package/dist/server/components/side-navigation/index.js +2 -2
  32. package/dist/server/index.js +32 -27
  33. package/dist/server/{index.server-3w72dxz7.js → index.server-0jhra85x.js} +4 -4
  34. package/dist/server/index.server-1gzbrhhh.js +151 -0
  35. package/dist/server/{index.server-ck3fwrab.js → index.server-46cjwcqw.js} +1 -1
  36. package/dist/server/{index.server-2zdbz3rj.js → index.server-8rmtb8vx.js} +4 -4
  37. package/dist/server/{index.server-grgv455a.js → index.server-9ra3xv88.js} +26 -26
  38. package/dist/server/{index.server-4x4hgvqe.js → index.server-czf35aba.js} +127 -116
  39. package/dist/server/{index.server-2s5h1d05.js → index.server-nphtb2ey.js} +1 -1
  40. package/dist/server/{index.server-p071e531.js → index.server-t1x9h8cb.js} +1 -1
  41. package/dist/server/{index.server-v3arexq8.js → index.server-vhyjjx9z.js} +32 -32
  42. package/package.json +37 -6
  43. package/src/components/chat/chat.examples.json +6 -0
  44. package/src/components/chat/container/chat.svelte +1 -1
  45. package/src/components/chat/conversation-model.ts +11 -0
  46. package/src/components/chat/index.ts +25 -3
  47. package/src/components/selectable-row/index.ts +12 -0
  48. package/src/components/selectable-row/selectable-row.css +128 -0
  49. package/src/components/selectable-row/selectable-row.examples.json +13 -0
  50. package/src/components/selectable-row/selectable-row.schema.json +95 -0
  51. package/src/components/selectable-row/selectable-row.schema.ts +104 -0
  52. package/src/components/selectable-row/selectable-row.svelte +95 -0
  53. package/src/components/selectable-row/selectable-row.types.ts +97 -0
  54. package/src/components/selectable-row/selectable-row.variables.json +8 -0
  55. package/src/components/selectable-row/selectable-row.variables.ts +10 -0
  56. package/src/index.ts +9 -0
  57. package/src/styles/components.css +1 -0
@@ -0,0 +1,95 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "density": {
6
+ "enum": ["comfortable", "condensed"],
7
+ "description": "Density token surfaced as `data-cinder-density`.",
8
+ "default": "comfortable"
9
+ },
10
+ "selected": {
11
+ "type": "boolean",
12
+ "description": "Whether the primary action represents the selected or current row.",
13
+ "default": false
14
+ },
15
+ "selectedState": {
16
+ "enum": ["pressed", "current"],
17
+ "description": "Accessible state mapping for selected button rows. Links always use `aria-current`.",
18
+ "default": "pressed"
19
+ },
20
+ "href": {
21
+ "type": "string",
22
+ "description": "Destination that renders the primary action as a native anchor."
23
+ },
24
+ "rel": {
25
+ "anyOf": [
26
+ {
27
+ "type": "string"
28
+ },
29
+ {
30
+ "type": "null"
31
+ }
32
+ ],
33
+ "description": "`rel` forwarded to the primary anchor and de-duplicated case-insensitively; `noopener noreferrer` is merged when `target=\"_blank\"`."
34
+ },
35
+ "currentValue": {
36
+ "enum": ["page", "step", "location", "date", "time", "true"],
37
+ "description": "`aria-current` value emitted for a selected link or a selected button using `selectedState=\"current\"`.",
38
+ "default": "true"
39
+ },
40
+ "type": {
41
+ "enum": ["button", "submit", "reset"],
42
+ "description": "Native button type.",
43
+ "default": "button"
44
+ },
45
+ "class": {
46
+ "type": "string",
47
+ "description": "Additional classes merged with `.cinder-selectable-row`."
48
+ },
49
+ "style": {
50
+ "type": "string",
51
+ "description": "Inline style string applied to the `.cinder-selectable-row` root."
52
+ }
53
+ },
54
+ "additionalProperties": false,
55
+ "metadata": {
56
+ "unsupportedProps": [
57
+ {
58
+ "name": "description",
59
+ "reason": "function-or-snippet",
60
+ "description": "Secondary description below the title."
61
+ },
62
+ {
63
+ "name": "leading",
64
+ "reason": "function-or-snippet",
65
+ "description": "Leading visual such as an icon, avatar, marker, or status dot."
66
+ },
67
+ {
68
+ "name": "meta",
69
+ "reason": "function-or-snippet",
70
+ "description": "Tertiary metadata such as a timestamp, status, or compact badge."
71
+ },
72
+ {
73
+ "name": "onclick",
74
+ "reason": "function-or-snippet",
75
+ "description": "Called when the native primary button activates. Optional for submit and reset buttons."
76
+ },
77
+ {
78
+ "name": "target",
79
+ "reason": "unknown-shape",
80
+ "description": "Browsing context for the primary anchor. `_blank` merges `noopener noreferrer` into `rel`."
81
+ },
82
+ {
83
+ "name": "title",
84
+ "reason": "function-or-snippet",
85
+ "required": true,
86
+ "description": "Primary row label. Required."
87
+ },
88
+ {
89
+ "name": "trailingActions",
90
+ "reason": "function-or-snippet",
91
+ "description": "Independent controls rendered as siblings after the primary action."
92
+ }
93
+ ]
94
+ }
95
+ }
@@ -0,0 +1,104 @@
1
+ import type { ComponentSchema } from '../../schema-types';
2
+
3
+ const schema = {
4
+ $schema: 'https://json-schema.org/draft/2020-12/schema',
5
+ type: 'object',
6
+ properties: {
7
+ density: {
8
+ enum: ['comfortable', 'condensed'],
9
+ description: 'Density token surfaced as `data-cinder-density`.',
10
+ default: 'comfortable',
11
+ },
12
+ selected: {
13
+ type: 'boolean',
14
+ description: 'Whether the primary action represents the selected or current row.',
15
+ default: false,
16
+ },
17
+ selectedState: {
18
+ enum: ['pressed', 'current'],
19
+ description:
20
+ 'Accessible state mapping for selected button rows. Links always use `aria-current`.',
21
+ default: 'pressed',
22
+ },
23
+ href: {
24
+ type: 'string',
25
+ description: 'Destination that renders the primary action as a native anchor.',
26
+ },
27
+ rel: {
28
+ anyOf: [
29
+ {
30
+ type: 'string',
31
+ },
32
+ {
33
+ type: 'null',
34
+ },
35
+ ],
36
+ description:
37
+ '`rel` forwarded to the primary anchor and de-duplicated case-insensitively; `noopener noreferrer` is merged when `target="_blank"`.',
38
+ },
39
+ currentValue: {
40
+ enum: ['page', 'step', 'location', 'date', 'time', 'true'],
41
+ description:
42
+ '`aria-current` value emitted for a selected link or a selected button using `selectedState="current"`.',
43
+ default: 'true',
44
+ },
45
+ type: {
46
+ enum: ['button', 'submit', 'reset'],
47
+ description: 'Native button type.',
48
+ default: 'button',
49
+ },
50
+ class: {
51
+ type: 'string',
52
+ description: 'Additional classes merged with `.cinder-selectable-row`.',
53
+ },
54
+ style: {
55
+ type: 'string',
56
+ description: 'Inline style string applied to the `.cinder-selectable-row` root.',
57
+ },
58
+ },
59
+ additionalProperties: false,
60
+ metadata: {
61
+ unsupportedProps: [
62
+ {
63
+ name: 'description',
64
+ reason: 'function-or-snippet',
65
+ description: 'Secondary description below the title.',
66
+ },
67
+ {
68
+ name: 'leading',
69
+ reason: 'function-or-snippet',
70
+ description: 'Leading visual such as an icon, avatar, marker, or status dot.',
71
+ },
72
+ {
73
+ name: 'meta',
74
+ reason: 'function-or-snippet',
75
+ description: 'Tertiary metadata such as a timestamp, status, or compact badge.',
76
+ },
77
+ {
78
+ name: 'onclick',
79
+ reason: 'function-or-snippet',
80
+ description:
81
+ 'Called when the native primary button activates. Optional for submit and reset buttons.',
82
+ },
83
+ {
84
+ name: 'target',
85
+ reason: 'unknown-shape',
86
+ description:
87
+ 'Browsing context for the primary anchor. `_blank` merges `noopener noreferrer` into `rel`.',
88
+ },
89
+ {
90
+ name: 'title',
91
+ reason: 'function-or-snippet',
92
+ required: true,
93
+ description: 'Primary row label. Required.',
94
+ },
95
+ {
96
+ name: 'trailingActions',
97
+ reason: 'function-or-snippet',
98
+ description: 'Independent controls rendered as siblings after the primary action.',
99
+ },
100
+ ],
101
+ },
102
+ } satisfies ComponentSchema;
103
+
104
+ export default schema as ComponentSchema;
@@ -0,0 +1,95 @@
1
+ <script lang="ts" module>
2
+ export {};
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ import { classNames } from '../../utilities/class-names.ts';
7
+ let { density = 'comfortable', selected = false, selectedState = 'pressed', href, currentValue = 'true', type = 'button', leading, title, description, meta, trailingActions, class: className, style, ...rest } = $props();
8
+ const isLink = $derived(href !== undefined);
9
+ const selectedDataAttribute = $derived(selected ? '' : undefined);
10
+ const ariaPressed = $derived(!isLink && selectedState === 'pressed' ? selected : undefined);
11
+ const ariaCurrent = $derived(selected && (isLink || selectedState === 'current') ? currentValue : undefined);
12
+ const anchorAttributes = $derived(rest);
13
+ const buttonAttributes = $derived(rest);
14
+ const resolvedRel = $derived.by(() => {
15
+ if (!isLink)
16
+ return undefined;
17
+ const consumerTokens = (anchorAttributes.rel ?? '').split(/\s+/).filter(Boolean);
18
+ const seen = new Set();
19
+ const merged = [];
20
+ for (const token of consumerTokens) {
21
+ const normalizedToken = token.toLowerCase();
22
+ if (!seen.has(normalizedToken)) {
23
+ seen.add(normalizedToken);
24
+ merged.push(token);
25
+ }
26
+ }
27
+ if (anchorAttributes.target?.toLowerCase() === '_blank') {
28
+ for (const token of ['noopener', 'noreferrer']) {
29
+ if (!seen.has(token)) {
30
+ seen.add(token);
31
+ merged.push(token);
32
+ }
33
+ }
34
+ }
35
+ return merged.length > 0 ? merged.join(' ') : undefined;
36
+ });
37
+ </script>
38
+
39
+ <div
40
+ class={classNames(
41
+ 'cinder-selectable-row',
42
+ leading && 'cinder-selectable-row--has-leading',
43
+ trailingActions && 'cinder-selectable-row--has-trailing-actions',
44
+ className,
45
+ )}
46
+ {style}
47
+ data-cinder-density={density}
48
+ data-cinder-selected={selectedDataAttribute}
49
+ >
50
+ {#if isLink}
51
+ <a
52
+ {...anchorAttributes}
53
+ class="cinder-selectable-row__primary"
54
+ {href}
55
+ rel={resolvedRel}
56
+ aria-current={ariaCurrent}
57
+ >
58
+ {#if leading}
59
+ <span class="cinder-selectable-row__leading">{@render leading()}</span>
60
+ {/if}
61
+ <span class="cinder-selectable-row__body">
62
+ <span class="cinder-selectable-row__title">{@render title()}</span>
63
+ {#if description}
64
+ <span class="cinder-selectable-row__description">{@render description()}</span>
65
+ {/if}
66
+ {#if meta}<span class="cinder-selectable-row__meta">{@render meta()}</span>{/if}
67
+ </span>
68
+ </a>
69
+ {:else}
70
+ <button
71
+ {...buttonAttributes}
72
+ class="cinder-selectable-row__primary"
73
+ {type}
74
+ aria-pressed={ariaPressed}
75
+ aria-current={ariaCurrent}
76
+ >
77
+ {#if leading}
78
+ <span class="cinder-selectable-row__leading">{@render leading()}</span>
79
+ {/if}
80
+ <span class="cinder-selectable-row__body">
81
+ <span class="cinder-selectable-row__title">{@render title()}</span>
82
+ {#if description}
83
+ <span class="cinder-selectable-row__description">{@render description()}</span>
84
+ {/if}
85
+ {#if meta}<span class="cinder-selectable-row__meta">{@render meta()}</span>{/if}
86
+ </span>
87
+ </button>
88
+ {/if}
89
+
90
+ {#if trailingActions}
91
+ <div class="cinder-selectable-row__trailing-actions">
92
+ {@render trailingActions()}
93
+ </div>
94
+ {/if}
95
+ </div>
@@ -0,0 +1,97 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
3
+
4
+ export type SelectableRowDensity = 'comfortable' | 'condensed';
5
+ export type SelectableRowSelectedState = 'pressed' | 'current';
6
+ export type SelectableRowCurrentValue = 'page' | 'step' | 'location' | 'date' | 'time' | 'true';
7
+
8
+ type SelectableRowSharedProps = {
9
+ /** Density token surfaced as `data-cinder-density`. @default "comfortable" */
10
+ density?: SelectableRowDensity;
11
+ /** Whether the primary action represents the selected or current row. @default false */
12
+ selected?: boolean;
13
+ /** Leading visual such as an icon, avatar, marker, or status dot. */
14
+ leading?: Snippet;
15
+ /** Primary row label. Required so the native action has visible text and an accessible name. */
16
+ title: Snippet;
17
+ /** Secondary description below the title. */
18
+ description?: Snippet;
19
+ /** Tertiary metadata such as a timestamp, status, or compact badge. */
20
+ meta?: Snippet;
21
+ /** Independent controls rendered as siblings after the primary action. */
22
+ trailingActions?: Snippet;
23
+ /** Additional classes merged with `.cinder-selectable-row`. */
24
+ class?: string;
25
+ /** Inline style string applied to the `.cinder-selectable-row` root. */
26
+ style?: string;
27
+ };
28
+
29
+ type SelectableRowButtonProps = SelectableRowSharedProps &
30
+ Omit<
31
+ HTMLButtonAttributes,
32
+ 'aria-current' | 'aria-pressed' | 'class' | 'href' | 'style' | 'title' | 'type'
33
+ > & {
34
+ href?: undefined;
35
+ /** Called when the native primary button activates. Optional for submit and reset buttons. */
36
+ onclick?: (event: MouseEvent) => void;
37
+ /** Native button type. @default "button" */
38
+ type?: 'button' | 'submit' | 'reset';
39
+ /** Accessible state mapping for selected button rows. @default "pressed" */
40
+ selectedState?: SelectableRowSelectedState;
41
+ /** `aria-current` value emitted when `selectedState="current"` and the row is selected. @default "true" */
42
+ currentValue?: SelectableRowCurrentValue;
43
+ };
44
+
45
+ type SelectableRowLinkProps = SelectableRowSharedProps &
46
+ Omit<
47
+ HTMLAnchorAttributes,
48
+ 'aria-current' | 'aria-pressed' | 'class' | 'href' | 'rel' | 'style' | 'target' | 'title'
49
+ > & {
50
+ /** Destination that renders the primary action as a native anchor. */
51
+ href: string;
52
+ /** Browsing context for the primary anchor. `_blank` merges `noopener noreferrer` into `rel`. */
53
+ target?: HTMLAnchorAttributes['target'];
54
+ /** `rel` forwarded to the primary anchor and de-duplicated case-insensitively; `noopener noreferrer` is merged when `target="_blank"`. */
55
+ rel?: HTMLAnchorAttributes['rel'];
56
+ /** `aria-current` value emitted when the linked row is selected. @default "true" */
57
+ currentValue?: SelectableRowCurrentValue;
58
+ selectedState?: never;
59
+ type?: never;
60
+ };
61
+
62
+ /** Props for SelectableRow. Pass `href` for a link or `onclick` for a button. */
63
+ export type SelectableRowProps = SelectableRowButtonProps | SelectableRowLinkProps;
64
+
65
+ /** Cinder-specific props used by the schema generator. */
66
+ export interface SelectableRowSchemaProps {
67
+ /** Density token surfaced as `data-cinder-density`. @default "comfortable" */
68
+ density?: SelectableRowDensity;
69
+ /** Whether the primary action represents the selected or current row. @default false */
70
+ selected?: boolean;
71
+ /** Accessible state mapping for selected button rows. Links always use `aria-current`. @default "pressed" */
72
+ selectedState?: SelectableRowSelectedState;
73
+ /** Destination that renders the primary action as a native anchor. */
74
+ href?: string;
75
+ /** Browsing context for the primary anchor. `_blank` merges `noopener noreferrer` into `rel`. */
76
+ target?: HTMLAnchorAttributes['target'];
77
+ /** `rel` forwarded to the primary anchor and de-duplicated case-insensitively; `noopener noreferrer` is merged when `target="_blank"`. */
78
+ rel?: HTMLAnchorAttributes['rel'];
79
+ /** `aria-current` value emitted for a selected link or a selected button using `selectedState="current"`. @default "true" */
80
+ currentValue?: SelectableRowCurrentValue;
81
+ /** Native button type. @default "button" */
82
+ type?: 'button' | 'submit' | 'reset';
83
+ /** Leading visual such as an icon, avatar, marker, or status dot. */
84
+ leading?: Snippet;
85
+ /** Primary row label. Required. */
86
+ title: Snippet;
87
+ /** Secondary description below the title. */
88
+ description?: Snippet;
89
+ /** Tertiary metadata such as a timestamp, status, or compact badge. */
90
+ meta?: Snippet;
91
+ /** Independent controls rendered as siblings after the primary action. */
92
+ trailingActions?: Snippet;
93
+ /** Additional classes merged with `.cinder-selectable-row`. */
94
+ class?: string;
95
+ /** Inline style string applied to the `.cinder-selectable-row` root. */
96
+ style?: string;
97
+ }
@@ -0,0 +1,8 @@
1
+ [
2
+ "--cinder-selectable-row-column-gap",
3
+ "--cinder-selectable-row-content-gap",
4
+ "--cinder-selectable-row-leading-gap",
5
+ "--cinder-selectable-row-padding-block",
6
+ "--cinder-selectable-row-padding-inline",
7
+ "--cinder-selectable-row-trailing-actions-gap"
8
+ ]
@@ -0,0 +1,10 @@
1
+ const variables: readonly string[] = [
2
+ '--cinder-selectable-row-column-gap',
3
+ '--cinder-selectable-row-content-gap',
4
+ '--cinder-selectable-row-leading-gap',
5
+ '--cinder-selectable-row-padding-block',
6
+ '--cinder-selectable-row-padding-inline',
7
+ '--cinder-selectable-row-trailing-actions-gap',
8
+ ];
9
+
10
+ export default variables;
package/src/index.ts CHANGED
@@ -773,6 +773,15 @@ export type { SegmentedControlProps } from './components/segmented-control/index
773
773
  export { default as Select } from './components/select/index.ts';
774
774
  export type { SelectOption, SelectProps } from './components/select/index.ts';
775
775
 
776
+ export { default as SelectableRow } from './components/selectable-row/index.ts';
777
+ export type {
778
+ SelectableRowCurrentValue,
779
+ SelectableRowDensity,
780
+ SelectableRowProps,
781
+ SelectableRowSchemaProps,
782
+ SelectableRowSelectedState,
783
+ } from './components/selectable-row/index.ts';
784
+
776
785
  export { default as SelectionPopover } from './components/selection-popover/index.ts';
777
786
  export type {
778
787
  SelectionPopoverPosition,
@@ -139,6 +139,7 @@
139
139
  @import '../components/section-heading/section-heading.css';
140
140
  @import '../components/select/select.css';
141
141
  @import '../components/segmented-control/segmented-control.css';
142
+ @import '../components/selectable-row/selectable-row.css';
142
143
  @import '../components/selection-popover/selection-popover.css';
143
144
  @import '../components/spectrogram/spectrogram.css';
144
145
  @import '../components/spectrum-chart/spectrum-chart.css';