@happyvertical/smrt-fields 0.60.16 → 0.60.18

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.
@@ -289,18 +289,18 @@ $effect(() => {
289
289
  {#if renderSnippet}
290
290
  {@render renderSnippet(snippetProps)}
291
291
  {:else if visible}
292
- <div class="policy-field {className}" bind:this={rootEl} data-smrt-component="PolicyField">
292
+ <div class="smrt-policy-field__root {className}" bind:this={rootEl} data-smrt-component="PolicyField">
293
293
  {#if label !== null}
294
294
  <!-- `for` tracks the repaired label↔control association: the `name`
295
295
  convention before the first effect pass (SSR / first paint), the
296
296
  repaired control id afterwards; Svelte omits the attribute entirely
297
297
  when it resolves to null (no wrapped control). -->
298
298
  <label
299
- class="policy-field__label"
299
+ class="smrt-policy-field__label" data-smrt-part="label"
300
300
  for={controlId === undefined ? id : controlId}
301
301
  title={helpDensity === 'tooltip' && help !== null ? help : undefined}
302
302
  >
303
- {label}{#if required}<span class="policy-field__required" aria-hidden="true">*</span>{/if}
303
+ {label}{#if required}<span class="smrt-policy-field__required" data-smrt-part="marker" aria-hidden="true">*</span>{/if}
304
304
  </label>
305
305
  {/if}
306
306
  {@render children?.()}
@@ -308,34 +308,39 @@ $effect(() => {
308
308
  <!-- Hint text density, or tooltip density with no label to attach the
309
309
  title attribute to (fall back to visible help rather than dropping
310
310
  it). -->
311
- <p class="policy-field__hint" id={helpId}>{help}</p>
311
+ <p class="smrt-policy-field__hint" data-smrt-part="description" id={helpId}>{help}</p>
312
312
  {/if}
313
313
  </div>
314
314
  {/if}
315
315
 
316
316
  <style>
317
317
  @layer smrt.reset, smrt.structure, smrt.theme;
318
- @layer smrt.theme {
319
- .policy-field {
318
+ @layer smrt.structure {
319
+ .smrt-policy-field__root {
320
320
  display: flex;
321
321
  flex-direction: column;
322
322
  gap: var(--smrt-spacing-1, 0.25rem);
323
323
  }
324
+ .smrt-policy-field__required {
325
+ margin-left: 0.25em;
326
+ }
327
+ .smrt-policy-field__hint {
328
+ margin: 0;
329
+ }
330
+ }
324
331
 
325
- .policy-field__label {
332
+ @layer smrt.theme {
333
+ .smrt-policy-field__label {
326
334
  font: var(--smrt-typography-label-large-font, inherit);
327
335
  color: var(--smrt-color-on-surface, currentColor);
328
336
  }
329
-
330
- .policy-field__required {
337
+ .smrt-policy-field__required {
331
338
  color: var(--smrt-color-error);
332
- margin-left: 0.25em;
333
339
  }
334
-
335
- .policy-field__hint {
340
+ .smrt-policy-field__hint {
336
341
  font: var(--smrt-typography-body-small-font, inherit);
337
342
  color: var(--smrt-color-on-surface-variant, currentColor);
338
- margin: 0;
339
343
  }
340
344
  }
345
+
341
346
  </style>
@@ -96,7 +96,7 @@ function handleSubmit() {
96
96
  }
97
97
  </script>
98
98
 
99
- <section class="field-policy-preview">
99
+ <section class="smrt-field-policy-form-preview__root" data-smrt-component="FieldPolicyFormPreview">
100
100
  <!--
101
101
  ONE provider, extended over the header too. FormHelp assembles its glossary
102
102
  from the provider context and must live inside it; the provider renders no
@@ -104,9 +104,9 @@ function handleSubmit() {
104
104
  second provider to reach it — a nested one shadows this mode store — #2272.
105
105
  -->
106
106
  <FieldPolicyProvider policy={resolvedPolicy} mode="basic">
107
- <header class="preview-header">
107
+ <header class="smrt-field-policy-form-preview__header" data-smrt-part="header">
108
108
  <h2>Hand-written form adopting PolicyField</h2>
109
- <p class="preview-desc">
109
+ <p class="smrt-field-policy-form-preview__description" data-smrt-part="description">
110
110
  A developer-authored product form. Two fields (name, SKU) adopt
111
111
  PolicyField for help, defaults, and progressive disclosure; the rest stay
112
112
  hand-written. Toggle the mode switch to reveal advanced-tier fields.
@@ -116,11 +116,11 @@ function handleSubmit() {
116
116
  />
117
117
  </header>
118
118
 
119
- <div class="toolbar">
119
+ <div class="smrt-field-policy-form-preview__toolbar" data-smrt-part="actions">
120
120
  <ModeSwitch />
121
121
  </div>
122
122
 
123
- <form class="widget-form" onsubmit={(e) => { e.preventDefault(); handleSubmit(); }}>
123
+ <form class="smrt-field-policy-form-preview__form" data-smrt-part="body" onsubmit={(e) => { e.preventDefault(); handleSubmit(); }}>
124
124
  <!-- Adopted field: gets label, help hint, required marker from the policy -->
125
125
  <PolicyField name="name">
126
126
  <Input id="name" name="name" bind:value={name} placeholder="Widget Deluxe" />
@@ -132,7 +132,7 @@ function handleSubmit() {
132
132
  </PolicyField>
133
133
 
134
134
  <!-- Unwrapped hand-written field — keeps working untouched -->
135
- <div class="raw-field">
135
+ <div class="smrt-field-policy-form-preview__field" data-smrt-part="field">
136
136
  <label for="rawNotes">Notes (unwrapped, hand-written)</label>
137
137
  <Textarea
138
138
  id="rawNotes"
@@ -152,70 +152,70 @@ function handleSubmit() {
152
152
  </PolicyField>
153
153
  </AdvancedFields>
154
154
 
155
- <div class="actions">
155
+ <div class="smrt-field-policy-form-preview__actions" data-smrt-part="actions">
156
156
  <Button type="submit">Save product</Button>
157
157
  </div>
158
158
  </form>
159
159
 
160
160
  {#if submitted}
161
- <p class="status" role="status">{submitted}</p>
161
+ <p class="smrt-field-policy-form-preview__status" data-smrt-part="status" role="status">{submitted}</p>
162
162
  {/if}
163
163
  </FieldPolicyProvider>
164
164
  </section>
165
165
 
166
166
  <style>
167
167
  @layer smrt.reset, smrt.structure, smrt.theme;
168
- @layer smrt.theme {
169
- .field-policy-preview {
168
+ @layer smrt.structure {
169
+ .smrt-field-policy-form-preview__root {
170
170
  display: flex;
171
171
  flex-direction: column;
172
172
  gap: var(--smrt-spacing-4, 1rem);
173
173
  max-width: 40rem;
174
174
  }
175
-
176
- .preview-header h2 {
177
- font: var(--smrt-typography-headline-small-font, inherit);
175
+ .smrt-field-policy-form-preview__header h2 {
178
176
  margin: 0 0 var(--smrt-spacing-1, 0.25rem);
179
177
  }
180
-
181
- .preview-desc {
182
- font: var(--smrt-typography-body-medium-font, inherit);
183
- color: var(--smrt-color-on-surface-variant, currentColor);
178
+ .smrt-field-policy-form-preview__description {
184
179
  margin: 0 0 var(--smrt-spacing-2, 0.5rem);
185
180
  }
186
-
187
- .toolbar {
181
+ .smrt-field-policy-form-preview__toolbar {
188
182
  display: flex;
189
183
  justify-content: flex-end;
190
184
  margin-bottom: var(--smrt-spacing-3, 0.75rem);
191
185
  }
192
-
193
- .widget-form {
186
+ .smrt-field-policy-form-preview__form {
194
187
  display: flex;
195
188
  flex-direction: column;
196
189
  gap: var(--smrt-spacing-3, 0.75rem);
197
190
  }
198
-
199
- .raw-field {
191
+ .smrt-field-policy-form-preview__field {
200
192
  display: flex;
201
193
  flex-direction: column;
202
194
  gap: var(--smrt-spacing-1, 0.25rem);
203
195
  }
204
-
205
- .raw-field label {
206
- font: var(--smrt-typography-label-large-font, inherit);
207
- color: var(--smrt-color-on-surface, currentColor);
208
- }
209
-
210
- .actions {
196
+ .smrt-field-policy-form-preview__actions {
211
197
  display: flex;
212
198
  gap: var(--smrt-spacing-2, 0.5rem);
213
199
  padding-top: var(--smrt-spacing-2, 0.5rem);
214
200
  }
201
+ }
215
202
 
216
- .status {
203
+ @layer smrt.theme {
204
+ .smrt-field-policy-form-preview__header h2 {
205
+ font: var(--smrt-typography-headline-small-font, inherit);
206
+ }
207
+ .smrt-field-policy-form-preview__description {
208
+ font: var(--smrt-typography-body-medium-font, inherit);
209
+ color: var(--smrt-color-on-surface-variant, currentColor);
210
+ }
211
+ .smrt-field-policy-form-preview__field label {
212
+ font: var(--smrt-typography-label-large-font, inherit);
213
+ color: var(--smrt-color-on-surface, currentColor);
214
+ }
215
+ .smrt-field-policy-form-preview__status {
217
216
  font: var(--smrt-typography-body-medium-font, inherit);
218
217
  color: var(--smrt-color-primary);
219
218
  }
220
219
  }
220
+
221
221
  </style>
@@ -105,7 +105,7 @@ let record = $state<Record<string, unknown>>({});
105
105
  />
106
106
  {/snippet}
107
107
 
108
- <section class="object-form-preview">
108
+ <section class="smrt-object-form-preview__root" data-smrt-component="ObjectFormPreview">
109
109
  <h2>Generated ObjectForm</h2>
110
110
  <p>
111
111
  This single form is driven by browser-safe fields and resolved policy. Basic
@@ -119,14 +119,30 @@ let record = $state<Record<string, unknown>>({});
119
119
  renderers={{ sku: skuRenderer }}
120
120
  />
121
121
  </ObjectFormSourceProvider>
122
- <output class="record-preview">{JSON.stringify(record)}</output>
122
+ <output class="smrt-object-form-preview__output" data-smrt-part="status">{JSON.stringify(record)}</output>
123
123
  </section>
124
124
 
125
125
  <style>
126
126
  @layer smrt.reset, smrt.structure, smrt.theme;
127
+ @layer smrt.structure {
128
+ .smrt-object-form-preview__root {
129
+ display: grid;
130
+ gap: var(--smrt-spacing-3, 0.75rem);
131
+ max-width: 40rem;
132
+ }
133
+ h2, p {
134
+ margin: 0;
135
+ }
136
+ .smrt-object-form-preview__output {
137
+ overflow-wrap: anywhere;
138
+ }
139
+ }
140
+
127
141
  @layer smrt.theme {
128
- .object-form-preview { display: grid; gap: var(--smrt-spacing-3, 0.75rem); max-width: 40rem; }
129
- h2, p { margin: 0; }
130
- .record-preview { font: var(--smrt-typography-body-small-font, monospace); color: var(--smrt-color-on-surface-variant, currentColor); overflow-wrap: anywhere; }
142
+ .smrt-object-form-preview__output {
143
+ font: var(--smrt-typography-body-small-font, monospace);
144
+ color: var(--smrt-color-on-surface-variant, currentColor);
145
+ }
131
146
  }
147
+
132
148
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-fields",
3
- "version": "0.60.16",
3
+ "version": "0.60.18",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Layered field policy store and resolver (defaults, visibility tiers, help text) for SMRT objects",
6
6
  "type": "module",
@@ -37,17 +37,17 @@
37
37
  }
38
38
  },
39
39
  "dependencies": {
40
- "@happyvertical/smrt-core": "0.60.16",
41
- "@happyvertical/smrt-tenancy": "0.60.16",
42
- "@happyvertical/smrt-ui": "0.60.16",
43
- "@happyvertical/smrt-users": "0.60.16",
44
- "@happyvertical/sql": "^0.111.8"
40
+ "@happyvertical/smrt-core": "0.60.18",
41
+ "@happyvertical/smrt-tenancy": "0.60.18",
42
+ "@happyvertical/smrt-ui": "0.60.18",
43
+ "@happyvertical/smrt-users": "0.60.18",
44
+ "@happyvertical/sql": "^0.112.2"
45
45
  },
46
46
  "devDependencies": {
47
- "@happyvertical/smrt-cli": "0.60.16",
48
- "@happyvertical/smrt-scanner": "0.60.16",
49
- "@happyvertical/smrt-users": "0.60.16",
50
- "@happyvertical/smrt-vitest": "0.60.16",
47
+ "@happyvertical/smrt-cli": "0.60.18",
48
+ "@happyvertical/smrt-scanner": "0.60.18",
49
+ "@happyvertical/smrt-users": "0.60.18",
50
+ "@happyvertical/smrt-vitest": "0.60.18",
51
51
  "@sveltejs/package": "^2.5.8",
52
52
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
53
53
  "@testing-library/svelte": "^5.4.2",