@gjsify/adwaita-storybook 0.47.0 → 0.48.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 (2) hide show
  1. package/package.json +6 -6
  2. package/src/controls.ts +12 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/adwaita-storybook",
3
- "version": "0.47.0",
3
+ "version": "0.48.0",
4
4
  "description": "Browser renderer for the @gjsify/stories contract — the web counterpart of @gjsify/storybook, built on @gjsify/adwaita-web",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -30,13 +30,13 @@
30
30
  "browser"
31
31
  ],
32
32
  "dependencies": {
33
- "@gjsify/adwaita-core": "^0.47.0",
34
- "@gjsify/adwaita-web": "^0.47.0",
35
- "@gjsify/stories": "^0.47.0",
36
- "@gjsify/storybook-core": "^0.47.0"
33
+ "@gjsify/adwaita-core": "^0.48.0",
34
+ "@gjsify/adwaita-web": "^0.48.0",
35
+ "@gjsify/stories": "^0.48.0",
36
+ "@gjsify/storybook-core": "^0.48.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@gjsify/cli": "^0.47.0",
39
+ "@gjsify/cli": "^0.48.0",
40
40
  "typescript": "^6.0.3"
41
41
  },
42
42
  "gjsify": {
package/src/controls.ts CHANGED
@@ -88,9 +88,17 @@ const ADWAITA_WEB_FACTORY: ControlWidgetFactory<HTMLElement> = {
88
88
  number(control: StoryNumberControl): ControlWidget<HTMLElement, number> {
89
89
  const row = document.createElement('adw-spin-row') as HTMLElement & { value: number };
90
90
  row.setAttribute('title', label(control));
91
- row.setAttribute('min', String(control.min ?? 0));
92
- row.setAttribute('max', String(control.max ?? 100));
93
- row.setAttribute('step', String(control.step ?? 1));
91
+ // A STORY CONTROL keeps `min`/`max`/`step` — that is `Adw.SpinRow.new_with_range`'s
92
+ // own vocabulary, which the GTK storybook calls directly — and the ELEMENT takes one
93
+ // `adjustment` (ADR 0047). This line is the map between the two.
94
+ row.setAttribute(
95
+ 'adjustment',
96
+ JSON.stringify({
97
+ lower: control.min ?? 0,
98
+ upper: control.max ?? 100,
99
+ stepIncrement: control.step ?? 1,
100
+ }),
101
+ );
94
102
  let cb: (v: number) => void = () => {};
95
103
  row.addEventListener('notify::value', (e) => cb((e as CustomEvent<{ value: number }>).detail.value));
96
104
  return {
@@ -109,7 +117,7 @@ const ADWAITA_WEB_FACTORY: ControlWidgetFactory<HTMLElement> = {
109
117
  const options = control.options ?? [];
110
118
  const row = document.createElement('adw-combo-row') as HTMLElement & { selected: number };
111
119
  row.setAttribute('title', label(control));
112
- row.setAttribute('items', JSON.stringify(options.map((o) => o.label)));
120
+ row.setAttribute('model', JSON.stringify(options.map((o) => o.label)));
113
121
  let cb: (v: number) => void = () => {};
114
122
  row.addEventListener('notify::selected', (e) => cb((e as CustomEvent<{ selected: number }>).detail.selected));
115
123
  return {