@getflip/swirl-components 0.170.0 → 0.171.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.
Files changed (44) hide show
  1. package/components.json +35 -5
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/swirl-avatar.cjs.entry.js +1 -3
  4. package/dist/cjs/swirl-components.cjs.js +1 -1
  5. package/dist/cjs/swirl-image-grid-item.cjs.entry.js +1 -3
  6. package/dist/cjs/swirl-shell-layout.cjs.entry.js +2 -2
  7. package/dist/cjs/swirl-switch.cjs.entry.js +3 -2
  8. package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
  9. package/dist/collection/collection-manifest.json +1 -1
  10. package/dist/collection/components/swirl-avatar/swirl-avatar.js +1 -3
  11. package/dist/collection/components/swirl-image-grid-item/swirl-image-grid-item.js +1 -3
  12. package/dist/collection/components/swirl-image-grid-item/swirl-image-grid-item.stories.js +2 -0
  13. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.css +6 -4
  14. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.js +4 -3
  15. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.spec.js +1 -1
  16. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.stories.js +5 -1
  17. package/dist/collection/components/swirl-switch/swirl-switch.css +10 -0
  18. package/dist/collection/components/swirl-switch/swirl-switch.js +25 -1
  19. package/dist/collection/components/swirl-switch/swirl-switch.spec.js +1 -1
  20. package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
  21. package/dist/components/swirl-avatar.js +1 -3
  22. package/dist/components/swirl-image-grid-item.js +1 -3
  23. package/dist/components/swirl-shell-layout.js +2 -2
  24. package/dist/components/swirl-switch.js +4 -2
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/swirl-avatar.entry.js +1 -3
  27. package/dist/esm/swirl-components.js +1 -1
  28. package/dist/esm/swirl-image-grid-item.entry.js +1 -3
  29. package/dist/esm/swirl-shell-layout.entry.js +2 -2
  30. package/dist/esm/swirl-switch.entry.js +3 -2
  31. package/dist/swirl-components/p-0935f67d.entry.js +1 -0
  32. package/dist/swirl-components/p-8acf7c0d.entry.js +1 -0
  33. package/dist/swirl-components/p-d2b60287.entry.js +1 -0
  34. package/dist/swirl-components/p-f69e0df8.entry.js +1 -0
  35. package/dist/swirl-components/swirl-components.esm.js +1 -1
  36. package/dist/types/components/swirl-shell-layout/swirl-shell-layout.d.ts +3 -2
  37. package/dist/types/components/swirl-switch/swirl-switch.d.ts +2 -0
  38. package/dist/types/components.d.ts +4 -0
  39. package/package.json +1 -1
  40. package/vscode-data.json +12 -0
  41. package/dist/swirl-components/p-345c4495.entry.js +0 -1
  42. package/dist/swirl-components/p-650a66f5.entry.js +0 -1
  43. package/dist/swirl-components/p-b4ba60d8.entry.js +0 -1
  44. package/dist/swirl-components/p-cffe1258.entry.js +0 -1
@@ -40,6 +40,7 @@
40
40
  "./components/swirl-skeleton-text/swirl-skeleton-text.js",
41
41
  "./components/swirl-spinner/swirl-spinner.js",
42
42
  "./components/swirl-status-indicator/swirl-status-indicator.js",
43
+ "./components/swirl-switch/swirl-switch.js",
43
44
  "./components/swirl-tab/swirl-tab.js",
44
45
  "./components/swirl-tab-bar/swirl-tab-bar.js",
45
46
  "./components/swirl-table-column/swirl-table-column.js",
@@ -248,7 +249,6 @@
248
249
  "./components/swirl-select/swirl-select.js",
249
250
  "./components/swirl-shell-layout/swirl-shell-layout.js",
250
251
  "./components/swirl-shell-navigation-item/swirl-shell-navigation-item.js",
