@hypermedia-components/core 0.1.0 → 0.1.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.
@@ -27,8 +27,11 @@
27
27
  // control is focused (opt out with `data-focus="none"` on the alert).
28
28
  //
29
29
  // Message resolution per item: `data-message-key` found in the i18n
30
- // catalog → `t(key, { field, code })`; otherwise the item's own text;
31
- // otherwise `t('fieldErrors.unknown')`. Localize once via `setMessages()`.
30
+ // catalog → `t(key, { field, code, ...data-message-params })`; otherwise
31
+ // the item's own text; otherwise `t('fieldErrors.unknown')`. Localize once
32
+ // via `setMessages()`. `data-message-params` is an optional JSON object of
33
+ // server-provided interpolation values (constraint declarations, validation
34
+ // row columns) for translations with placeholders beyond {field}/{code}.
32
35
  //
33
36
  // Server errors are stale the moment the user edits the field or
34
37
  // resubmits: cleared on first `input`/`change` per field, on `submit` /
@@ -85,6 +88,22 @@ function resolveMessage(item) {
85
88
  field: item.getAttribute('data-field') ?? '',
86
89
  code: item.getAttribute('data-code') ?? '',
87
90
  };
91
+ // Optional server-provided interpolation params (a JSON object), so a
92
+ // catalog translation may use placeholders beyond {field}/{code} — e.g.
93
+ // data-message-params='{"stock": 5}' for "在庫 {stock} を超えています。".
94
+ // Item params win over the implicit field/code; malformed or non-object
95
+ // JSON degrades to the attribute being ignored.
96
+ const raw = item.getAttribute('data-message-params');
97
+ if (raw) {
98
+ try {
99
+ const extra = JSON.parse(raw);
100
+ if (extra && typeof extra === 'object' && !Array.isArray(extra)) {
101
+ Object.assign(params, extra);
102
+ }
103
+ } catch {
104
+ /* malformed JSON — keep the default params */
105
+ }
106
+ }
88
107
  if (key && hasMessage(key)) return t(key, params);
89
108
  const text = item.textContent.trim();
90
109
  if (text) return text;
@@ -51,7 +51,7 @@
51
51
  min-inline-size: var(--hc-combobox-listbox-min-width);
52
52
  max-block-size: var(--hc-combobox-listbox-max-height);
53
53
  overflow-y: auto;
54
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.12);
54
+ box-shadow: var(--hc-shadow-lg);
55
55
  list-style: none;
56
56
  }
57
57
 
@@ -36,7 +36,7 @@
36
36
  background: var(--hc-command-bg);
37
37
  color: var(--hc-command-fg);
38
38
  overflow: hidden;
39
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.12);
39
+ box-shadow: var(--hc-shadow-lg);
40
40
  }
41
41
 
42
42
  .hc-command__input {
@@ -38,7 +38,7 @@
38
38
  /* Contextual shadow cast by a frozen column's trailing edge — its
39
39
  direction flips per edge (see the frozen-edge rules below), so it
40
40
  stays a CSS-local var, not a theme token. */
41
- --hc-datagrid-freeze-shadow: 2px 0 4px -2px rgb(0, 0, 0, 0.25);
41
+ --hc-datagrid-freeze-shadow: 2px 0 4px -2px var(--hc-shadow-edge);
42
42
 
43
43
  position: relative;
44
44
  border: 1px solid var(--hc-datagrid-border);
@@ -173,7 +173,7 @@
173
173
 
174
174
  /* RTL: the freeze line falls on the other (inline-end) side. */
175
175
  .hc-datagrid:dir(rtl) {
176
- --hc-datagrid-freeze-shadow: -2px 0 4px -2px rgb(0, 0, 0, 0.25);
176
+ --hc-datagrid-freeze-shadow: -2px 0 4px -2px var(--hc-shadow-edge);
177
177
  }
178
178
 
179
179
  /* ---- States ----
@@ -355,7 +355,7 @@
355
355
  line-height: 1.4;
356
356
  white-space: normal;
357
357
  overflow-wrap: anywhere;
358
- box-shadow: 0 4px 12px rgb(0, 0, 0, 0.25);
358
+ box-shadow: var(--hc-shadow-lg);
359
359
  pointer-events: none;
360
360
  }
361
361
 
@@ -14,7 +14,7 @@
14
14
  color: var(--hc-dialog-fg);
15
15
  max-inline-size: var(--hc-dialog-max-width);
16
16
  inline-size: calc(100% - 2 * var(--hc-space-4));
17
- box-shadow: 0 10px 30px rgb(0, 0, 0, 0.15);
17
+ box-shadow: var(--hc-shadow-overlay);
18
18
  }
19
19
 
20
20
  .hc-dialog::backdrop {
@@ -30,7 +30,7 @@
30
30
  background: var(--hc-drawer-bg);
31
31
  color: var(--hc-drawer-fg);
32
32
  overflow: hidden;
33
- box-shadow: 0 0 30px rgb(0, 0, 0, 0.2);
33
+ box-shadow: var(--hc-shadow-overlay);
34
34
 
35
35
  /* Default side = right. Specific sides override below. */
36
36
  inset-block: 0;
@@ -40,7 +40,7 @@
40
40
  color: var(--hc-hovercard-fg);
41
41
  inline-size: max-content;
42
42
  max-inline-size: var(--hc-hovercard-max-width);
43
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.14);
43
+ box-shadow: var(--hc-shadow-lg);
44
44
 
