@urbicon-ui/blocks 6.40.4 → 6.43.2

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 (107) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Calendar/calendar.variants.d.ts +63 -63
  3. package/dist/components/Chat/A2UIView/A2UINode.svelte +20 -39
  4. package/dist/components/Chat/A2UIView/A2UIView.svelte +47 -50
  5. package/dist/components/Chat/A2UIView/a2ui-basic-catalog.d.ts +17 -0
  6. package/dist/components/Chat/A2UIView/a2ui-basic-catalog.js +69 -0
  7. package/dist/components/Chat/A2UIView/a2ui-catalog.d.ts +95 -0
  8. package/dist/components/Chat/A2UIView/a2ui-catalog.js +87 -0
  9. package/dist/components/Chat/A2UIView/a2ui-node-common.d.ts +40 -0
  10. package/dist/components/Chat/A2UIView/a2ui-node-common.js +72 -0
  11. package/dist/components/Chat/A2UIView/a2ui-prompt.d.ts +21 -10
  12. package/dist/components/Chat/A2UIView/a2ui-prompt.js +170 -24
  13. package/dist/components/Chat/A2UIView/a2ui-registry.d.ts +1 -1
  14. package/dist/components/Chat/A2UIView/a2ui-registry.js +2 -1
  15. package/dist/components/Chat/A2UIView/a2ui-render.d.ts +30 -0
  16. package/dist/components/Chat/A2UIView/a2ui-render.js +61 -23
  17. package/dist/components/Chat/A2UIView/a2ui-router.d.ts +136 -0
  18. package/dist/components/Chat/A2UIView/a2ui-router.js +264 -0
  19. package/dist/components/Chat/A2UIView/a2ui-schema.d.ts +45 -0
  20. package/dist/components/Chat/A2UIView/a2ui-schema.js +133 -0
  21. package/dist/components/Chat/A2UIView/a2ui-stream.d.ts +120 -0
  22. package/dist/components/Chat/A2UIView/a2ui-stream.js +406 -0
  23. package/dist/components/Chat/A2UIView/a2ui-transcript.d.ts +65 -0
  24. package/dist/components/Chat/A2UIView/a2ui-transcript.js +101 -0
  25. package/dist/components/Chat/A2UIView/a2ui-validate.d.ts +33 -1
  26. package/dist/components/Chat/A2UIView/a2ui-validate.js +167 -63
  27. package/dist/components/Chat/A2UIView/a2ui.types.d.ts +50 -0
  28. package/dist/components/Chat/A2UIView/a2ui.types.js +38 -1
  29. package/dist/components/Chat/A2UIView/index.d.ts +35 -2
  30. package/dist/components/Chat/A2UIView/index.js +13 -0
  31. package/dist/components/Chat/A2UIView/urbicon/UrbiconA2UINode.svelte +831 -0
  32. package/dist/components/Chat/A2UIView/urbicon/UrbiconA2UINode.svelte.d.ts +4 -0
  33. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon-catalog.d.ts +14 -0
  34. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon-catalog.js +87 -0
  35. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon-registry.d.ts +78 -0
  36. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon-registry.js +783 -0
  37. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon.variants.d.ts +43 -0
  38. package/dist/components/Chat/A2UIView/urbicon/a2ui-urbicon.variants.js +33 -0
  39. package/dist/components/Chat/A2UIView/urbicon/urbicon-axes.gen.d.ts +7 -0
  40. package/dist/components/Chat/A2UIView/urbicon/urbicon-axes.gen.js +86 -0
  41. package/dist/components/Chat/ChatMessage/ChatMessage.svelte +93 -67
  42. package/dist/components/Chat/ChatMessage/chat-message.variants.d.ts +26 -19
  43. package/dist/components/Chat/ChatMessage/chat-message.variants.js +45 -12
  44. package/dist/components/Chat/ChatMessage/index.d.ts +20 -5
  45. package/dist/components/Chat/CodeBlock/CodeBlock.svelte +59 -33
  46. package/dist/components/Chat/CodeBlock/code-block.variants.d.ts +7 -0
  47. package/dist/components/Chat/CodeBlock/code-block.variants.js +28 -13
  48. package/dist/components/Chat/CodeBlock/index.d.ts +39 -4
  49. package/dist/components/Chat/PromptInput/PromptInput.svelte +9 -16
  50. package/dist/components/Chat/PromptInput/prompt-input.variants.js +16 -15
  51. package/dist/components/Chat/ToolCallCard/ToolCallCard.svelte +9 -4
  52. package/dist/components/Chat/ToolCallCard/index.d.ts +4 -3
  53. package/dist/components/Chat/ToolCallCard/tool-call-card.variants.d.ts +0 -3
  54. package/dist/components/Chat/ToolCallCard/tool-call-card.variants.js +4 -4
  55. package/dist/components/CopyButton/CopyButton.svelte +9 -19
  56. package/dist/components/CopyButton/copy-button.variants.d.ts +4 -4
  57. package/dist/components/FileUpload/fileUpload.variants.js +15 -4
  58. package/dist/components/PinInput/PinInput.svelte +1 -0
  59. package/dist/components/PinInput/pin-input.variants.js +14 -1
  60. package/dist/components/TimeInput/time-input.variants.js +16 -1
  61. package/dist/i18n/index.d.ts +398 -2
  62. package/dist/internal/copy-state.svelte.d.ts +60 -0
  63. package/dist/internal/copy-state.svelte.js +76 -0
  64. package/dist/internal/field-chrome.d.ts +18 -1
  65. package/dist/internal/field-chrome.js +19 -2
  66. package/dist/primitives/Alert/alert.variants.d.ts +8 -8
  67. package/dist/primitives/Avatar/avatar.variants.js +4 -1
  68. package/dist/primitives/Badge/badge.variants.js +11 -2
  69. package/dist/primitives/Button/button.variants.js +4 -1
  70. package/dist/primitives/Card/card.variants.js +4 -1
  71. package/dist/primitives/Checkbox/checkbox.variants.js +7 -1
  72. package/dist/primitives/Combobox/Combobox.svelte +9 -1
  73. package/dist/primitives/Combobox/combobox.variants.d.ts +25 -0
  74. package/dist/primitives/Combobox/combobox.variants.js +43 -7
  75. package/dist/primitives/Combobox/index.d.ts +8 -2
  76. package/dist/primitives/Dialog/dialog.variants.js +4 -1
  77. package/dist/primitives/Drawer/drawer.variants.js +4 -1
  78. package/dist/primitives/Input/input.variants.js +17 -1
  79. package/dist/primitives/JourneyTimeline/journey-timeline.variants.d.ts +22 -22
  80. package/dist/primitives/Menu/menu.variants.js +5 -1
  81. package/dist/primitives/Progress/progress.variants.js +5 -2
  82. package/dist/primitives/RadioGroup/radioGroup.variants.js +74 -10
  83. package/dist/primitives/Select/select.variants.js +14 -5
  84. package/dist/primitives/Slider/Slider.svelte +4 -1
  85. package/dist/primitives/Slider/slider.variants.js +9 -2
  86. package/dist/primitives/Spinner/spinner.variants.d.ts +16 -16
  87. package/dist/primitives/Stepper/stepper.variants.d.ts +11 -11
  88. package/dist/primitives/Stepper/stepper.variants.js +2 -1
  89. package/dist/primitives/Tab/tab.variants.js +4 -1
  90. package/dist/primitives/Textarea/textarea.variants.js +16 -2
  91. package/dist/primitives/Toast/toast.variants.d.ts +12 -12
  92. package/dist/primitives/Toast/toast.variants.js +5 -1
  93. package/dist/primitives/Toggle/toggle.variants.js +94 -18
  94. package/dist/primitives/Tooltip/tooltip.variants.d.ts +3 -3
  95. package/dist/primitives/Tooltip/tooltip.variants.js +5 -1
  96. package/dist/style/foundation.css +19 -9
  97. package/dist/style/semantic.css +49 -2
  98. package/dist/style/themes/forest.css +2 -2
  99. package/dist/style/themes/neutral.css +2 -2
  100. package/dist/style/themes/ocean.css +2 -2
  101. package/dist/style/themes/rose.css +2 -2
  102. package/dist/style/themes/sunset.css +2 -2
  103. package/dist/utils/figma-token-export.js +7 -3
  104. package/dist/utils/persistent-state.svelte.d.ts +25 -1
  105. package/dist/utils/persistent-state.svelte.js +98 -10
  106. package/docs/MIGRATION-v5.md +29 -0
  107. package/package.json +3 -3