251
- "./components/swirl-switch/swirl-switch.js",
252
252
  "./components/swirl-symbol/symbols/swirl-symbol-cloud.js",
253
253
  "./components/swirl-symbol/swirl-symbol.js",
254
254
  "./components/swirl-symbol/symbols/swirl-symbol-account-circle.js",
@@ -83,9 +83,7 @@ export class SwirlAvatar {
83
83
  this.intersectionObserver.observe(this.element);
84
84
  }
85
85
  onVisibilityChange(entries) {
86
- if (entries[0].isIntersecting) {
87
- this.inViewport = true;
88
- }
86
+ this.inViewport = entries.some((entry) => entry.isIntersecting);
89
87
  }
90
88
  render() {
91
89
  const showImage = Boolean(this.src) &&
@@ -46,9 +46,7 @@ export class SwirlImageGridItem {
46
46
  this.intersectionObserver.observe(this.el);
47
47
  }
48
48
  onVisibilityChange(entries) {
49
- if (entries[0].isIntersecting) {
50
- this.inViewport = true;
51
- }
49
+ this.inViewport = entries.some((entry) => entry.isIntersecting);
52
50
  }
53
51
  render() {
54
52
  const Tag = this.interactive ? "button" : "div";
@@ -13,6 +13,7 @@ export default {
13
13
  const Template = (args) => {
14
14
  const container = document.createElement("swirl-image-grid");
15
15
  const element = generateStoryElement("swirl-image-grid-item", args);
16
+ container.style.paddingTop = "200vh";
16
17
  container.append(element);
17
18
  return container;
18
19
  };
@@ -20,5 +21,6 @@ export const SwirlImageGridItem = Template.bind({});
20
21
  SwirlImageGridItem.args = {
21
22
  alt: "Dog in a blanket",
22
23
  icon: "<swirl-icon-play-arrow></swirl-icon-play-arrow>",
24
+ loading: "intersecting",
23
25
  src: "/sample.jpg",
24
26
  };
@@ -217,20 +217,21 @@
217
217
  display: flex;
218
218
  flex-basis: 8rem;
219
219
  flex-shrink: 0;
220
+ align-items: center;
220
221
  gap: var(--s-space-8);
221
222
  }
222
223
 
223
224
  .shell-layout__header-right {
225
+ --swirl-ghost-button-background-default: var(--s-surface-sunken-default);
226
+ --swirl-ghost-button-background-hovered: var(--s-surface-sunken-hovered);
227
+ --swirl-ghost-button-background-pressed: var(--s-surface-sunken-pressed);
228
+
224
229
  display: flex;
225
230
  flex-basis: 8rem;
226
231
  flex-shrink: 0;
227
232
  justify-content: flex-end;
228
233
  align-items: center;
229
234
  gap: var(--s-space-8);
230
-
231
- --swirl-ghost-button-background-default: var(--s-surface-sunken-default);
232
- --swirl-ghost-button-background-hovered: var(--s-surface-sunken-hovered);
233
- --swirl-ghost-button-background-pressed: var(--s-surface-sunken-pressed);
234
235
  }
235
236
 
236
237
  .shell-layout__logo {
@@ -254,6 +255,7 @@
254
255
  width: 2.25rem;
255
256
  height: 2.25rem;
256
257
  padding: var(--s-space-8);
258
+ flex-shrink: 0;
257
259
  border: none;
258
260
  border-radius: var(--s-border-radius-sm);
259
261
  color: var(--swirl-shell-text-color);
@@ -5,9 +5,10 @@ const NAVIGATION_COLLAPSE_STORAGE_KEY = "SWIRL_SHELL_NAVIGATION_COLLAPSE_STATE";
5
5
  const SIDEBAR_STORAGE_KEY = "SWIRL_SHELL_SIDEBAR_STATE";
6
6
  /**
7
7
  * @slot logo - Logo shown inside header.
8
- * @slot avatar - User avatar positioned on the header's right-hand side.
9
- * @slot header-tools - Tools positioned on the header's right-hand side.
8
+ * @slot left-header-tools - Tools positioned on the header's left-hand side.
9
+ * @slot right-header-tools - Tools positioned on the header's right-hand side.
10
10
  * @slot mobile-header-tools - Tools positioned in the mobile drawer header.
11
+ * @slot avatar - User avatar positioned on the header's right-hand side.
11
12
  * @slot nav - Items shown in the lower sidebar part.
12
13
  * @slot mobile-logo - Logo shown inside the mobile navigation drawer.
13
14
  * @slot default - Contents of the main area.
@@ -110,7 +111,7 @@ export class SwirlShellLayout {
110
111
  "shell-layout--navigation-collapsed": this.navigationCollapsed,
111
112
  "shell-layout--sidebar-active": this.sidebarActive,
112
113
  });
113
- return (h(Host, null, h("div", { class: className }, h("header", { class: "shell-layout__header", "data-tauri-drag-region": "true" }, h("button", { class: "shell-layout__skip-link", onClick: this.skipLinkClick.emit, type: "button" }, this.skipLinkLabel), h("div", { class: "shell-layout__header-left" }, h("button", { class: "shell-layout__header-tool shell-layout__navigation-toggle", onClick: this.onNavigationToggleClick, type: "button" }, h("swirl-icon-hamburger-menu", { size: 20 }), h("swirl-icon-double-arrow-left", { size: 20 }), h("swirl-icon-double-arrow-right", { size: 20 }), h("swirl-visually-hidden", null, this.navigationToggleLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserBackClick, type: "button" }, h("swirl-icon-arrow-back", { size: 20 }), h("swirl-visually-hidden", null, this.browserBackButtonLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserForwardClick, type: "button" }, h("swirl-icon-arrow-forward", { size: 20 }), h("swirl-visually-hidden", null, this.browserForwardButtonLabel))), h("div", { class: "shell-layout__logo" }, h("slot", { name: "logo" })), h("div", { class: "shell-layout__header-right" }, h("slot", { name: "header-tools" }), h("button", { class: "shell-layout__header-tool shell-layout__sidebar-toggle", onClick: this.sidebarToggleClick.emit, type: "button" }, h("swirl-icon", { glyph: this.sidebarToggleIcon, size: 20 }), h("swirl-visually-hidden", null, this.sidebarToggleLabel), this.sidebarToggleBadge && (h("swirl-badge", { "aria-label": this.sidebarToggleBadgeAriaLabel, label: !hasSidebarToggleBadgeWithLabel
114
+ return (h(Host, null, h("div", { class: className }, h("header", { class: "shell-layout__header", "data-tauri-drag-region": "true" }, h("button", { class: "shell-layout__skip-link", onClick: this.skipLinkClick.emit, type: "button" }, this.skipLinkLabel), h("div", { class: "shell-layout__header-left" }, h("button", { class: "shell-layout__header-tool shell-layout__navigation-toggle", onClick: this.onNavigationToggleClick, type: "button" }, h("swirl-icon-hamburger-menu", { size: 20 }), h("swirl-icon-double-arrow-left", { size: 20 }), h("swirl-icon-double-arrow-right", { size: 20 }), h("swirl-visually-hidden", null, this.navigationToggleLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserBackClick, type: "button" }, h("swirl-icon-arrow-back", { size: 20 }), h("swirl-visually-hidden", null, this.browserBackButtonLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserForwardClick, type: "button" }, h("swirl-icon-arrow-forward", { size: 20 }), h("swirl-visually-hidden", null, this.browserForwardButtonLabel)), h("slot", { name: "left-header-tools" })), h("div", { class: "shell-layout__logo" }, h("slot", { name: "logo" })), h("div", { class: "shell-layout__header-right" }, h("slot", { name: "right-header-tools" }), h("button", { class: "shell-layout__header-tool shell-layout__sidebar-toggle", onClick: this.sidebarToggleClick.emit, type: "button" }, h("swirl-icon", { glyph: this.sidebarToggleIcon, size: 20 }), h("swirl-visually-hidden", null, this.sidebarToggleLabel), this.sidebarToggleBadge && (h("swirl-badge", { "aria-label": this.sidebarToggleBadgeAriaLabel, label: !hasSidebarToggleBadgeWithLabel
114
115
  ? this.sidebarToggleBadgeAriaLabel
115
116
  : String(this.sidebarToggleBadge), size: "xs", variant: !hasSidebarToggleBadgeWithLabel ? "dot" : "default" }))), h("slot", { name: "avatar" }))), h("div", { class: "shell-layout__mobile-nav-backdrop", onClick: this.onNavigationClick }), h("nav", { "aria-labelledby": "main-navigation-label", class: "shell-layout__nav", onClick: this.onNavigationClick, ref: (el) => (this.navElement = el) }, h("div", { class: "shell-layout__mobile-header" }, h("slot", { name: "mobile-logo" }), h("div", { class: "shell-layout__mobile-header-tools" }, h("slot", { name: "mobile-header-tools" }), h("button", { class: "shell-layout__header-tool", type: "button" }, h("swirl-icon-double-arrow-left", { size: 20 }), h("swirl-visually-hidden", null, this.hideMobileNavigationButtonLabel)))), h("div", { class: "shell-layout__nav-body" }, h("swirl-visually-hidden", null, h("span", { id: "main-navigation-label" }, this.navigationLabel)), h("slot", { name: "nav" }))), h("main", { class: "shell-layout__main", id: "main-content" }, h("slot", null)), h("aside", { class: "shell-layout__sidebar", ...{ inert: this.sidebarActive ? undefined : true } }, h("div", { class: "shell-layout__sidebar-body" }, h("div", { class: "shell-layout__sidebar-app-bar" }, h("slot", { name: "sidebar-app-bar" })), h("div", { class: "shell-layout__sidebar-content" }, h("slot", { name: "sidebar" })))))));
116
117
  }
@@ -14,6 +14,6 @@ describe("swirl-shell-layout", () => {
14
14
  <div slot="sidebar">Sidebar</div>
15
15
  </swirl-shell-layout>`,
16
16
  });
17
- expect(page.root.innerHTML).toMatchInlineSnapshot(`"<!----> <div slot=\\"sidebar-header\\" hidden=\\"\\">Sidebar header</div> <div class=\\"shell-layout\\"><header class=\\"shell-layout__header\\" data-tauri-drag-region=\\"true\\"><button class=\\"shell-layout__skip-link\\" type=\\"button\\">Skip to main content</button><div class=\\"shell-layout__header-left\\"><button class=\\"shell-layout__header-tool shell-layout__navigation-toggle\\" type=\\"button\\"><swirl-icon-hamburger-menu size=\\"20\\"></swirl-icon-hamburger-menu><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-icon-double-arrow-right size=\\"20\\"></swirl-icon-double-arrow-right><swirl-visually-hidden>Toggle navigation</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-back size=\\"20\\"></swirl-icon-arrow-back><swirl-visually-hidden>Navigate back</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-forward size=\\"20\\"></swirl-icon-arrow-forward><swirl-visually-hidden>Navigate forward</swirl-visually-hidden></button></div><div class=\\"shell-layout__logo\\"> <div slot=\\"logo\\">Logo</div></div><div class=\\"shell-layout__header-right\\"> <div slot=\\"header-tools\\">Tools</div><button class=\\"shell-layout__header-tool shell-layout__sidebar-toggle\\" type=\\"button\\"><swirl-icon glyph=\\"notifications\\" size=\\"20\\"></swirl-icon><swirl-visually-hidden>Toggle sidebar</swirl-visually-hidden></button> </div></header><div class=\\"shell-layout__mobile-nav-backdrop\\"></div><nav aria-labelledby=\\"main-navigation-label\\" class=\\"shell-layout__nav\\"><div class=\\"shell-layout__mobile-header\\"> <div slot=\\"mobile-logo\\">Mobile logo</div><div class=\\"shell-layout__mobile-header-tools\\"> <button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-visually-hidden>Close navigation</swirl-visually-hidden></button></div></div><div class=\\"shell-layout__nav-body\\"><swirl-visually-hidden><span id=\\"main-navigation-label\\">Main</span></swirl-visually-hidden> <div slot=\\"nav\\">nav</div></div></nav><main class=\\"shell-layout__main\\" id=\\"main-content\\"> <div>Main</div> </main><aside class=\\"shell-layout__sidebar\\" inert=\\"\\"><div class=\\"shell-layout__sidebar-body\\"><div class=\\"shell-layout__sidebar-app-bar\\"></div><div class=\\"shell-layout__sidebar-content\\"> <div slot=\\"sidebar\\">Sidebar</div></div></div></aside></div>"`);
17
+ expect(page.root.innerHTML).toMatchInlineSnapshot(`"<!----> <div slot=\\"header-tools\\" hidden=\\"\\">Tools</div> <div slot=\\"sidebar-header\\" hidden=\\"\\">Sidebar header</div> <div class=\\"shell-layout\\"><header class=\\"shell-layout__header\\" data-tauri-drag-region=\\"true\\"><button class=\\"shell-layout__skip-link\\" type=\\"button\\">Skip to main content</button><div class=\\"shell-layout__header-left\\"><button class=\\"shell-layout__header-tool shell-layout__navigation-toggle\\" type=\\"button\\"><swirl-icon-hamburger-menu size=\\"20\\"></swirl-icon-hamburger-menu><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-icon-double-arrow-right size=\\"20\\"></swirl-icon-double-arrow-right><swirl-visually-hidden>Toggle navigation</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-back size=\\"20\\"></swirl-icon-arrow-back><swirl-visually-hidden>Navigate back</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-forward size=\\"20\\"></swirl-icon-arrow-forward><swirl-visually-hidden>Navigate forward</swirl-visually-hidden></button> </div><div class=\\"shell-layout__logo\\"> <div slot=\\"logo\\">Logo</div></div><div class=\\"shell-layout__header-right\\"> <button class=\\"shell-layout__header-tool shell-layout__sidebar-toggle\\" type=\\"button\\"><swirl-icon glyph=\\"notifications\\" size=\\"20\\"></swirl-icon><swirl-visually-hidden>Toggle sidebar</swirl-visually-hidden></button> </div></header><div class=\\"shell-layout__mobile-nav-backdrop\\"></div><nav aria-labelledby=\\"main-navigation-label\\" class=\\"shell-layout__nav\\"><div class=\\"shell-layout__mobile-header\\"> <div slot=\\"mobile-logo\\">Mobile logo</div><div class=\\"shell-layout__mobile-header-tools\\"> <button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-visually-hidden>Close navigation</swirl-visually-hidden></button></div></div><div class=\\"shell-layout__nav-body\\"><swirl-visually-hidden><span id=\\"main-navigation-label\\">Main</span></swirl-visually-hidden> <div slot=\\"nav\\">nav</div></div></nav><main class=\\"shell-layout__main\\" id=\\"main-content\\"> <div>Main</div> </main><aside class=\\"shell-layout__sidebar\\" inert=\\"\\"><div class=\\"shell-layout__sidebar-body\\"><div class=\\"shell-layout__sidebar-app-bar\\"></div><div class=\\"shell-layout__sidebar-content\\"> <div slot=\\"sidebar\\">Sidebar</div></div></div></aside></div>"`);
18
18
  });
19
19
  });
@@ -30,7 +30,11 @@ const Template = (args) => {
30
30
  <swirl-avatar label="John Doe" slot="avatar" src="https://picsum.photos/id/433/144/144"></swirl-avatar>
31
31
  <swirl-avatar label="John Doe" slot="mobile-header-tools" src="https://picsum.photos/id/433/144/144"></swirl-avatar>
32
32
 
33
- <swirl-button label="Header tool" slot="header-tools" variant="outline"></swirl-button>
33
+ <swirl-box padding-inline-start="16" slot="left-header-tools">
34
+ <swirl-switch label="Header tool" label-position="start"></swirl-switch>
35
+ </swirl-box>
36
+
37
+ <swirl-button label="Header tool" slot="right-header-tools" variant="outline"></swirl-button>
34
38
 
35
39
  <div slot="nav">
36
40
  <ul>
@@ -17,6 +17,15 @@
17
17
  0 0 0 0.1875rem var(--s-focus-default);
18
18
  }
19
19
 
20
+ .switch--label-position-start {
21
+ flex-direction: row-reverse;
22
+ }
23
+
24
+ .switch--label-position-start .switch__label {
25
+ margin-right: var(--s-space-12);
26
+ margin-left: 0;
27
+ }
28
+
20
29
  .switch--on .switch__thumb {
21
30
  left: calc(100% - 1.25rem - var(--s-space-2));
22
31
  }
@@ -106,4 +115,5 @@
106
115
  font-size: var(--s-font-size-sm);
107
116
  font-weight: var(--s-font-weight-medium);
108
117
  line-height: var(--s-line-height-base);
118
+ white-space: nowrap;
109
119
  }
@@ -12,13 +12,14 @@ export class SwirlSwitch {
12
12
  this.inputId = undefined;
13
13
  this.inputName = undefined;
14
14
  this.label = undefined;
15
+ this.labelPosition = "end";
15
16
  this.value = undefined;
16
17
  }
17
18
  render() {
18
19
  const off = !this.checked;
19
20
  const on = this.checked;
20
21
  const ariaCheckedLabel = on ? "true" : "false";
21
- const className = classnames("switch", {
22
+ const className = classnames("switch", `switch--label-position-${this.labelPosition}`, {
22
23
  "switch--off": off,
23
24
  "switch--on": on,
24
25
  "switch--disabled": this.disabled,
@@ -143,6 +144,29 @@ export class SwirlSwitch {
143
144
  "attribute": "label",
144
145
  "reflect": false
145
146
  },
147
+ "labelPosition": {
148
+ "type": "string",
149
+ "mutable": false,
150
+ "complexType": {
151
+ "original": "SwirlSwitchLabelPosition",
152
+ "resolved": "\"end\" | \"start\"",
153
+ "references": {
154
+ "SwirlSwitchLabelPosition": {
155
+ "location": "local",
156
+ "path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-switch/swirl-switch.tsx"
157
+ }
158
+ }
159
+ },
160
+ "required": false,
161
+ "optional": true,
162
+ "docs": {
163
+ "tags": [],
164
+ "text": ""
165
+ },
166
+ "attribute": "label-position",
167
+ "reflect": false,
168
+ "defaultValue": "\"end\""
169
+ },
146
170
  "value": {
147
171
  "type": "string",
148
172
  "mutable": false,
@@ -8,7 +8,7 @@ describe("swirl-switch", () => {
8
8
  });
9
9
  expect(page.root).toMatchInlineSnapshot(`
10
10
  <swirl-switch checked="true" disabled="true" input-id="switch" input-name="switch" label="Label" value="Value">
11
- <label class="switch switch--disabled switch--on" htmlfor="switch">
11
+ <label class="switch switch--disabled switch--label-position-end switch--on" htmlfor="switch">
12
12
  <span class="switch__control">
13
13
  <swirl-visually-hidden>
14
14
  <input aria-checked="true" checked="" class="switch__input" disabled="" id="switch" name="switch" role="switch" type="checkbox" value="Value">