@sealpixel/ui 1.0.0-rc.18 → 1.0.0-rc.19

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.
@@ -79,7 +79,10 @@ export class SealpixelToolbar extends LitElement {
79
79
  height: 28px;
80
80
  display: grid;
81
81
  place-items: center;
82
- border-radius: 8px;
82
+ /* The chip sits inside the button, so it takes the small radius the
83
+ theme pairs with --sealpixel-radius. A pill rule on ::part(tool)
84
+ can set the token too and round the chip with the button. */
85
+ border-radius: var(--sealpixel-radius-sm);
83
86
  /*
84
87
  * The filled pill is the one element that says which tool is open, so
85
88
  * it is the one that earns a spring. Colour and shadow ride the
@@ -1 +1 @@
1
- {"version":3,"file":"sealpixel-toolbar.js","sourceRoot":"","sources":["../../src/components/sealpixel-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,0FAA0F;AAC1F,MAAM,OAAO,gBAAiB,SAAQ,UAAU;aAC9B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqJF;KACF,AAxJqB,CAwJpB;aAEc,eAAU,GAAG;QAC3B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC3B,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5C,CAAC,EAAE,EAAE,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C,SAAS;YAClG,CAAC,CAAC,OACN;;gCAEoB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;kBAChC,CACX;WACI,CAAC;IACV,CAAC;IAEO,MAAM,CAAC,EAAU;QACvB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC9E,CAAC;IACJ,CAAC","sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { base } from '../theme.js';\nimport type { UiTool } from '../tool.js';\n\n/** Tool switcher with roving tabindex. Horizontal on narrow layouts, vertical on wide. */\nexport class SealpixelToolbar extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: flex;\n padding: 4px;\n background: var(--sealpixel-color-surface);\n border-top: 1px solid var(--sealpixel-color-border);\n overflow: auto;\n scrollbar-width: thin;\n /* Arrow keys move the roving tabindex; the scroll follows it smoothly. */\n scroll-behavior: smooth;\n }\n .tools {\n display: flex;\n gap: 4px;\n /* Centres when it fits, scrolls from the first button when it does not. */\n margin: auto;\n }\n :host([orientation='vertical']) {\n border-top: none;\n border-right: 1px solid var(--sealpixel-color-border);\n /* The rail has a fixed width: a long label truncates, it never scrolls sideways. */\n overflow-x: hidden;\n }\n :host([orientation='vertical']) .tools {\n flex-direction: column;\n margin: 0;\n width: 100%;\n min-width: 0;\n }\n :host([orientation='vertical']) button {\n width: 100%;\n min-width: 0;\n }\n /* A long label (German, for example) must not widen the horizontal bar. */\n :host(:not([orientation='vertical'])) button {\n max-inline-size: var(--sealpixel-toolbar-label-max, 88px);\n }\n button {\n min-width: var(--sealpixel-touch-target);\n min-height: calc(var(--sealpixel-touch-target) + 10px);\n border: 1px solid transparent;\n border-radius: var(--sealpixel-radius);\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: calc(var(--sealpixel-font-size) * 11 / 14);\n font-weight: 500;\n letter-spacing: 0.01em;\n cursor: pointer;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 4px;\n padding: 6px 4px;\n max-width: 100%;\n transition:\n background var(--sealpixel-transition),\n color var(--sealpixel-transition);\n }\n button:hover {\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n }\n button[aria-pressed='true'] {\n color: var(--sealpixel-color-accent);\n background: var(--sealpixel-color-accent-soft, var(--sealpixel-color-surface-2));\n }\n .icon {\n font-size: calc(var(--sealpixel-font-size) * 20 / 14);\n line-height: 1;\n width: 28px;\n height: 28px;\n display: grid;\n place-items: center;\n border-radius: 8px;\n /*\n * The filled pill is the one element that says which tool is open, so\n * it is the one that earns a spring. Colour and shadow ride the\n * standard curve underneath, otherwise the overshoot shows up as a\n * flash of accent at the edges.\n */\n transition:\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring),\n background var(--sealpixel-duration) var(--sealpixel-ease),\n color var(--sealpixel-duration) var(--sealpixel-ease),\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease);\n }\n button:hover .icon {\n transform: translateY(-1px);\n }\n button[aria-pressed='true'] .icon {\n background: var(--sealpixel-color-accent);\n color: var(--sealpixel-color-accent-fg);\n box-shadow: var(--sealpixel-shadow-sm, none);\n transform: none;\n }\n button:active .icon {\n transform: scale(0.92);\n transition-duration: var(--sealpixel-duration-fast);\n }\n .label {\n /*\n * A block as wide as the button, so the ellipsis applies in every\n * engine. It must not shrink: a flex item with overflow hidden may\n * collapse in the column and cut the descenders. The line height stays\n * inherited, because the host page sets it and the panel measures it.\n */\n display: block;\n box-sizing: border-box;\n width: 100%;\n flex: none;\n min-width: 0;\n max-width: 100%;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n /* A count over the icon's corner, notification style. Hidden at zero. */\n .icon-wrap {\n position: relative;\n }\n .badge {\n position: absolute;\n top: -6px;\n right: -10px;\n min-width: 16px;\n height: 16px;\n padding: 0 4px;\n box-sizing: border-box;\n border-radius: 999px;\n background: var(--sealpixel-color-accent);\n color: var(--sealpixel-color-accent-fg);\n font-size: calc(var(--sealpixel-font-size) * 10 / 14);\n line-height: 16px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n text-align: center;\n pointer-events: none;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n }\n `,\n ];\n\n static override properties = {\n tools: { attribute: false },\n badges: { attribute: false },\n active: { type: String },\n orientation: { type: String, reflect: true },\n t: { attribute: false },\n };\n\n declare tools: UiTool[];\n /** Counts by tool id, shown as a bubble on the button; a missing or zero entry shows nothing. */\n declare badges: Record<string, number>;\n declare active: string | null;\n declare orientation: 'horizontal' | 'vertical';\n declare t: (key: string, params?: Record<string, string | number>) => string;\n\n constructor() {\n super();\n this.tools = [];\n this.badges = {};\n this.active = null;\n this.orientation = 'horizontal';\n this.t = (k) => k;\n }\n\n override render() {\n return html`<div class=\"tools\" role=\"toolbar\" aria-orientation=${this.orientation} @keydown=${this.onKeydown}>\n ${this.tools.map(\n (tool, i) => html`<button\n part=\"tool\"\n type=\"button\"\n data-tool=${tool.id}\n title=${this.t(tool.label)}\n aria-pressed=${this.active === tool.id ? 'true' : 'false'}\n tabindex=${this.active === tool.id || (this.active === null && i === 0) ? 0 : -1}\n @click=${() => this.select(tool.id)}\n >\n <span class=\"icon-wrap\">\n <span class=\"icon\" aria-hidden=\"true\">${tool.icon}</span>\n ${\n this.badges[tool.id]\n ? html`<span part=\"badge\" class=\"badge\" aria-hidden=\"true\">${(this.badges[tool.id] as number) > 99 ? '99+' : this.badges[tool.id]}</span>\n <span class=\"sr-only\">${this.t('tool.badge', { count: this.badges[tool.id] as number })}</span>`\n : nothing\n }\n </span>\n <span class=\"label\">${this.t(tool.label)}</span>\n </button>`,\n )}\n </div>`;\n }\n\n private select(id: string): void {\n this.dispatchEvent(\n new CustomEvent('tool-select', { detail: id, bubbles: true, composed: true }),\n );\n }\n\n private onKeydown = (e: KeyboardEvent) => {\n const keys =\n this.orientation === 'vertical' ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight'];\n const dir = e.key === keys[0] ? -1 : e.key === keys[1] ? 1 : 0;\n if (dir === 0) return;\n e.preventDefault();\n const idx = Math.max(\n 0,\n this.tools.findIndex((t) => t.id === this.active),\n );\n const next = this.tools[(idx + dir + this.tools.length) % this.tools.length];\n if (next) {\n this.select(next.id);\n this.updateComplete.then(() =>\n (this.renderRoot.querySelector(`[data-tool=\"${next.id}\"]`) as HTMLElement | null)?.focus(),\n );\n }\n };\n}\n"]}
1
+ {"version":3,"file":"sealpixel-toolbar.js","sourceRoot":"","sources":["../../src/components/sealpixel-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAGnC,0FAA0F;AAC1F,MAAM,OAAO,gBAAiB,SAAQ,UAAU;aAC9B,WAAM,GAAG;QACvB,IAAI;QACJ,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwJF;KACF,AA3JqB,CA2JpB;aAEc,eAAU,GAAG;QAC3B,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC3B,MAAM,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;QAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACxB,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5C,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;KACxB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N;;gCAEoB,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;kBAChC,CACX;WACI,CAAC;IACV,CAAC;IAEO,MAAM,CAAC,EAAU;QACvB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAC9E,CAAC;IACJ,CAAC","sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { base } from '../theme.js';\nimport type { UiTool } from '../tool.js';\n\n/** Tool switcher with roving tabindex. Horizontal on narrow layouts, vertical on wide. */\nexport class SealpixelToolbar extends LitElement {\n static override styles = [\n base,\n css`\n :host {\n display: flex;\n padding: 4px;\n background: var(--sealpixel-color-surface);\n border-top: 1px solid var(--sealpixel-color-border);\n overflow: auto;\n scrollbar-width: thin;\n /* Arrow keys move the roving tabindex; the scroll follows it smoothly. */\n scroll-behavior: smooth;\n }\n .tools {\n display: flex;\n gap: 4px;\n /* Centres when it fits, scrolls from the first button when it does not. */\n margin: auto;\n }\n :host([orientation='vertical']) {\n border-top: none;\n border-right: 1px solid var(--sealpixel-color-border);\n /* The rail has a fixed width: a long label truncates, it never scrolls sideways. */\n overflow-x: hidden;\n }\n :host([orientation='vertical']) .tools {\n flex-direction: column;\n margin: 0;\n width: 100%;\n min-width: 0;\n }\n :host([orientation='vertical']) button {\n width: 100%;\n min-width: 0;\n }\n /* A long label (German, for example) must not widen the horizontal bar. */\n :host(:not([orientation='vertical'])) button {\n max-inline-size: var(--sealpixel-toolbar-label-max, 88px);\n }\n button {\n min-width: var(--sealpixel-touch-target);\n min-height: calc(var(--sealpixel-touch-target) + 10px);\n border: 1px solid transparent;\n border-radius: var(--sealpixel-radius);\n background: transparent;\n color: var(--sealpixel-color-fg-muted);\n font: inherit;\n font-size: calc(var(--sealpixel-font-size) * 11 / 14);\n font-weight: 500;\n letter-spacing: 0.01em;\n cursor: pointer;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 4px;\n padding: 6px 4px;\n max-width: 100%;\n transition:\n background var(--sealpixel-transition),\n color var(--sealpixel-transition);\n }\n button:hover {\n color: var(--sealpixel-color-fg);\n background: var(--sealpixel-color-surface-2);\n }\n button[aria-pressed='true'] {\n color: var(--sealpixel-color-accent);\n background: var(--sealpixel-color-accent-soft, var(--sealpixel-color-surface-2));\n }\n .icon {\n font-size: calc(var(--sealpixel-font-size) * 20 / 14);\n line-height: 1;\n width: 28px;\n height: 28px;\n display: grid;\n place-items: center;\n /* The chip sits inside the button, so it takes the small radius the\n theme pairs with --sealpixel-radius. A pill rule on ::part(tool)\n can set the token too and round the chip with the button. */\n border-radius: var(--sealpixel-radius-sm);\n /*\n * The filled pill is the one element that says which tool is open, so\n * it is the one that earns a spring. Colour and shadow ride the\n * standard curve underneath, otherwise the overshoot shows up as a\n * flash of accent at the edges.\n */\n transition:\n transform var(--sealpixel-duration) var(--sealpixel-ease-spring),\n background var(--sealpixel-duration) var(--sealpixel-ease),\n color var(--sealpixel-duration) var(--sealpixel-ease),\n box-shadow var(--sealpixel-duration) var(--sealpixel-ease);\n }\n button:hover .icon {\n transform: translateY(-1px);\n }\n button[aria-pressed='true'] .icon {\n background: var(--sealpixel-color-accent);\n color: var(--sealpixel-color-accent-fg);\n box-shadow: var(--sealpixel-shadow-sm, none);\n transform: none;\n }\n button:active .icon {\n transform: scale(0.92);\n transition-duration: var(--sealpixel-duration-fast);\n }\n .label {\n /*\n * A block as wide as the button, so the ellipsis applies in every\n * engine. It must not shrink: a flex item with overflow hidden may\n * collapse in the column and cut the descenders. The line height stays\n * inherited, because the host page sets it and the panel measures it.\n */\n display: block;\n box-sizing: border-box;\n width: 100%;\n flex: none;\n min-width: 0;\n max-width: 100%;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n /* A count over the icon's corner, notification style. Hidden at zero. */\n .icon-wrap {\n position: relative;\n }\n .badge {\n position: absolute;\n top: -6px;\n right: -10px;\n min-width: 16px;\n height: 16px;\n padding: 0 4px;\n box-sizing: border-box;\n border-radius: 999px;\n background: var(--sealpixel-color-accent);\n color: var(--sealpixel-color-accent-fg);\n font-size: calc(var(--sealpixel-font-size) * 10 / 14);\n line-height: 16px;\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n text-align: center;\n pointer-events: none;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n }\n `,\n ];\n\n static override properties = {\n tools: { attribute: false },\n badges: { attribute: false },\n active: { type: String },\n orientation: { type: String, reflect: true },\n t: { attribute: false },\n };\n\n declare tools: UiTool[];\n /** Counts by tool id, shown as a bubble on the button; a missing or zero entry shows nothing. */\n declare badges: Record<string, number>;\n declare active: string | null;\n declare orientation: 'horizontal' | 'vertical';\n declare t: (key: string, params?: Record<string, string | number>) => string;\n\n constructor() {\n super();\n this.tools = [];\n this.badges = {};\n this.active = null;\n this.orientation = 'horizontal';\n this.t = (k) => k;\n }\n\n override render() {\n return html`<div class=\"tools\" role=\"toolbar\" aria-orientation=${this.orientation} @keydown=${this.onKeydown}>\n ${this.tools.map(\n (tool, i) => html`<button\n part=\"tool\"\n type=\"button\"\n data-tool=${tool.id}\n title=${this.t(tool.label)}\n aria-pressed=${this.active === tool.id ? 'true' : 'false'}\n tabindex=${this.active === tool.id || (this.active === null && i === 0) ? 0 : -1}\n @click=${() => this.select(tool.id)}\n >\n <span class=\"icon-wrap\">\n <span class=\"icon\" aria-hidden=\"true\">${tool.icon}</span>\n ${\n this.badges[tool.id]\n ? html`<span part=\"badge\" class=\"badge\" aria-hidden=\"true\">${(this.badges[tool.id] as number) > 99 ? '99+' : this.badges[tool.id]}</span>\n <span class=\"sr-only\">${this.t('tool.badge', { count: this.badges[tool.id] as number })}</span>`\n : nothing\n }\n </span>\n <span class=\"label\">${this.t(tool.label)}</span>\n </button>`,\n )}\n </div>`;\n }\n\n private select(id: string): void {\n this.dispatchEvent(\n new CustomEvent('tool-select', { detail: id, bubbles: true, composed: true }),\n );\n }\n\n private onKeydown = (e: KeyboardEvent) => {\n const keys =\n this.orientation === 'vertical' ? ['ArrowUp', 'ArrowDown'] : ['ArrowLeft', 'ArrowRight'];\n const dir = e.key === keys[0] ? -1 : e.key === keys[1] ? 1 : 0;\n if (dir === 0) return;\n e.preventDefault();\n const idx = Math.max(\n 0,\n this.tools.findIndex((t) => t.id === this.active),\n );\n const next = this.tools[(idx + dir + this.tools.length) % this.tools.length];\n if (next) {\n this.select(next.id);\n this.updateComplete.then(() =>\n (this.renderRoot.querySelector(`[data-tool=\"${next.id}\"]`) as HTMLElement | null)?.focus(),\n );\n }\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealpixel/ui",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.19",
4
4
  "description": "Default, themeable Sealpixel editor UI as Web Components (Lit). Optional: the core is headless.",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
@@ -36,13 +36,13 @@
36
36
  "./themes/*": "./themes/*"
37
37
  },
38
38
  "dependencies": {
39
- "@sealpixel/core": "1.0.0-rc.15",
40
- "@sealpixel/plugins": "1.0.0-rc.18",
39
+ "@sealpixel/core": "1.0.0-rc.19",
40
+ "@sealpixel/plugins": "1.0.0-rc.19",
41
41
  "lit": "^3.3.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@sealpixel/config": "0.0.0",
45
- "@sealpixel/wasm": "1.0.0-rc.15",
45
+ "@sealpixel/wasm": "1.0.0-rc.19",
46
46
  "@types/node": "^24.0.0",
47
47
  "typescript": "^6.0.0",
48
48
  "vitest": "^5.0.0"