@@ -30,33 +30,88 @@ function debounce(func, wait) {
30
30
  /**
31
31
  * Create a persistent state that automatically syncs with storage
32
32
  * Uses Svelte 5 $state() for reactivity
33
+ *
34
+ * Besides `value`, the returned object exposes `hasStoredValue` — whether an
35
+ * entry for this key exists in storage. That is what lets a consumer tell a
36
+ * *stored empty* value (`[]`, `''`, `null` — the user cleared it) from *nothing
37
+ * stored at all*, so a cleared state can win over a default/seed instead of
38
+ * being re-applied on every load. Two rules keep that signal meaningful: a save
39
+ * that would not change the stored bytes is skipped, and an instance nobody
40
+ * wrote to never creates an entry for its own default (so `reset()` is not
41
+ * undone by the auto-save, and untouched state stays out of storage). Writing
42
+ * the default *back* — clearing — is a real write and does create the entry.
43
+ *
44
+ * Values must round-trip through the configured `serialize`/`deserialize`;
45
+ * `Set`/`Map` do not under the `JSON.stringify` default (they serialize to
46
+ * `{}`), so pass converting functions or store plain arrays/objects.
33
47
  */
34
48
  export function createPersistentState(config) {
35
49
  const { key, defaultValue, storage: storageType = 'localStorage', serialize = JSON.stringify, deserialize = JSON.parse, debounceMs = 300, version = 1 } = config;
36
50
  const storageKey = `urbicon_${key}_v${version}`;
37
51
  const storage = getStorage(storageType);
38
52
  // Initialize state with stored value or default
39
- const initialValue = loadFromStorage();
40
- const state = $state({ value: initialValue });
53
+ const initial = loadFromStorage();
54
+ const state = $state({ value: initial.value, hasStored: initial.stored });
55
+ // A faithful mirror of what storage holds: the exact stored string, or `null`
56
+ // when the key is absent (or unparseable). It must never claim the default is
57
+ // stored when it is not — that would make the absent → stored-empty
58
+ // transition unwritable, which is exactly the state this module exists to
59
+ // preserve (the user cleared the axis).
60
+ let lastWritten = initial.raw;
61
+ // Whether the consumer ever wrote through this instance. Only used to keep an
62
+ // *untouched* instance from creating an entry for its own default.
63
+ let touched = false;
64
+ const defaultSerialized = trySerialize(defaultValue);
65
+ function trySerialize(value) {
66
+ try {
67
+ return serialize(value);
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ }
41
73
  function loadFromStorage() {
42
74
  if (!storage)
43
- return defaultValue;
75
+ return { value: defaultValue, stored: false, raw: null };
44
76
  try {
45
77
  const stored = storage.getItem(storageKey);
46
78
  if (stored === null)
47
- return defaultValue;
48
- return deserialize(stored);
79
+ return { value: defaultValue, stored: false, raw: null };
80
+ return { value: deserialize(stored), stored: true, raw: stored };
49
81
  }
50
82
  catch (error) {
51
83
  console.warn(`Failed to load persistent state for key "${key}":`, error);
52
- return defaultValue;
84
+ // A corrupt entry counts as *absent*, never as "stored": consumers use
85
+ // `hasStoredValue` to let a stored value win over their own default or
86
+ // seed, and unparseable junk must not win — it would block that default
87
+ // forever. The junk itself is left in place until something is actually
88
+ // written (the first real write overwrites it); an untouched instance
89
+ // does not clean it up, and does not need to — it reads as absent.
90
+ return { value: defaultValue, stored: false, raw: null };
53
91
  }
54
92
  }
55
93
  function saveToStorage(value) {
56
94
  if (!storage)
57
95
  return;
58
96
  try {
59
- storage.setItem(storageKey, serialize(value));
97
+ const next = serialize(value);
98
+ // Storage already holds exactly this — nothing to do.
99
+ if (next === lastWritten)
100
+ return;
101
+ // Never *create* an entry for a value nobody touched. Without this the
102
+ // auto-save effect below would write every key with its own default on
103
+ // mount, making `hasStoredValue` useless (an untouched default would be
104
+ // indistinguishable from a deliberately cleared one) and re-creating the
105
+ // entry `reset()` just removed. Once the consumer has written — including
106
+ // writing the default back, i.e. clearing — the write goes through, even
107
+ // if the key does not exist yet. `forceSave()` obeys the same rule on
108
+ // purpose: a blanket flush (the table exposes one) must not create an
109
+ // entry for every untouched axis, which would retire all their seeds.
110
+ if (!touched && lastWritten === null && next === defaultSerialized)
111
+ return;
112
+ storage.setItem(storageKey, next);
113
+ lastWritten = next;
114
+ state.hasStored = true;
60
115
  }
61
116
  catch (error) {
62
117
  console.warn(`Failed to save persistent state for key "${key}":`, error);
@@ -73,17 +128,44 @@ export function createPersistentState(config) {
73
128
  return state.value;
74
129
  },
75
130
  set value(newValue) {
131
+ // Mark the instance as written-to *before* the state change, so the
132
+ // auto-save effect it triggers knows this is a deliberate value — that is
133
+ // what lets clearing back to the default create an entry.
134
+ touched = true;
76
135
  state.value = newValue;
77
136
  },
137
+ /**
138
+ * Whether storage currently holds an entry for this key: `true` when
139
+ * construction (or `reload()`) found a parseable entry, and after a write
140
+ * actually reached storage; `false` when the key was absent or corrupt,
141
+ * after `reset()`, and always without a working storage (SSR, private
142
+ * mode). Use it to distinguish a stored empty value from an absent one.
143
+ */
144
+ get hasStoredValue() {
145
+ return state.hasStored;
146
+ },
78
147
  /**
79
148
  * Reset to default value and clear storage
80
149
  */
81
150
  reset() {
82
151
  state.value = defaultValue;
83
- storage?.removeItem(storageKey);
152
+ try {
153
+ storage?.removeItem(storageKey);
154
+ }
155
+ catch (error) {
156
+ console.warn(`Failed to clear persistent state for key "${key}":`, error);
157
+ }
158
+ state.hasStored = false;
159
+ // Back to "nothing stored", and untouched again — so the auto-save
160
+ // triggered by the assignment above does not immediately re-create the
161
+ // key we just removed. A later write (including clearing) still lands.
162
+ lastWritten = null;
163
+ touched = false;
84
164
  },
85
165
  /**
86
- * Force immediate save (bypasses debounce)
166
+ * Force immediate save (bypasses debounce). A no-op when storage already
167
+ * holds exactly this value, and — like the auto-save — when the instance
168
+ * was never written to and still holds its default.
87
169
  */
88
170
  forceSave() {
89
171
  saveToStorage(state.value);
@@ -92,7 +174,13 @@ export function createPersistentState(config) {
92
174
  * Reload from storage
93
175
  */
94
176
  reload() {
95
- state.value = loadFromStorage();
177
+ const next = loadFromStorage();
178
+ state.value = next.value;
179
+ state.hasStored = next.stored;
180
+ lastWritten = next.raw;
181
+ // The value now mirrors storage again; nothing here came from the
182
+ // consumer, so an absent key stays absent until the next real write.
183
+ touched = false;
96
184
  }
97
185
  };
98
186
  }
@@ -80,6 +80,35 @@ The dead `tableVariants` export is removed (was unused in any consumer).
80
80
  <Table data={rows} columns={cols} />
81
81
  ```
82
82
 
83
+ ## 3b. Table state snippets renamed (v6.41)
84
+
85
+ The Table's three state snippets are renamed to match the slot names they
86
+ already had in `slotClasses` (`emptyState` / `loadingState` / `errorState`).
87
+ That frees `loading` and `error` for the state props they are everywhere else
88
+ in the library — the Table can now be told it is loading or has failed, which
89
+ previously only the managed `queryFn` path could do.
90
+
91
+ | Before (snippet) | After (snippet) | Freed prop |
92
+ | ---------------- | --------------- | ---------------------- |
93
+ | `empty` | `emptyState` | — |
94
+ | `loading` | `loadingState` | `loading?: boolean` |
95
+ | `error` | `errorState` | `error?: string\|null` |
96
+
97
+ ```svelte
98
+ <!-- before -->
99
+ <Table {items} {columns}>
100
+ {#snippet empty()}<tr><td colspan="99">Nothing here</td></tr>{/snippet}
101
+ </Table>
102
+
103
+ <!-- after — plus the new state props for data you fetch yourself -->
104
+ <Table {items} {columns} loading={pending} error={failure}>
105
+ {#snippet emptyState()}<tr><td colspan="99">Nothing here</td></tr>{/snippet}
106
+ </Table>
107
+ ```
108
+
109
+ With a managed `queryFn` the table still owns both states and ignores the two
110
+ props (DEV warns).
111
+
83
112
  ## 4. Dialog + Drawer intent
84
113
 
85
114
  Dialog and Drawer no longer draw a coloured `border-t-[3px]` accent for
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urbicon-ui/blocks",
3
- "version": "6.40.4",
3
+ "version": "6.43.2",
4
4
  "description": "Svelte 5 UI component library with Tailwind CSS 4, OKLCH design tokens and zero runtime dependencies",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -93,8 +93,8 @@
93
93
  "@sveltejs/package": "^2.5.8",
94
94
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
95
95
  "@tailwindcss/vite": "^4.3.1",
96
- "@urbicon-ui/i18n": "6.40.4",
97
- "@urbicon-ui/shared-types": "6.40.4",
96
+ "@urbicon-ui/i18n": "6.43.2",
97
+ "@urbicon-ui/shared-types": "6.43.2",
98
98
  "prettier": "^3.8.4",
99
99
  "prettier-plugin-svelte": "^4.1.1",
100
100
  "prettier-plugin-tailwindcss": "^0.8.0",