45
45
  /* Shared directional placement (hc-anchored.css). */
46
46
  --hc-anchored-offset: var(--hc-hovercard-offset);
package/dist/hc-menu.css CHANGED
@@ -34,7 +34,7 @@
34
34
  color: var(--hc-menu-fg);
35
35
  min-inline-size: var(--hc-menu-min-width);
36
36
  max-inline-size: var(--hc-menu-max-width);
37
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.12);
37
+ box-shadow: var(--hc-shadow-lg);
38
38
  }
39
39
 
40
40
  /* Anchor Positioning path. installMenu injects the matching
@@ -117,7 +117,7 @@
117
117
  min-inline-size: var(--hc-multicombobox-listbox-min-width);
118
118
  max-block-size: var(--hc-multicombobox-listbox-max-height);
119
119
  overflow-y: auto;
120
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.12);
120
+ box-shadow: var(--hc-shadow-lg);
121
121
  list-style: none;
122
122
  }
123
123
 
@@ -77,7 +77,7 @@
77
77
  background: var(--hc-navmenu-panel-bg);
78
78
  color: var(--hc-navmenu-panel-fg);
79
79
  min-inline-size: var(--hc-navmenu-panel-min-width);
80
- box-shadow: 0 8px 24px rgb(0, 0, 0, 0.12);
80
+ box-shadow: var(--hc-shadow-lg);
81
81
  }
82
82
 
83
83
  /* Links inside a panel stack as a readable list. */
@@ -14,7 +14,7 @@
14
14
  color: var(--hc-popover-fg);
15
15
  min-inline-size: var(--hc-popover-min-width);
16
16
  max-inline-size: var(--hc-popover-max-width);
17
- box-shadow: 0 6px 20px rgb(0, 0, 0, 0.12);
17
+ box-shadow: var(--hc-shadow-lg);
18
18
 
19
19
  /* Shared directional placement (hc-anchored.css). Anchoring is opt-in via
20
20
  * data-side + installPopover; a bare popover stays browser-positioned. */
@@ -46,7 +46,7 @@
46
46
  block-size: var(--hc-switch-thumb-size);
47
47
  background-color: var(--hc-switch-thumb-bg);
48
48
  border-radius: 50%;
49
- box-shadow: 0 1px 2px rgb(0, 0, 0, 0.15);
49
+ box-shadow: var(--hc-shadow-sm);
50
50
  translate: 0 -50%;
51
51
  transition: translate 120ms ease;
52
52
  }
package/dist/hc-tabs.css CHANGED
@@ -226,12 +226,12 @@
226
226
 
227
227
  .hc-tabs__scroll[data-dir="start"] {
228
228
  inset-inline-start: 0;
229
- box-shadow: 4px 0 6px -4px rgb(0, 0, 0, 0.2);
229
+ box-shadow: 4px 0 6px -4px var(--hc-shadow-edge);
230
230
  }
231
231
 
232
232
  .hc-tabs__scroll[data-dir="end"] {
233
233
  inset-inline-end: 0;
234
- box-shadow: -4px 0 6px -4px rgb(0, 0, 0, 0.2);
234
+ box-shadow: -4px 0 6px -4px var(--hc-shadow-edge);
235
235
  }
236
236
 
237
237
  .hc-tabs__scroll::before {
package/dist/hc-toast.css CHANGED
@@ -66,7 +66,7 @@
66
66
  border: 1px solid var(--hc-toast-info-border);
67
67
  background: var(--hc-toast-info-bg);
68
68
  color: var(--hc-toast-info-fg);
69
- box-shadow: 0 4px 12px rgb(0, 0, 0, 0.08);
69
+ box-shadow: var(--hc-shadow-md);
70
70
 
71
71
  /* Horizontal drag is the swipe-to-dismiss gesture; the behavior animates
72
72
  * the snap-back / fly-out via these transitions. */