@swiftwc/ui 0.0.0-dev.27 → 0.0.0-dev.29

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.
@@ -19,7 +19,7 @@ export declare const alert: (title?: string, message?: string, actions?: {
19
19
  }[], options?: {
20
20
  titleVisibility?: boolean;
21
21
  }) => Promise<void>;
22
- export declare const confirmationDialog: (trigger: HTMLElement, title: string, actions?: {
22
+ export declare const confirmationDialog: (trigger: HTMLElement, title: string, message?: string, actions?: {
23
23
  label?: string;
24
24
  image?: string;
25
25
  role?: string;
@@ -356,15 +356,20 @@ export const alert = async (title, message, actions, options) => {
356
356
  return promise;
357
357
  });
358
358
  };
359
- export const confirmationDialog = async (trigger, title, actions, options) => {
359
+ export const confirmationDialog = async (trigger, title, message, actions, options) => {
360
360
  const newAnchorName = `--confirmation-dialog-${self.crypto.randomUUID()}`;
361
- const dialog = $(`<dialog is="confirmation-dialog"></dialog>`, '>1');
361
+ const dialog = $(`<dialog is="confirmation-dialog"></dialog>`, '>1'), vStack = dialog.querySelector(':scope>v-stack') ?? dialog.appendChild($(`<v-stack spacing="1" alignment="fill"></v-stack>`, '>1'));
362
362
  trigger.style.setProperty('anchor-name', newAnchorName, 'important'); //$.prop('anchor-name', newAnchorName, trigger, 'important')
363
363
  dialog.style.setProperty('position-anchor', newAnchorName); //$.prop('position-anchor', newAnchorName, dialog)
364
364
  if (title && false !== options?.titleVisibility) {
365
- const label = $(`<label-view></label-view>`, '>1');
365
+ const label = $(`<label-view font="headline"></label-view>`, '>1');
366
366
  label.setAttribute('title', title);
367
- dialog.insertAdjacentElement('beforeend', label);
367
+ vStack.insertAdjacentElement('beforeend', label);
368
+ }
369
+ if (message && false !== options?.titleVisibility) {
370
+ const label = $(`<label-view foreground="secondary" font="callout"></label-view>`, '>1');
371
+ label.setAttribute('title', message);
372
+ vStack.insertAdjacentElement('beforeend', label);
368
373
  }
369
374
  for (const [index, action] of (actions ?? []).entries()) {
370
375
  const btn = $(`<button type="button" tabindex="0" is="bordered-button"></button>`, '>1');
@@ -43,7 +43,7 @@ export class ToolBarItem extends HTMLElement {
43
43
  case 'data-previous-slot':
44
44
  case 'title-key':
45
45
  const target = this.querySelector(':scope>button'), nv = this.getAttribute('data-previous-slot') ?? this.getAttribute('slot') ?? '';
46
- if (target && ['confirmation-action'].includes(nv))
46
+ if (target && ['confirmation-action', 'cancellation-action'].includes(nv))
47
47
  Snapshot.waitReady.then(() => {
48
48
  buttonRole(target, nv, this.getAttribute('title-key'));
49
49
  });
@@ -874,6 +874,7 @@
874
874
  }
875
875
  :where([is=glass-prominent-button] > [slot], [is=glass-button] > [slot], [is=bordered-prominent-button] > [slot], [is=bordered-button] > [slot], [is=borderless-button] > [slot], [is=plain-button] > [slot]) {
876
876
  position: absolute;
877
+ inset: 0;
877
878
  visibility: collapse;
878
879
  }
879
880
  :where([is=glass-prominent-button] > [slot=overlay], [is=glass-button] > [slot=overlay], [is=bordered-prominent-button] > [slot=overlay], [is=bordered-button] > [slot=overlay], [is=borderless-button] > [slot=overlay], [is=plain-button] > [slot=overlay]) {
@@ -1695,8 +1696,8 @@
1695
1696
  color: var(--text, );
1696
1697
  touch-action: none;
1697
1698
  position: fixed;
1698
- inline-size: max-content;
1699
- block-size: max-content;
1699
+ inline-size: fit-content;
1700
+ block-size: fit-content;
1700
1701
  height: auto;
1701
1702
  min-inline-size: min(20rem, 80svw);
1702
1703
  max-inline-size: var(--confirmation--dialog-max-inline-size, );
@@ -1712,12 +1713,12 @@
1712
1713
  box-shadow: var(--menu-popover-box-shadow, );
1713
1714
  padding-block: 1rem;
1714
1715
  padding-inline: 1rem;
1715
- gap: 0.5rem;
1716
+ gap: 1rem;
1716
1717
  --confirmation--dialog-scale: scale(0);
1717
1718
  }
1718
1719
  :where([is=confirmation-dialog][open]) {
1719
- --confirmation--dialog-max-inline-size: 100vw;
1720
- --confirmation--dialog-max-block-size: 100vh;
1720
+ --confirmation--dialog-max-inline-size: min(20rem, 80vw);
1721
+ --confirmation--dialog-max-block-size: 80vh;
1721
1722
  --confirmation--dialog-margin-block: max(env(safe-area-inset-top), var(--menu-spacing)) max(env(safe-area-inset-bottom), var(--menu-spacing));
1722
1723
  --confirmation--dialog-margin-inline: max(env(safe-area-inset-left), var(--menu-spacing)) max(env(safe-area-inset-right), var(--menu-spacing));
1723
1724
  --confirmation--dialog-scale: scale(1);
@@ -2117,6 +2118,7 @@
2117
2118
  }
2118
2119
  :where(tool-bar-item > button > [slot]) {
2119
2120
  position: absolute;
2121
+ inset: 0;
2120
2122
  visibility: collapse;
2121
2123
  }
2122
2124
  :where(tool-bar-item > button > [slot=overlay]) {
@@ -2189,6 +2191,15 @@
2189
2191
  --accentColor4: var(--red4);
2190
2192
  --accentColor5: var(--red5);
2191
2193
  }
2194
+ :where([is=borderless-button][role=confirm]) {
2195
+ --accentColorEffective: var(--blue);
2196
+ --accentColorEffective4: var(--blue4);
2197
+ --accentColor: var(--blue);
2198
+ --accentColor2: var(--blue2);
2199
+ --accentColor3: var(--blue3);
2200
+ --accentColor4: var(--blue4);
2201
+ --accentColor5: var(--blue5);
2202
+ }
2192
2203
  }
2193
2204
  @layer sw-utils {
2194
2205
  :where([is=borderless-button]) {
@@ -2240,6 +2251,15 @@
2240
2251
  --accentColor4: var(--red4);
2241
2252
  --accentColor5: var(--red5);
2242
2253
  }
2254
+ :where([is=bordered-button][role=confirm]) {
2255
+ --accentColorEffective: var(--blue);
2256
+ --accentColorEffective4: var(--blue4);
2257
+ --accentColor: var(--blue);
2258
+ --accentColor2: var(--blue2);
2259
+ --accentColor3: var(--blue3);
2260
+ --accentColor4: var(--blue4);
2261
+ --accentColor5: var(--blue5);
2262
+ }
2243
2263
  }
2244
2264
  @layer sw-utils {
2245
2265
  :where([is=bordered-button]) {
@@ -2286,9 +2306,18 @@
2286
2306
  --accentColor4: var(--red4);
2287
2307
  --accentColor5: var(--red5);
2288
2308
  }
2309
+ :where([is=bordered-prominent-button][role=confirm]) {
2310
+ --accentColorEffective: var(--blue);
2311
+ --accentColorEffective4: var(--blue4);
2312
+ --accentColor: var(--blue);
2313
+ --accentColor2: var(--blue2);
2314
+ --accentColor3: var(--blue3);
2315
+ --accentColor4: var(--blue4);
2316
+ --accentColor5: var(--blue5);
2317
+ }
2289
2318
  }
2290
2319
  @layer sw-colors {
2291
- [is=bordered-prominent-button] {
2320
+ :where([is=bordered-prominent-button] > *) {
2292
2321
  --secondary: var(--btntext);
2293
2322
  --blue: var(--btntext);
2294
2323
  }
@@ -2341,6 +2370,15 @@
2341
2370
  --accentColor4: var(--red4);
2342
2371
  --accentColor5: var(--red5);
2343
2372
  }
2373
+ :where([is=glass-button][role=confirm]) {
2374
+ --accentColorEffective: var(--blue);
2375
+ --accentColorEffective4: var(--blue4);
2376
+ --accentColor: var(--blue);
2377
+ --accentColor2: var(--blue2);
2378
+ --accentColor3: var(--blue3);
2379
+ --accentColor4: var(--blue4);
2380
+ --accentColor5: var(--blue5);
2381
+ }
2344
2382
  }
2345
2383
  @layer sw-utils {
2346
2384
  :where([is=glass-button]) {
@@ -2390,9 +2428,18 @@
2390
2428
  --accentColor4: var(--red4);
2391
2429
  --accentColor5: var(--red5);
2392
2430
  }
2431
+ :where([is=glass-prominent-button][role=confirm]) {
2432
+ --accentColorEffective: var(--blue);
2433
+ --accentColorEffective4: var(--blue4);
2434
+ --accentColor: var(--blue);
2435
+ --accentColor2: var(--blue2);
2436
+ --accentColor3: var(--blue3);
2437
+ --accentColor4: var(--blue4);
2438
+ --accentColor5: var(--blue5);
2439
+ }
2393
2440
  }
2394
2441
  @layer sw-colors {
2395
- [is=glass-prominent-button] {
2442
+ :where([is=glass-prominent-button] > *) {
2396
2443
  --secondary: var(--btntext);
2397
2444
  --blue: var(--btntext);
2398
2445
  }
@@ -5,9 +5,9 @@ declare const _default: () => {
5
5
  readonly Description: "Ελέγξτε την ορθογραφία ή δοκιμάστε μια νέα αναζήτηση.";
6
6
  };
7
7
  readonly ButtonRole: {
8
- readonly Cancel: "Cancel";
9
- readonly Close: "Close";
10
- readonly Confirm: "Confirm";
8
+ readonly Cancel: "Ακύρωση";
9
+ readonly Close: "Κλείσιμο";
10
+ readonly Confirm: "Τέλος";
11
11
  readonly Destructive: "Διαγραφή";
12
12
  readonly OK: "OK";
13
13
  };
@@ -6,9 +6,9 @@ export default defineTranslations(() => ({
6
6
  Description: 'Ελέγξτε την ορθογραφία ή δοκιμάστε μια νέα αναζήτηση.',
7
7
  },
8
8
  ButtonRole: {
9
- Cancel: 'Cancel',
10
- Close: 'Close',
11
- Confirm: 'Confirm',
9
+ Cancel: 'Ακύρωση',
10
+ Close: 'Κλείσιμο',
11
+ Confirm: 'Τέλος',
12
12
  Destructive: 'Διαγραφή',
13
13
  OK: 'OK',
14
14
  },
@@ -32,6 +32,10 @@ function renderPlaceholder(el, role, titleKey) {
32
32
  label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Confirm);
33
33
  label.setAttribute('system-image', Snapshot.config['confirm-button-icon']);
34
34
  break;
35
+ case 'cancellation-action':
36
+ label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Cancel);
37
+ label.setAttribute('system-image', Snapshot.config['cancel-button-icon']);
38
+ break;
35
39
  case 'destructive':
36
40
  label.setAttribute('title', titleKey && titleKey in I18n.t('ButtonRole') ? I18n.t('ButtonRole')[titleKey] : I18n.t('ButtonRole').Destructive);
37
41
  label.setAttribute('system-image', Snapshot.config['delete-button-icon']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swiftwc/ui",
3
- "version": "0.0.0-dev.27",
3
+ "version": "0.0.0-dev.29",
4
4
  "description": "Elegant SwiftUI-inspired web components for standalone web apps and web extensions.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -71,8 +71,8 @@
71
71
  "format:check": "prettier . --check",
72
72
  "format:write": "prettier . --write",
73
73
  "test": "vitest --dom",
74
- "predeploy": "rm -rf generated",
75
- "deploy": "npm run build:ts && npm run build:scss",
74
+ "prepackage": "rm -rf generated",
75
+ "package": "npm run build:ts && npm run build:scss",
76
76
  "version:pkg": "npm version $npm_config_bump --no-git-tag-version --preid=dev"
77
77
  },
78
78
  "devDependencies": {
@@ -35,6 +35,16 @@
35
35
  --accentColor4: var(--red4);
36
36
  --accentColor5: var(--red5);
37
37
  }
38
+ :where(&[role='confirm']) {
39
+ --accentColorEffective: var(--blue);
40
+ --accentColorEffective4: var(--blue4);
41
+
42
+ --accentColor: var(--blue);
43
+ --accentColor2: var(--blue2);
44
+ --accentColor3: var(--blue3);
45
+ --accentColor4: var(--blue4);
46
+ --accentColor5: var(--blue5);
47
+ }
38
48
  }
39
49
  }
40
50
 
@@ -32,13 +32,25 @@
32
32
  --accentColor4: var(--red4);
33
33
  --accentColor5: var(--red5);
34
34
  }
35
+ :where(&[role='confirm']) {
36
+ --accentColorEffective: var(--blue);
37
+ --accentColorEffective4: var(--blue4);
38
+
39
+ --accentColor: var(--blue);
40
+ --accentColor2: var(--blue2);
41
+ --accentColor3: var(--blue3);
42
+ --accentColor4: var(--blue4);
43
+ --accentColor5: var(--blue5);
44
+ }
35
45
  }
36
46
  }
37
47
 
38
48
  @layer #{vars.$colors-layer} {
39
- [is='bordered-prominent-button'] {
40
- --secondary: var(--btntext);
41
- --blue: var(--btntext);
49
+ [is='bordered-prominent-button'] > * {
50
+ :where(&) {
51
+ --secondary: var(--btntext);
52
+ --blue: var(--btntext);
53
+ }
42
54
  }
43
55
  }
44
56
 
@@ -22,6 +22,16 @@
22
22
  --accentColor4: var(--red4);
23
23
  --accentColor5: var(--red5);
24
24
  }
25
+ :where(&[role='confirm']) {
26
+ --accentColorEffective: var(--blue);
27
+ --accentColorEffective4: var(--blue4);
28
+
29
+ --accentColor: var(--blue);
30
+ --accentColor2: var(--blue2);
31
+ --accentColor3: var(--blue3);
32
+ --accentColor4: var(--blue4);
33
+ --accentColor5: var(--blue5);
34
+ }
25
35
  }
