@lostgradient/cinder 0.12.0 → 0.13.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 (124) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components.json +9 -6
  3. package/dist/components/accordion/index.js +14 -11
  4. package/dist/components/accordion-item/accordion-item.css +20 -7
  5. package/dist/components/accordion-item/accordion-item.schema.js +5 -1
  6. package/dist/components/accordion-item/accordion-item.types.d.ts +4 -0
  7. package/dist/components/accordion-item/accordion-item.variables.js +13 -2
  8. package/dist/components/accordion-item/index.js +14 -11
  9. package/dist/components/action-row/action-row.css +20 -9
  10. package/dist/components/action-row/action-row.schema.js +5 -1
  11. package/dist/components/action-row/action-row.types.d.ts +43 -0
  12. package/dist/components/action-row/action-row.variables.js +12 -2
  13. package/dist/components/chat/chat.svelte.d.ts +1 -0
  14. package/dist/components/diff-viewer/index.js +201 -101
  15. package/dist/components/json-schema-editor/index.js +229 -129
  16. package/dist/components/markdown-editor/index.js +207 -107
  17. package/dist/components/review-editor/index.js +291 -191
  18. package/dist/components/schedule-builder/index.js +205 -105
  19. package/dist/components/segment/index.js +119 -56
  20. package/dist/components/segment/segment.schema.d.ts +2 -2
  21. package/dist/components/segment/segment.schema.js +71 -33
  22. package/dist/components/segment/segment.svelte.d.ts +2 -1
  23. package/dist/components/segment/segment.types.d.ts +67 -10
  24. package/dist/components/segmented-control/index.js +193 -93
  25. package/dist/components/segmented-control/segmented-control-state.svelte.d.ts +4 -4
  26. package/dist/components/segmented-control/segmented-control.css +26 -6
  27. package/dist/components/segmented-control/segmented-control.schema.js +3 -3
  28. package/dist/components/segmented-control/segmented-control.svelte.d.ts +2 -1
  29. package/dist/components/segmented-control/segmented-control.types.d.ts +4 -4
  30. package/dist/components/side-navigation/side-navigation.css +2 -1
  31. package/dist/components/side-navigation/side-navigation.schema.js +9 -6
  32. package/dist/components/side-navigation/side-navigation.types.d.ts +11 -0
  33. package/dist/components/side-navigation/side-navigation.variables.js +2 -2
  34. package/dist/components/sidebar/index.d.ts +1 -0
  35. package/dist/components/sidebar/index.js +9 -3
  36. package/dist/components/sidebar/sidebar.constants.d.ts +12 -0
  37. package/dist/components/stat/stat.css +16 -8
  38. package/dist/components/stat/stat.schema.js +5 -1
  39. package/dist/components/stat/stat.types.d.ts +19 -0
  40. package/dist/components/stat/stat.variables.js +11 -2
  41. package/dist/components/stat-group/stat-group.css +7 -4
  42. package/dist/components/stat-group/stat-group.schema.js +5 -1
  43. package/dist/components/stat-group/stat-group.types.d.ts +27 -0
  44. package/dist/components/stat-group/stat-group.variables.js +6 -2
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +479 -368
  47. package/dist/server/components/accordion/index.js +2 -2
  48. package/dist/server/components/accordion-item/index.js +2 -2
  49. package/dist/server/components/diff-viewer/index.js +4 -4
  50. package/dist/server/components/json-schema-editor/index.js +4 -4
  51. package/dist/server/components/markdown-editor/index.js +3 -3
  52. package/dist/server/components/review-editor/index.js +4 -4
  53. package/dist/server/components/schedule-builder/index.js +3 -3
  54. package/dist/server/components/segment/index.js +2 -2
  55. package/dist/server/components/segmented-control/index.js +3 -3
  56. package/dist/server/components/sidebar/index.js +7 -3
  57. package/dist/server/index.js +19 -13
  58. package/dist/server/{index.server-cf6pxeyg.js → index.server-0rzd71e0.js} +1 -1
  59. package/dist/server/{index.server-jgb8yh5k.js → index.server-2m1kenak.js} +1 -1
  60. package/dist/server/{index.server-jfrssta6.js → index.server-ck3fwrab.js} +1 -1
  61. package/dist/server/{index.server-sedjxt36.js → index.server-e89qfamd.js} +79 -35
  62. package/dist/server/{index.server-pag862vz.js → index.server-grgv455a.js} +2 -2
  63. package/dist/server/{index.server-y83kqayt.js → index.server-h3nzp8g8.js} +1 -1
  64. package/dist/server/{index.server-2qj6s2mh.js → index.server-j570vb03.js} +7 -3
  65. package/dist/server/index.server-jwvxxjvc.js +50 -0
  66. package/dist/server/{index.server-xeqtpv61.js → index.server-mr68brd6.js} +49 -24
  67. package/dist/server/{index.server-qbkxz7r2.js → index.server-nx9c2ep1.js} +2 -2
  68. package/dist/server/{index.server-jj76374p.js → index.server-p071e531.js} +1 -1
  69. package/dist/server/{index.server-5gzyqv78.js → index.server-v3arexq8.js} +2 -2
  70. package/dist/server/{index.server-85p4ydph.js → index.server-zzd5wpbw.js} +1 -1
  71. package/package.json +1 -1
  72. package/src/components/accordion/accordion.examples.json +6 -0
  73. package/src/components/accordion-item/accordion-item.css +20 -7
  74. package/src/components/accordion-item/accordion-item.schema.json +4 -0
  75. package/src/components/accordion-item/accordion-item.schema.ts +4 -0
  76. package/src/components/accordion-item/accordion-item.svelte +9 -7
  77. package/src/components/accordion-item/accordion-item.types.ts +4 -0
  78. package/src/components/accordion-item/accordion-item.variables.json +12 -1
  79. package/src/components/accordion-item/accordion-item.variables.ts +12 -1
  80. package/src/components/action-row/action-row.css +20 -9
  81. package/src/components/action-row/action-row.examples.json +6 -0
  82. package/src/components/action-row/action-row.schema.json +4 -0
  83. package/src/components/action-row/action-row.schema.ts +4 -0
  84. package/src/components/action-row/action-row.types.ts +44 -0
  85. package/src/components/action-row/action-row.variables.json +11 -1
  86. package/src/components/action-row/action-row.variables.ts +11 -1
  87. package/src/components/chat/chat.examples.json +6 -0
  88. package/src/components/segment/segment.schema.json +34 -7
  89. package/src/components/segment/segment.schema.ts +5 -47
  90. package/src/components/segment/segment.svelte +58 -23
  91. package/src/components/segment/segment.types.ts +81 -11
  92. package/src/components/segmented-control/segmented-control.css +26 -6
  93. package/src/components/segmented-control/segmented-control.examples.json +6 -0
  94. package/src/components/segmented-control/segmented-control.schema.json +2 -2
  95. package/src/components/segmented-control/segmented-control.schema.ts +2 -2
  96. package/src/components/segmented-control/segmented-control.svelte +50 -23
  97. package/src/components/segmented-control/segmented-control.types.ts +4 -7
  98. package/src/components/side-navigation/side-navigation.css +2 -1
  99. package/src/components/side-navigation/side-navigation.examples.json +6 -0
  100. package/src/components/side-navigation/side-navigation.schema.json +8 -5
  101. package/src/components/side-navigation/side-navigation.schema.ts +8 -5
  102. package/src/components/side-navigation/side-navigation.types.ts +12 -0
  103. package/src/components/side-navigation/side-navigation.variables.json +1 -1
  104. package/src/components/side-navigation/side-navigation.variables.ts +1 -1
  105. package/src/components/sidebar/index.ts +1 -0
  106. package/src/components/sidebar/sidebar.constants.ts +13 -0
  107. package/src/components/sidebar/sidebar.examples.json +6 -0
  108. package/src/components/sidebar/sidebar.svelte +4 -5
  109. package/src/components/stat/stat.css +16 -8
  110. package/src/components/stat/stat.schema.json +4 -0
  111. package/src/components/stat/stat.schema.ts +4 -0
  112. package/src/components/stat/stat.types.ts +20 -0
  113. package/src/components/stat/stat.variables.json +10 -1
  114. package/src/components/stat/stat.variables.ts +10 -1
  115. package/src/components/stat-group/stat-group.css +7 -4
  116. package/src/components/stat-group/stat-group.examples.json +6 -0
  117. package/src/components/stat-group/stat-group.schema.json +4 -0
  118. package/src/components/stat-group/stat-group.schema.ts +4 -0
  119. package/src/components/stat-group/stat-group.types.ts +28 -0
  120. package/src/components/stat-group/stat-group.variables.json +5 -1
  121. package/src/components/stat-group/stat-group.variables.ts +5 -1
  122. package/src/index.ts +5 -1
  123. package/src/styles/foundation.css +2 -1
  124. package/dist/server/index.server-hfx487zj.js +0 -42
@@ -302,25 +302,69 @@ var rest_excludes = new Set([
302
302
  "$$events",
303
303
  "$$legacy",
304
304
  "value",
305
+ "href",
306
+ "download",
307
+ "target",
308
+ "rel",
309
+ "current",
310
+ "currentToken",
305
311
  "disabled",
306
312
  "controls",
307
313
  "leading",
308
314
  "trailing",
309
315
  "children",
310
- "class"
316
+ "class",
317
+ "onclick"
311
318
  ]);
312
319
  var root = $2.from_html(`<span class="cinder-segmented-control-option-icon" aria-hidden="true"><!></span>`);
313
320
  var root_1 = $2.from_html(`<span class="cinder-segmented-control-option-trailing" aria-hidden="true"><!></span>`);
314
- var root_2 = $2.from_html(`<button><!> <!> <!></button>`);
321
+ var root_2 = $2.from_html(`<!> <!> <!>`, 1);
322
+ var root_3 = $2.from_html(`<a><!></a>`);
323
+ var root_4 = $2.from_html(`<button><!></button>`);
315
324
  function Segment($$anchor, $$props) {
316
325
  $2.push($$props, true);
317
- let disabled = $2.prop($$props, "disabled", 3, false), rest = $2.rest_props($$props, rest_excludes);
326
+ const content = ($$anchor2) => {
327
+ var fragment = root_2();
328
+ var node_1 = $2.first_child(fragment);
329
+ {
330
+ var consequent = ($$anchor3) => {
331
+ var span = root();
332
+ var node_2 = $2.child(span);
333
+ $2.snippet(node_2, () => $$props.leading);
334
+ $2.reset(span);
335
+ $2.append($$anchor3, span);
336
+ };
337
+ $2.if(node_1, ($$render) => {
338
+ if ($$props.leading)
339
+ $$render(consequent);
340
+ });
341
+ }
342
+ var node_3 = $2.sibling(node_1, 2);
343
+ $2.snippet(node_3, () => $$props.children ?? $2.noop);
344
+ var node_4 = $2.sibling(node_3, 2);
345
+ {
346
+ var consequent_1 = ($$anchor3) => {
347
+ var span_1 = root_1();
348
+ var node_5 = $2.child(span_1);
349
+ $2.snippet(node_5, () => $$props.trailing);
350
+ $2.reset(span_1);
351
+ $2.append($$anchor3, span_1);
352
+ };
353
+ $2.if(node_4, ($$render) => {
354
+ if ($$props.trailing)
355
+ $$render(consequent_1);
356
+ });
357
+ }
358
+ $2.append($$anchor2, fragment);
359
+ };
360
+ let current = $2.prop($$props, "current", 3, false), currentToken = $2.prop($$props, "currentToken", 3, "page"), disabled = $2.prop($$props, "disabled", 3, false), rest = $2.rest_props($$props, rest_excludes);
318
361
  const context = getSegmentedControlContext();
362
+ const buttonValue = $2.derived(() => $$props.value ?? $$props.href ?? "");
319
363
  const registerSegment = (node) => {
320
364
  return untrack(() => context.register({
321
365
  node,
322
366
  get value() {
323
- return $$props.value;
367
+ return $2.get(buttonValue);
324
368
  },
325
369
  get disabled() {
326
370
  return disabled() || context.controlDisabled;
@@ -330,64 +374,83 @@ function Segment($$anchor, $$props) {
330
374
  }
331
375
  }));
332
376
  };
333
- const isSelected = $2.derived(() => context.isSelected($$props.value));
334
- const isFocusable = $2.derived(() => context.isFocusable($$props.value));
377
+ const isSelected = $2.derived(() => context.isSelected($2.get(buttonValue)));
378
+ const isFocusable = $2.derived(() => context.isFocusable($2.get(buttonValue)));
335
379
  const effectiveDisabled = $2.derived(() => disabled() || context.controlDisabled);
380
+ const isNavigationItem = $2.derived(() => context.variant === "navigation");
381
+ const anchorDisabled = $2.derived(() => $2.get(effectiveDisabled) || $$props.href === undefined);
382
+ const elementAttributes = $2.derived(() => rest);
383
+ const anchorTabindex = $2.derived(() => $2.get(anchorDisabled) ? -1 : $2.get(elementAttributes).tabindex);
336
384
  const role = $2.derived(() => context.selectionMode === "multiple" ? undefined : context.variant === "tablist" ? "tab" : "radio");
337
- var button = root_2();
338
- var event_handler = () => context.toggle($$props.value);
339
- $2.attribute_effect(button, ($0) => ({
340
- ...rest,
341
- type: "button",
342
- role: $2.get(role),
343
- "data-cinder-segment-value": $$props.value,
344
- "aria-checked": $2.get(role) === "radio" ? $2.get(isSelected) : undefined,
345
- "aria-selected": $2.get(role) === "tab" ? $2.get(isSelected) : undefined,
346
- "aria-pressed": context.selectionMode === "multiple" ? $2.get(isSelected) : undefined,
347
- "aria-controls": $2.get(role) === "tab" ? $$props.controls : undefined,
348
- "aria-disabled": $2.get(effectiveDisabled) ? "true" : undefined,
349
- disabled: context.selectionMode === "multiple" ? $2.get(effectiveDisabled) : undefined,
350
- tabindex: $2.get(isFocusable) ? 0 : -1,
351
- class: $0,
352
- "data-cinder-selected": $2.get(isSelected) ? "" : undefined,
353
- "data-cinder-pressed": context.selectionMode === "multiple" && $2.get(isSelected) ? "" : undefined,
354
- onclick: event_handler
355
- }), [
356
- () => classNames("cinder-segmented-control-option", $$props.class)
357
- ]);
358
- var node_1 = $2.child(button);
359
- {
360
- var consequent = ($$anchor2) => {
361
- var span = root();
362
- var node_2 = $2.child(span);
363
- $2.snippet(node_2, () => $$props.leading);
364
- $2.reset(span);
365
- $2.append($$anchor2, span);
366
- };
367
- $2.if(node_1, ($$render) => {
368
- if ($$props.leading)
369
- $$render(consequent);
370
- });
385
+ function handleAnchorClick(event) {
386
+ if ($2.get(anchorDisabled)) {
387
+ event.preventDefault();
388
+ return;
389
+ }
390
+ $$props.onclick?.(event);
371
391
  }
372
- var node_3 = $2.sibling(node_1, 2);
373
- $2.snippet(node_3, () => $$props.children ?? $2.noop);
374
- var node_4 = $2.sibling(node_3, 2);
392
+ var fragment_1 = $2.comment();
393
+ var node_6 = $2.first_child(fragment_1);
375
394
  {
376
- var consequent_1 = ($$anchor2) => {
377
- var span_1 = root_1();
378
- var node_5 = $2.child(span_1);
379
- $2.snippet(node_5, () => $$props.trailing);
380
- $2.reset(span_1);
381
- $2.append($$anchor2, span_1);
395
+ var consequent_2 = ($$anchor2) => {
396
+ var a = root_3();
397
+ $2.attribute_effect(a, ($0) => ({
398
+ ...$2.get(elementAttributes),
399
+ href: $2.get(anchorDisabled) ? undefined : $$props.href,
400
+ download: $$props.download,
401
+ target: $$props.target,
402
+ rel: $$props.rel,
403
+ "data-cinder-segment-value": $2.get(buttonValue),
404
+ "aria-current": current() ? currentToken() : undefined,
405
+ "aria-disabled": $2.get(anchorDisabled) ? "true" : undefined,
406
+ tabindex: $2.get(anchorTabindex),
407
+ class: $0,
408
+ "data-cinder-current": current() ? "" : undefined,
409
+ onclick: handleAnchorClick
410
+ }), [
411
+ () => classNames("cinder-segmented-control-option", $$props.class)
412
+ ]);
413
+ var node_7 = $2.child(a);
414
+ content(node_7);
415
+ $2.reset(a);
416
+ $2.append($$anchor2, a);
417
+ };
418
+ var alternate = ($$anchor2) => {
419
+ var button = root_4();
420
+ var event_handler = () => context.toggle($2.get(buttonValue));
421
+ $2.attribute_effect(button, ($0) => ({
422
+ ...$2.get(elementAttributes),
423
+ type: "button",
424
+ role: $2.get(role),
425
+ "data-cinder-segment-value": $2.get(buttonValue),
426
+ "aria-checked": $2.get(role) === "radio" ? $2.get(isSelected) : undefined,
427
+ "aria-selected": $2.get(role) === "tab" ? $2.get(isSelected) : undefined,
428
+ "aria-pressed": context.selectionMode === "multiple" ? $2.get(isSelected) : undefined,
429
+ "aria-controls": $2.get(role) === "tab" ? $$props.controls : undefined,
430
+ "aria-disabled": $2.get(effectiveDisabled) ? "true" : undefined,
431
+ disabled: context.selectionMode === "multiple" ? $2.get(effectiveDisabled) : undefined,
432
+ tabindex: $2.get(isFocusable) ? 0 : -1,
433
+ class: $0,
434
+ "data-cinder-selected": $2.get(isSelected) ? "" : undefined,
435
+ "data-cinder-pressed": context.selectionMode === "multiple" && $2.get(isSelected) ? "" : undefined,
436
+ onclick: event_handler
437
+ }), [
438
+ () => classNames("cinder-segmented-control-option", $$props.class)
439
+ ]);
440
+ var node_8 = $2.child(button);
441
+ content(node_8);
442
+ $2.reset(button);
443
+ $2.attach(button, () => registerSegment);
444
+ $2.append($$anchor2, button);
382
445
  };
383
- $2.if(node_4, ($$render) => {
384
- if ($$props.trailing)
385
- $$render(consequent_1);
446
+ $2.if(node_6, ($$render) => {
447
+ if ($2.get(isNavigationItem))
448
+ $$render(consequent_2);
449
+ else
450
+ $$render(alternate, -1);
386
451
  });
387
452
  }
388
- $2.reset(button);
389
- $2.attach(button, () => registerSegment);
390
- $2.append($$anchor, button);
453
+ $2.append($$anchor, fragment_1);
391
454
  $2.pop();
392
455
  }
393
456
 
@@ -398,4 +461,4 @@ export {
398
461
  Segment
399
462
  };
400
463
 
401
- //# debugId=CFCFE4C72557F31C64756E2164756E21
464
+ //# debugId=7889F5204BDFFA8464756E2164756E21
@@ -1,3 +1,3 @@
1
1
  import type { ComponentSchema } from '../../schema-types';
2
- declare const _default: ComponentSchema;
3
- export default _default;
2
+ declare const schema: ComponentSchema;
3
+ export default schema;
@@ -52,54 +52,92 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
52
52
  });
53
53
 
54
54
  // src/components/segment/segment.schema.ts
55
- var schema = {
56
- $schema: "https://json-schema.org/draft/2020-12/schema",
57
- type: "object",
58
- properties: {
59
- class: {
60
- type: "string",
61
- description: "Custom class merged with `.cinder-segmented-control-option`."
55
+ var schema = JSON.parse(`{
56
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
57
+ "type": "object",
58
+ "properties": {
59
+ "class": {
60
+ "type": "string",
61
+ "description": "Custom class merged with \`.cinder-segmented-control-option\`."
62
62
  },
63
- disabled: {
64
- type: "boolean",
65
- description: "Disable just this segment (independent of the control-level `disabled`)."
63
+ "disabled": {
64
+ "type": "boolean",
65
+ "description": "Disable just this segment (independent of the control-level \`disabled\`)."
66
66
  },
67
- controls: {
68
- type: "string",
69
- description: 'ID of the panel this segment controls only meaningful when the parent\n`SegmentedControl` uses `variant="tablist"`.'
67
+ "href": {
68
+ "type": "string",
69
+ "description": "Render this segment as a real link inside \`SegmentedControl variant=\\"navigation\\"\`."
70
+ },
71
+ "current": {
72
+ "type": "boolean",
73
+ "description": "Marks this linked segment as the current route/filter."
74
+ },
75
+ "currentToken": {
76
+ "enum": [
77
+ "page",
78
+ "step",
79
+ "location",
80
+ "date",
81
+ "time",
82
+ "true"
83
+ ],
84
+ "description": "\`aria-current\` token emitted while \`current\` is true. Defaults to \`\\"page\\"\`."
85
+ },
86
+ "value": {
87
+ "type": "string",
88
+ "description": "Value this segment represents. Required when \`href\` is not provided."
89
+ },
90
+ "controls": {
91
+ "type": "string",
92
+ "description": "ID of the panel this segment controls — only meaningful when the parent\\n\`SegmentedControl\` uses \`variant=\\"tablist\\"\`."
70
93
  }
71
94
  },
72
- additionalProperties: false,
73
- metadata: {
74
- unsupportedProps: [
95
+ "additionalProperties": false,
96
+ "metadata": {
97
+ "unsupportedProps": [
75
98
  {
76
- name: "children",
77
- reason: "function-or-snippet",
78
- required: true,
79
- description: "The segment's label content."
99
+ "name": "children",
100
+ "reason": "function-or-snippet",
101
+ "required": true,
102
+ "description": "The segment's label content."
80
103
  },
81
104
  {
82
- name: "leading",
83
- reason: "function-or-snippet",
84
- description: "Optional decorative content rendered before the label, inside `aria-hidden`."
105
+ "name": "leading",
106
+ "reason": "function-or-snippet",
107
+ "description": "Optional decorative content rendered before the label, inside \`aria-hidden\`."
85
108
  },
86
109
  {
87
- name: "trailing",
88
- reason: "function-or-snippet",
89
- description: "Optional decorative content rendered after the label, inside `aria-hidden`."
110
+ "name": "onclick",
111
+ "reason": "function-or-snippet",
112
+ "description": "Optional click handler for the rendered link. Disabled navigation segments\\nprevent default and do not call this handler."
90
113
  },
91
114
  {
92
- name: "value",
93
- reason: "unknown-shape",
94
- required: true,
95
- description: "Value this segment represents. Must be unique within the parent control."
115
+ "name": "trailing",
116
+ "reason": "function-or-snippet",
117
+ "description": "Optional decorative content rendered after the label, inside \`aria-hidden\`."
96
118
  }
97
119
  ]
98
- }
99
- };
120
+ },
121
+ "allOf": [
122
+ {
123
+ "if": {
124
+ "not": {
125
+ "required": [
126
+ "href"
127
+ ]
128
+ }
129
+ },
130
+ "then": {
131
+ "required": [
132
+ "value"
133
+ ]
134
+ }
135
+ }
136
+ ]
137
+ }`);
100
138
  var segment_schema_default = schema;
101
139
  export {
102
140
  segment_schema_default as default
103
141
  };
104
142
 
105
- //# debugId=B44936DB628401DB64756E2164756E21
143
+ //# debugId=3A6B83E20522836564756E2164756E21
@@ -2,11 +2,12 @@
2
2
  * @cinder
3
3
  * @category form
4
4
  * @status stable
5
- * @purpose Individual option inside a SegmentedControl that renders the button, wires the value, and forwards leading/trailing decorations.
5
+ * @purpose Individual option inside a SegmentedControl that renders either a selection button or a route-backed link with shared segmented styling.
6
6
  * @tag form
7
7
  * @tag selection
8
8
  * @useWhen Authoring SegmentedControl children declaratively so consumers can compose icons, labels, and badges per segment.
9
9
  * @useWhen Mixing disabled and enabled segments inside a single radiogroup/tablist where each segment carries its own metadata.
10
+ * @useWhen Rendering route filters as real links inside `SegmentedControl variant="navigation"`.
10
11
  * @avoidWhen Building a standalone toggle button — use Button or Toggle instead.
11
12
  * @avoidWhen Selecting one option from a long list — use Select or Combobox instead.
12
13
  * @related segmented-control, button, toggle
@@ -1,18 +1,11 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { HTMLButtonAttributes } from 'svelte/elements';
3
- type SegmentOwnedAttributes = 'role' | 'type' | 'disabled' | 'tabindex' | 'class' | 'aria-checked' | 'aria-selected' | 'aria-pressed' | 'aria-controls' | 'aria-disabled' | 'onclick';
4
- export type SegmentProps = Omit<HTMLButtonAttributes, SegmentOwnedAttributes> & {
5
- /** Value this segment represents. Must be unique within the parent control. */
6
- value: string;
2
+ import type { HTMLAnchorAttributes, HTMLAttributes } from 'svelte/elements';
3
+ export type SegmentCurrentToken = 'page' | 'step' | 'location' | 'date' | 'time' | 'true';
4
+ type SharedProps = {
7
5
  /** Custom class merged with `.cinder-segmented-control-option`. */
8
6
  class?: string | undefined;
9
7
  /** Disable just this segment (independent of the control-level `disabled`). */
10
8
  disabled?: boolean | undefined;
11
- /**
12
- * ID of the panel this segment controls — only meaningful when the parent
13
- * `SegmentedControl` uses `variant="tablist"`.
14
- */
15
- controls?: string | undefined;
16
9
  /** Optional decorative content rendered before the label, inside `aria-hidden`. */
17
10
  leading?: Snippet | undefined;
18
11
  /** Optional decorative content rendered after the label, inside `aria-hidden`. */
@@ -20,4 +13,68 @@ export type SegmentProps = Omit<HTMLButtonAttributes, SegmentOwnedAttributes> &
20
13
  /** The segment's label content. */
21
14
  children: Snippet;
22
15
  };
16
+ type SegmentOwnedAttributes = 'role' | 'type' | 'disabled' | 'tabindex' | 'class' | 'href' | 'download' | 'target' | 'rel' | 'aria-checked' | 'aria-selected' | 'aria-pressed' | 'aria-controls' | 'aria-disabled' | 'aria-current' | 'onclick';
17
+ type SharedElementAttributes = Omit<HTMLAttributes<HTMLElement>, SegmentOwnedAttributes>;
18
+ type SegmentButtonProps = SharedElementAttributes & SharedProps & {
19
+ href?: undefined;
20
+ download?: undefined;
21
+ target?: undefined;
22
+ rel?: undefined;
23
+ current?: undefined;
24
+ currentToken?: undefined;
25
+ onclick?: undefined;
26
+ /** Value this segment represents. Must be unique within the parent control. */
27
+ value: string;
28
+ /**
29
+ * ID of the panel this segment controls — only meaningful when the parent
30
+ * `SegmentedControl` uses `variant="tablist"`.
31
+ */
32
+ controls?: string | undefined;
33
+ };
34
+ type SegmentAnchorProps = SharedElementAttributes & SharedProps & {
35
+ /** Render this segment as a real link inside `SegmentedControl variant="navigation"`. */
36
+ href: string;
37
+ /** Download hint for the rendered link. */
38
+ download?: boolean | string | undefined;
39
+ /** Browsing context for the rendered link. */
40
+ target?: HTMLAnchorAttributes['target'] | undefined;
41
+ /** Relationship metadata for the rendered link. */
42
+ rel?: HTMLAnchorAttributes['rel'] | undefined;
43
+ /** Optional tab index for enabled links. Disabled navigation links force `-1`. */
44
+ tabindex?: HTMLAttributes<HTMLElement>['tabindex'] | undefined;
45
+ /**
46
+ * Optional click handler for the rendered link. Disabled navigation segments
47
+ * prevent default and do not call this handler.
48
+ */
49
+ onclick?: ((event: MouseEvent) => void) | undefined;
50
+ /** Marks this linked segment as the current route/filter. */
51
+ current?: boolean | undefined;
52
+ /** `aria-current` token emitted while `current` is true. Defaults to `"page"`. */
53
+ currentToken?: SegmentCurrentToken | undefined;
54
+ /** Optional value for consumer metadata; navigation segments do not bind selection state. */
55
+ value?: string | undefined;
56
+ /** Panel controls apply only to tab segments, not navigation links. */
57
+ controls?: undefined;
58
+ };
59
+ export type SegmentProps = SegmentButtonProps | SegmentAnchorProps;
60
+ /** Schema generator surface for Segment's cinder-specific, JSON-expressible props. */
61
+ export interface SegmentSchemaProps {
62
+ /** Custom class merged with `.cinder-segmented-control-option`. */
63
+ class?: string | undefined;
64
+ /** Disable just this segment (independent of the control-level `disabled`). */
65
+ disabled?: boolean | undefined;
66
+ /** Render this segment as a real link inside `SegmentedControl variant="navigation"`. */
67
+ href?: string | undefined;
68
+ /** Marks this linked segment as the current route/filter. */
69
+ current?: boolean | undefined;
70
+ /** `aria-current` token emitted while `current` is true. Defaults to `"page"`. */
71
+ currentToken?: SegmentCurrentToken | undefined;
72
+ /** Value this segment represents. Required when `href` is not provided. */
73
+ value?: string | undefined;
74
+ /**
75
+ * ID of the panel this segment controls — only meaningful when the parent
76
+ * `SegmentedControl` uses `variant="tablist"`.
77
+ */
78
+ controls?: string | undefined;
79
+ }
23
80
  export {};