26
36
  }
27
37
 
@@ -12,8 +12,8 @@
12
12
 
13
13
  position: fixed;
14
14
 
15
- inline-size: max-content;
16
- block-size: max-content;
15
+ inline-size: fit-content;
16
+ block-size: fit-content;
17
17
  height: auto; // safari
18
18
 
19
19
  min-inline-size: min(20rem, 80svw);
@@ -37,7 +37,7 @@
37
37
 
38
38
  padding-block: 1rem;
39
39
  padding-inline: 1rem;
40
- gap: 0.5rem;
40
+ gap: 1rem;
41
41
 
42
42
  // finally
43
43
  --confirmation--dialog-scale: scale(0);
@@ -45,8 +45,8 @@
45
45
 
46
46
  &[open] {
47
47
  :where(&) {
48
- --confirmation--dialog-max-inline-size: 100vw;
49
- --confirmation--dialog-max-block-size: 100vh;
48
+ --confirmation--dialog-max-inline-size: min(20rem, 80vw);
49
+ --confirmation--dialog-max-block-size: 80vh;
50
50
 
51
51
  --confirmation--dialog-margin-block: max(env(safe-area-inset-top), var(--menu-spacing)) max(env(safe-area-inset-bottom), var(--menu-spacing));
52
52
  --confirmation--dialog-margin-inline: max(env(safe-area-inset-left), var(--menu-spacing)) max(env(safe-area-inset-right), var(--menu-spacing));
@@ -37,6 +37,16 @@
37
37
  --accentColor4: var(--red4);
38
38
  --accentColor5: var(--red5);
39
39
  }
40
+ :where(&[role='confirm']) {
41
+ --accentColorEffective: var(--blue);
42
+ --accentColorEffective4: var(--blue4);
43
+
44
+ --accentColor: var(--blue);
45
+ --accentColor2: var(--blue2);
46
+ --accentColor3: var(--blue3);
47
+ --accentColor4: var(--blue4);
48
+ --accentColor5: var(--blue5);
49
+ }
40
50
  }
41
51
  }
42
52
 
@@ -37,13 +37,25 @@
37
37
  --accentColor4: var(--red4);
38
38
  --accentColor5: var(--red5);
39
39
  }
40
+ :where(&[role='confirm']) {
41
+ --accentColorEffective: var(--blue);
42
+ --accentColorEffective4: var(--blue4);
43
+
44
+ --accentColor: var(--blue);
45
+ --accentColor2: var(--blue2);
46
+ --accentColor3: var(--blue3);
47
+ --accentColor4: var(--blue4);
48
+ --accentColor5: var(--blue5);
49
+ }
40
50
  }
41
51
  }
42
52
 
43
53
  @layer #{vars.$colors-layer} {
44
- [is='glass-prominent-button'] {
45
- --secondary: var(--btntext);
46
- --blue: var(--btntext);
54
+ [is='glass-prominent-button'] > * {
55
+ :where(&) {
56
+ --secondary: var(--btntext);
57
+ --blue: var(--btntext);
58
+ }
47
59
  }
48
60
  }
49
61
 
@@ -4,6 +4,8 @@
4
4
  // take over NOTE: NO other propsm they break grids!! KISS pos+visibility+opacity
5
5
  position: absolute;
6
6
 
7
+ inset: 0;
8
+
7
9
  visibility: collapse;
8
10
  }
9
11
  }
@@ -5,12 +5,6 @@
5
5
  @media (prefers-reduced-motion: no-preference) {
6
6
  [is='confirmation-dialog'] {
7
7
  :where(&) {
8
- // transition:
9
- // block-size var(--menu-animation-duration) allow-discrete ease-out,
10
- // inline-size var(--menu-animation-duration) allow-discrete ease-out,
11
- // display var(--menu-animation-duration) allow-discrete ease-out,
12
- // overlay var(--menu-animation-duration) allow-discrete ease-out,
13
- // transform var(--menu-animation-duration) allow-discrete ease-out;
14
8
  transition: all var(--touchglass-transition-duration) allow-discrete ease-out;
15
9
  // will-change: block-size, inline-size, transform, overlay, display;
16
10
  }