@antadesign/anta 0.3.34 → 0.3.35
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.
- package/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1333
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.js +2 -2
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -35
- package/dist/components/Select.js +53 -97
- package/dist/components/SelectFaceted.d.ts +7 -3
- package/dist/components/SelectFaceted.js +21 -9
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.js +1 -11
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +5 -8
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +16 -26
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-button.d.ts +2 -1
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +66 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -1
- package/dist/elements/a-select-faceted.js +1 -1
- package/dist/elements/a-select.d.ts +1 -1
- package/dist/elements/a-select.js +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +3 -3
- package/dist/elements/index.js +3 -7
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +348 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +2 -1
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +183 -26
- package/docs/packages/plot.md +170 -148
- package/docs/theming.md +7 -0
- package/package.json +41 -3
- package/theme-antithesis-license.md +66 -0
package/dist/elements/a-card.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-card{--card-text: var(--text-2);--card-bg-secondary: var(--bg-2);--card-bg-primary: light-dark(var(--bg-1), var(--bg-4));--card-bg: var(--card-bg-primary);--card-border: var(--border-4);--card-border-hover: var(--border-3);--card-selected-ring: var(--border-1);--card-bg-hover-lift: .01;--card-radius: 8px;--card-padding: 12px;--card-content-fs: 15px;--card-content-lh: 20px;--card-icon-size: 40px;--card-icon-bg: light-dark(var(--bg-4), var(--bg-5));--card-header-nudge: 2px;display:
|
|
1
|
+
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-card{--card-text: var(--text-2);--card-bg-secondary: var(--bg-2);--card-bg-primary: light-dark(var(--bg-1), var(--bg-4));--card-bg: var(--card-bg-primary);--card-border: var(--border-4);--card-border-hover: var(--border-3);--card-selected-ring: var(--border-1);--card-bg-hover-lift: .01;--card-direction: column;--card-media-flex: 0 1 auto;--card-content-animation: none;--card-selection-shadow: inset 0 0 0 0 transparent;--card-subtitle-gap: 1px;--card-radius: 8px;--card-padding: 12px;--card-content-fs: 15px;--card-content-lh: 20px;--card-icon-size: 40px;--card-icon-bg: light-dark(var(--bg-4), var(--bg-5));--card-header-nudge: 2px;display:flex;flex-direction:var(--card-direction);box-sizing:border-box;position:relative;width:100%;container-type:inline-size;container-name:card;color:var(--card-text);background:var(--card-bg);box-shadow:0 0 0 1px var(--card-border),var(--card-selection-shadow);border-radius:var(--card-radius);overflow:clip;transition:background-color .15s ease,box-shadow .15s ease}a-card[media-position=bottom]{--card-direction: column-reverse}a-card[media-position=left]{--card-direction: row;--card-media-flex: none}a-card[media-position=right]{--card-direction: row-reverse;--card-media-flex: none}a-card[selected]{--card-selection-shadow: inset 0 0 0 2px var(--card-selected-ring, var(--focus-ring))}a-card[priority=secondary]{--card-bg: var(--card-bg-secondary);--card-icon-blend: multiply}.dark a-card:not([priority=tertiary]){--card-icon-blend: exclusion}a-card[round]{--card-radius: var(--card-round, 999px);@supports (border-radius: attr(probe type(<length>),1px)){--card-round: attr(round type(<length>))}}a-card[priority=tertiary]{--card-bg: color-mix(in oklch, var(--card-bg-primary) 1%, transparent);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}@media(hover:hover)and (pointer:fine){a-card:has(>a[data-anta-card-link]):not([loading]):hover{background:oklch(from var(--card-bg) calc(l + var(--card-bg-hover-lift)) c h)}a-card:not([loading]):hover{box-shadow:0 0 0 1px var(--card-border-hover),var(--card-selection-shadow)}}a-card:has(>a[data-anta-card-link]):not([loading]):active{box-shadow:0 0 0 1px var(--card-border),var(--card-selection-shadow)}@media(prefers-reduced-motion:reduce){a-card{transition:none}}a-card>a[data-anta-card-link]{display:block;flex:1 1 auto;box-sizing:border-box;width:100%;height:100%;min-width:0;border-radius:var(--card-radius, 8px);color:inherit;text-decoration:none;-webkit-user-drag:none;user-select:none}a-card>a[data-anta-card-link]:focus-visible{outline:none;box-shadow:inset 0 0 0 1px transparent,inset 0 0 0 2px var(--focus-ring)}a-card>a[data-anta-card-link]>a-card-layout{display:flex;flex-direction:var(--card-direction, column);box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0}a-card-media{display:block;flex:var(--card-media-flex, 0 1 auto)}a-card-content{display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0;animation:var(--card-content-animation, none);font-size:var(--card-content-fs, 15px);line-height:var(--card-content-lh, 20px)}a-card-header{display:flex;align-items:center;gap:1ch;padding:var(--card-padding, 12px);padding-block-start:calc(var(--card-padding, 12px) - var(--card-header-nudge, 1px));padding-block-end:calc(var(--card-padding, 12px) / 2)}a-card-icon{display:flex;flex:none;align-items:center;mix-blend-mode:var(--card-icon-blend, normal)}a-card-title{display:block;flex:1 1 auto;min-width:0}a-card-body{display:block;flex:1 1 auto;min-width:0;min-height:0;padding:var(--card-padding, 12px)}a-card-footer{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-start;padding:var(--card-padding, 12px)}a-card-header+a-card-body{padding-block-start:0}a-card-body:has(+a-card-footer){padding-block-end:0}a-card-icon-chip{display:grid;place-items:center;width:var(--card-icon-size);height:var(--card-icon-size);border-radius:50%;background:var(--card-icon-bg)}a-card[loading]{pointer-events:none}@media(prefers-reduced-motion:no-preference){a-card[loading]{--card-content-animation: card-pulse 1.4s ease-in-out infinite}}@keyframes card-pulse{0%,to{opacity:1}50%{opacity:.55}}a-card-title :is(h1,h2,h3,h4,h5,h6),a-card-title a-title[level]{margin-block:0}a-card-body>:is(h1,h2,h3,h4,h5,h6),a-card-body>a-title[level]{margin-block-start:0}a-card[size=large]{--card-subtitle-gap: 2px}a-card-title>a-title+a-text,a-card-title>:is(h1,h2,h3,h4,h5,h6)+a-text{margin-block-start:var(--card-subtitle-gap, 1px)}a-card[tone=brand]{--card-text: var(--text-2-brand);--card-bg-secondary: light-dark(var(--bg-4-brand), var(--bg-2-brand));--card-bg-primary: light-dark(var(--bg-2-brand), var(--bg-4-brand));--card-border: var(--border-4-brand);--card-border-hover: var(--border-3-brand);--card-icon-bg: var(--bg-5-brand);--card-selected-ring: var(--border-1-brand)}a-card[tone=info]{--card-text: var(--text-2-info);--card-bg-secondary: light-dark(var(--bg-4-info), var(--bg-2-info));--card-bg-primary: light-dark(var(--bg-2-info), var(--bg-4-info));--card-border: var(--border-4-info);--card-border-hover: var(--border-3-info);--card-icon-bg: var(--bg-5-info);--card-selected-ring: var(--border-1-info)}a-card[tone=success]{--card-text: var(--text-2-success);--card-bg-secondary: light-dark(var(--bg-4-success), var(--bg-2-success));--card-bg-primary: light-dark(var(--bg-2-success), var(--bg-4-success));--card-border: var(--border-4-success);--card-border-hover: var(--border-3-success);--card-icon-bg: var(--bg-5-success);--card-selected-ring: var(--border-1-success)}a-card[tone=warning]{--card-text: var(--text-2-warning);--card-bg-secondary: light-dark(var(--bg-4-warning), var(--bg-2-warning));--card-bg-primary: light-dark(var(--bg-2-warning), var(--bg-4-warning));--card-border: var(--border-4-warning);--card-border-hover: var(--border-3-warning);--card-icon-bg: var(--bg-5-warning);--card-selected-ring: var(--border-1-warning)}a-card[tone=critical]{--card-text: var(--text-2-critical);--card-bg-secondary: light-dark(var(--bg-4-critical), var(--bg-2-critical));--card-bg-primary: light-dark(var(--bg-2-critical), var(--bg-4-critical));--card-border: var(--border-4-critical);--card-border-hover: var(--border-3-critical);--card-icon-bg: var(--bg-5-critical);--card-selected-ring: var(--border-1-critical)}a-card[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--card-tone-source: currentColor;--card-text: light-dark(oklch(from var(--card-tone-source) .41 .15 h), oklch(from var(--card-tone-source) .75 .11 h));--card-bg-secondary: light-dark(oklch(from var(--card-tone-source) .955 .02 h), oklch(from var(--card-tone-source) .13 .02 h));--card-bg-primary: light-dark(oklch(from var(--card-tone-source) .99 .006 h), oklch(from var(--card-tone-source) .19 .04 h));--card-icon-bg: light-dark(oklch(from var(--card-tone-source) .925 .03 h), oklch(from var(--card-tone-source) .22 .05 h));--card-border: light-dark(oklch(from var(--card-tone-source) .895 .045 h), oklch(from var(--card-tone-source) .26 .07 h));--card-border-hover: light-dark(oklch(from var(--card-tone-source) .85 .06 h), oklch(from var(--card-tone-source) .32 .09 h));--card-selected-ring: light-dark(oklch(from var(--card-tone-source) .6 .15 h), oklch(from var(--card-tone-source) .7 .13 h));@supports (color: attr(probe type(<color>),red)){--card-tone-source: attr(tone type(<color>), currentColor)}}a-card[priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3), color-mix(in oklch, var(--bg-5), white 10%))}a-card[tone=brand][priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3-brand), color-mix(in oklch, var(--bg-5-brand), white 10%))}a-card[tone=info][priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3-info), color-mix(in oklch, var(--bg-5-info), white 10%))}a-card[tone=success][priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3-success), color-mix(in oklch, var(--bg-5-success), white 10%))}a-card[tone=warning][priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3-warning), color-mix(in oklch, var(--bg-5-warning), white 10%))}a-card[tone=critical][priority=tertiary]{--card-icon-bg: light-dark(var(--bg-3-critical), color-mix(in oklch, var(--bg-5-critical), white 10%))}a-card[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical])[priority=tertiary]{--card-icon-bg: light-dark( oklch(from var(--card-tone-source) .97 .014 h), color-mix(in oklch, oklch(from var(--card-tone-source) .22 .05 h), white 10%) )}@media(forced-colors:active){a-card{border:1px solid CanvasText;box-shadow:none}a-card:has(>a[data-anta-card-link]){border-color:LinkText}a-card[selected],a-card>a[data-anta-card-link]:focus-visible{outline:2px solid Highlight;outline-offset:-3px;box-shadow:none}a-card-icon-chip{box-sizing:border-box;border:1px dotted CanvasText}}a-card[size=small]{--card-padding: 8px;--card-header-nudge: 1px;--card-icon-size: 32px;--card-content-fs: 13px;--card-content-lh: 16px}a-card[size=large]{--card-padding: 16px;--card-header-nudge: 4px;--card-icon-size: 44px;--card-content-fs: 17px;--card-content-lh: 24px}}a-card-body>p:last-child{margin-block-end:0}
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import { HTMLElementBase } from '../anta_helpers';
|
|
2
1
|
import './a-card.css';
|
|
3
|
-
export declare class ACardElement extends HTMLElementBase {
|
|
4
|
-
#private;
|
|
5
|
-
static observedAttributes: string[];
|
|
6
|
-
constructor();
|
|
7
|
-
connectedCallback(): void;
|
|
8
|
-
attributeChangedCallback(): void;
|
|
9
|
-
}
|
|
10
|
-
export declare function register_a_card(): void;
|
package/dist/elements/a-card.js
CHANGED
|
@@ -1,185 +1 @@
|
|
|
1
|
-
import { HTMLElementBase } from "../anta_helpers";
|
|
2
1
|
import "./a-card.css";
|
|
3
|
-
const SHADOW_STYLE = `
|
|
4
|
-
.container {
|
|
5
|
-
display: flex;
|
|
6
|
-
flex-direction: column;
|
|
7
|
-
box-sizing: border-box;
|
|
8
|
-
width: 100%;
|
|
9
|
-
height: 100%;
|
|
10
|
-
min-width: 0;
|
|
11
|
-
color: inherit;
|
|
12
|
-
text-decoration: none;
|
|
13
|
-
cursor: default;
|
|
14
|
-
border-radius: var(--card-radius, 8px);
|
|
15
|
-
-webkit-user-drag: none;
|
|
16
|
-
}
|
|
17
|
-
:host([media-position="bottom"]) .container { flex-direction: column-reverse; }
|
|
18
|
-
:host([media-position="left"]) .container { flex-direction: row; }
|
|
19
|
-
:host([media-position="right"]) .container { flex-direction: row-reverse; }
|
|
20
|
-
|
|
21
|
-
:host([href]) .container { user-select: none; }
|
|
22
|
-
:host([href]:not([loading])) .container { cursor: pointer; }
|
|
23
|
-
|
|
24
|
-
.container:focus-visible {
|
|
25
|
-
outline: none;
|
|
26
|
-
box-shadow: inset 0 0 0 1px transparent, inset 0 0 0 2px var(--focus-ring);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
[part="media"] { display: block; }
|
|
30
|
-
:host([media-position="left"]) [part="media"],
|
|
31
|
-
:host([media-position="right"]) [part="media"] { flex: none; }
|
|
32
|
-
|
|
33
|
-
.content {
|
|
34
|
-
display: flex;
|
|
35
|
-
flex-direction: column;
|
|
36
|
-
flex: 1 1 auto;
|
|
37
|
-
min-width: 0;
|
|
38
|
-
min-height: 0;
|
|
39
|
-
/* Base type for the content zone, matching the body <a-text> at this size. The
|
|
40
|
-
title / subtitle / body all set their own font, so this changes nothing
|
|
41
|
-
visible \u2014 it defines the em/ch base so the header gap (in ch) resolves against
|
|
42
|
-
the body's type size. */
|
|
43
|
-
font-size: var(--card-content-fs, 15px);
|
|
44
|
-
line-height: var(--card-content-lh, 20px);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.header {
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
gap: 1ch;
|
|
51
|
-
padding: var(--card-padding, 12px);
|
|
52
|
-
padding-block-start: calc(var(--card-padding, 12px) - var(--card-header-nudge, 1px));
|
|
53
|
-
padding-block-end: calc(var(--card-padding, 12px) / 2);
|
|
54
|
-
}
|
|
55
|
-
slot[name="icon"] {
|
|
56
|
-
flex: none;
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
/* Off by default; secondary cards in light multiply the chip into the deeper
|
|
60
|
-
surface (see --card-icon-blend in the external sheet). */
|
|
61
|
-
mix-blend-mode: var(--card-icon-blend, normal);
|
|
62
|
-
}
|
|
63
|
-
slot[name="header"] {
|
|
64
|
-
display: block;
|
|
65
|
-
flex: 1 1 auto;
|
|
66
|
-
min-width: 0;
|
|
67
|
-
}
|
|
68
|
-
slot[part="body"] {
|
|
69
|
-
display: block;
|
|
70
|
-
flex: 1 1 auto;
|
|
71
|
-
min-width: 0;
|
|
72
|
-
min-height: 0;
|
|
73
|
-
padding: var(--card-padding, 12px);
|
|
74
|
-
}
|
|
75
|
-
slot[name="footer"] {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
gap: 8px;
|
|
79
|
-
flex-wrap: wrap;
|
|
80
|
-
justify-content: flex-start;
|
|
81
|
-
padding: var(--card-padding, 12px);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
:host([selected]) .container { box-shadow: inset 0 0 0 2px var(--card-selected-ring, var(--focus-ring)); }
|
|
85
|
-
:host([selected]) .container:focus-visible { box-shadow: inset 0 0 0 1px transparent, inset 0 0 0 2px var(--focus-ring); }
|
|
86
|
-
|
|
87
|
-
:host([loading]) .container { pointer-events: none; }
|
|
88
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
89
|
-
:host([loading]) [part="content"] { animation: card-pulse 1.4s ease-in-out infinite; }
|
|
90
|
-
}
|
|
91
|
-
@keyframes card-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
|
|
92
|
-
`;
|
|
93
|
-
class ACardElement extends HTMLElementBase {
|
|
94
|
-
static observedAttributes = ["href", "target", "rel", "ping", "loading", "aria-label"];
|
|
95
|
-
#container;
|
|
96
|
-
#headerSlot;
|
|
97
|
-
#bodySlot;
|
|
98
|
-
constructor() {
|
|
99
|
-
super();
|
|
100
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
101
|
-
const style = document.createElement("style");
|
|
102
|
-
style.textContent = SHADOW_STYLE;
|
|
103
|
-
this.#container = document.createElement("a");
|
|
104
|
-
this.#container.className = "container";
|
|
105
|
-
this.#container.setAttribute("part", "container");
|
|
106
|
-
const mediaSlot = document.createElement("slot");
|
|
107
|
-
mediaSlot.name = "media";
|
|
108
|
-
mediaSlot.setAttribute("part", "media");
|
|
109
|
-
const content = document.createElement("div");
|
|
110
|
-
content.className = "content";
|
|
111
|
-
content.setAttribute("part", "content");
|
|
112
|
-
const headerSection = document.createElement("div");
|
|
113
|
-
headerSection.className = "header";
|
|
114
|
-
headerSection.setAttribute("part", "header");
|
|
115
|
-
const iconSlot = document.createElement("slot");
|
|
116
|
-
iconSlot.name = "icon";
|
|
117
|
-
iconSlot.setAttribute("part", "icon");
|
|
118
|
-
this.#headerSlot = document.createElement("slot");
|
|
119
|
-
this.#headerSlot.name = "header";
|
|
120
|
-
this.#headerSlot.setAttribute("part", "title");
|
|
121
|
-
headerSection.append(iconSlot, this.#headerSlot);
|
|
122
|
-
this.#bodySlot = document.createElement("slot");
|
|
123
|
-
this.#bodySlot.setAttribute("part", "body");
|
|
124
|
-
const footerSlot = document.createElement("slot");
|
|
125
|
-
footerSlot.name = "footer";
|
|
126
|
-
footerSlot.setAttribute("part", "footer");
|
|
127
|
-
content.append(headerSection, this.#bodySlot, footerSlot);
|
|
128
|
-
this.#container.append(mediaSlot, content);
|
|
129
|
-
shadow.append(style, this.#container);
|
|
130
|
-
this.#headerSlot.addEventListener("slotchange", () => this.#syncName());
|
|
131
|
-
this.#bodySlot.addEventListener("slotchange", () => this.#syncName());
|
|
132
|
-
}
|
|
133
|
-
connectedCallback() {
|
|
134
|
-
this.#syncLink();
|
|
135
|
-
}
|
|
136
|
-
attributeChangedCallback() {
|
|
137
|
-
this.#syncLink();
|
|
138
|
-
}
|
|
139
|
-
/** Mirror the link attributes onto the shadow anchor — but drop `href` while
|
|
140
|
-
* `loading` so a loading card can't navigate. Also reflects `aria-busy`. */
|
|
141
|
-
#syncLink() {
|
|
142
|
-
const href = this.getAttribute("href");
|
|
143
|
-
const loading = this.hasAttribute("loading");
|
|
144
|
-
if (href != null && !loading) {
|
|
145
|
-
this.#container.setAttribute("href", href);
|
|
146
|
-
for (const name of ["target", "rel", "ping"]) {
|
|
147
|
-
const v = this.getAttribute(name);
|
|
148
|
-
if (v != null) this.#container.setAttribute(name, v);
|
|
149
|
-
else this.#container.removeAttribute(name);
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
for (const name of ["href", "target", "rel", "ping"]) {
|
|
153
|
-
this.#container.removeAttribute(name);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (loading) this.#container.setAttribute("aria-busy", "true");
|
|
157
|
-
else this.#container.removeAttribute("aria-busy");
|
|
158
|
-
this.#syncName();
|
|
159
|
-
}
|
|
160
|
-
/** Name the anchor (link mode only): explicit aria-label → header → body → href. */
|
|
161
|
-
#syncName() {
|
|
162
|
-
if (!this.#container.hasAttribute("href")) {
|
|
163
|
-
this.#container.removeAttribute("aria-label");
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const explicit = this.getAttribute("aria-label")?.trim();
|
|
167
|
-
const name = explicit || this.#slotText(this.#headerSlot) || this.#slotText(this.#bodySlot) || this.getAttribute("href") || "";
|
|
168
|
-
if (name) this.#container.setAttribute("aria-label", name);
|
|
169
|
-
else this.#container.removeAttribute("aria-label");
|
|
170
|
-
}
|
|
171
|
-
#slotText(slot) {
|
|
172
|
-
return slot.assignedNodes().map((n) => n.textContent ?? "").join(" ").replace(/\s+/g, " ").trim();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function register_a_card() {
|
|
176
|
-
if (typeof customElements === "undefined") return;
|
|
177
|
-
if (!customElements.get("a-card")) {
|
|
178
|
-
customElements.define("a-card", ACardElement);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
register_a_card();
|
|
182
|
-
export {
|
|
183
|
-
ACardElement,
|
|
184
|
-
register_a_card
|
|
185
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-checkbox{--checkbox-gap: 8px;--checkbox-box-size: 16px;--checkbox-bg: var(--bg-1);--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .6 c h), oklch(from var(--checkbox-tone-source) .42 c h));--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) .45 c h);--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: light-dark(#f6f4f6, #ece9ec);--checkbox-icon-disabled: light-dark(#c1b9c1, #534c57);--checkbox-bg-disabled: light-dark(color-mix(in oklch, #44374b 10%, transparent), color-mix(in oklch, #e4d1ef 10%, transparent));--checkbox-border-disabled: var(--checkbox-bg-disabled);--checkbox-mask-size: 12px;--checkbox-mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");--checkbox-mask-indeterminate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");--checkbox-label-color: var(--text-2);--checkbox-label-color-disabled: var(--text-4);--checkbox-hint-color: var(--text-3);--checkbox-label-fs: 15px;--checkbox-label-lh: 20px;--checkbox-hint-fs: 13px;--checkbox-hint-lh: 16px;display:inline-grid;grid-template-columns:auto 1fr;align-items:start;column-gap:var(--checkbox-gap);vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-drag:none;outline:none;color:var(--checkbox-label-color);font-family:var(--sans-serif);font-size:var(--checkbox-label-fs);line-height:var(--checkbox-label-lh);&:before{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);box-sizing:border-box;inline-size:16px;block-size:16px;border-radius:4px;background:var(--checkbox-bg);border:1.5px solid var(--checkbox-border);transition:background-color .15s ease-out,border-color .15s ease-out}&[round]{--checkbox-round: 999px;@supports (border-radius: attr(probe type(<length>),1px)){--checkbox-round: attr(round type(<length>), 999px)}}&[round]:before{border-radius:var(--checkbox-round, 999px)}&:after{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);inline-size:16px;block-size:16px;background-color:transparent;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:var(--checkbox-mask-size);mask-size:var(--checkbox-mask-size)}@media(hover:hover)and (pointer:fine){&:not(:disabled):hover:before{border-color:var(--checkbox-border-hover);transition:background-color 75ms ease-in,border-color 75ms ease-in}&:not(:disabled):hover:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}&:not(:disabled):active:before{border-color:var(--checkbox-border-active);transition:background-color 50ms linear,border-color 50ms linear}&:not(:disabled):active:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}&:is(:state(checked),:state(indeterminate)){&:before{background:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}&:after{background-color:var(--checkbox-icon)}}&:state(checked):after{-webkit-mask-image:var(--checkbox-mask-check);mask-image:var(--checkbox-mask-check)}&:state(indeterminate):after{-webkit-mask-image:var(--checkbox-mask-indeterminate);mask-image:var(--checkbox-mask-indeterminate)}&:focus-visible{outline:none}&:focus-visible:before{outline:1px solid var(--focus-ring);outline-offset:1px}&:disabled{cursor:not-allowed;color:var(--checkbox-label-color-disabled);&:before{background:var(--checkbox-bg-disabled);border-color:var(--checkbox-border-disabled);transition:none}&:is(:state(checked),:state(indeterminate)):after{background-color:var(--checkbox-icon-disabled)}a-checkbox-hint{color:var(--checkbox-label-color-disabled)}}&[size=small]{--checkbox-gap: 6px;--checkbox-box-size: 14px;--checkbox-label-fs: 13px;--checkbox-label-lh: 16px;--checkbox-hint-fs: 12px;--checkbox-hint-lh: 14px;--checkbox-mask-size: 10px;&:before,&:after{inline-size:14px;block-size:14px}}&[size=large]{--checkbox-box-size: 18px;--checkbox-label-fs: 17px;--checkbox-label-lh: 22px;--checkbox-hint-fs: 15px;--checkbox-hint-lh: 19px;--checkbox-mask-size: 14px;&:before,&:after{inline-size:18px;block-size:18px}}}.dark a-checkbox{--checkbox-mask-size: 13px}.dark a-checkbox[size=small]{--checkbox-mask-size: 11px}.dark a-checkbox[size=large]{--checkbox-mask-size: 15px}a-checkbox-label,a-checkbox-hint{display:block;grid-column:2;min-width:0}a-checkbox-hint{color:var(--checkbox-hint-color);font-size:var(--checkbox-hint-fs);line-height:var(--checkbox-hint-lh);margin-block-start:2px}a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .5 c h), oklch(from var(--checkbox-tone-source) .45 c h));--checkbox-bg-selected-hover: light-dark(oklch(from var(--checkbox-tone-source) .45 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .57 c h))}a-checkbox[tone=brand]{--checkbox-tone-source: var(--anta-seed-brand);--checkbox-off-tone-source: var(--anta-seed-brand)}a-checkbox[tone=info]{--checkbox-tone-source: var(--anta-seed-info);--checkbox-off-tone-source: var(--anta-seed-info)}a-checkbox[tone=success]{--checkbox-tone-source: var(--anta-seed-success);--checkbox-off-tone-source: var(--anta-seed-success)}a-checkbox[tone=warning]{--checkbox-tone-source: var(--anta-seed-warning);--checkbox-off-tone-source: var(--anta-seed-warning)}a-checkbox[tone=critical]{--checkbox-tone-source: var(--anta-seed-critical);--checkbox-off-tone-source: var(--anta-seed-critical)}a-checkbox[tone=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral)}a-checkbox[tone]:not([tone=""],[tone=neutral],[tone-scope=selected]){--checkbox-bg: light-dark(oklch(from var(--checkbox-off-tone-source) .99 calc(c*.03) h), oklch(from var(--checkbox-off-tone-source) .15 calc(c*.18) h));--_checkbox-off-bg-selected: var(--checkbox-bg-selected);--_checkbox-border-base: color-mix(in oklch, var(--_checkbox-off-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: light-dark(oklch(from var(--_checkbox-border-base) calc(l + .17) c h), var(--_checkbox-border-base));--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: light-dark(var(--_checkbox-border-base), oklch(from var(--_checkbox-border-base) calc(l + .17) c h))}a-checkbox[tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: transparent;--checkbox-off-tone-source: transparent;@supports (color: attr(probe type(<color>),red)){--checkbox-tone-source: attr(tone type(<color>), transparent);--checkbox-off-tone-source: attr(tone type(<color>), transparent)}}label:has(>input[data-anta][type=checkbox]){display:inline-flex;align-items:center;gap:8px;color:var(--text-2);font-family:var(--sans-serif);font-size:15px;line-height:20px}input[data-anta][type=checkbox]{--checkbox-box-size: 16px;--checkbox-mask-size: 12px;--checkbox-round: 4px;--checkbox-bg: var(--bg-1);--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .6 c h), oklch(from var(--checkbox-tone-source) .42 c h));--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) .45 c h);--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .5 c h));box-sizing:border-box;flex:0 0 var(--checkbox-box-size);inline-size:var(--checkbox-box-size);block-size:var(--checkbox-box-size);margin:0;appearance:none;-webkit-appearance:none;border:1.5px solid var(--checkbox-border);border-radius:var(--checkbox-round);background-color:var(--checkbox-bg);background-repeat:no-repeat;background-position:center;background-size:var(--checkbox-mask-size);cursor:pointer;vertical-align:middle;transition:background-color .15s ease-out,border-color .15s ease-out}label:has(>input[data-anta][type=checkbox][size=small]){gap:6px;font-size:13px;line-height:16px}label:has(>input[data-anta][type=checkbox][size=large]){font-size:17px;line-height:22px}input[data-anta][type=checkbox][size=small]{--checkbox-box-size: 14px;--checkbox-mask-size: 10px}input[data-anta][type=checkbox][size=large]{--checkbox-box-size: 18px;--checkbox-mask-size: 14px}input[data-anta][type=checkbox][round]{--checkbox-round: 999px;@supports (border-radius: attr(probe type(<length>),1px)){--checkbox-round: attr(round type(<length>), 999px)}}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .5 c h), oklch(from var(--checkbox-tone-source) .45 c h));--checkbox-bg-selected-hover: light-dark(oklch(from var(--checkbox-tone-source) .45 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .57 c h))}input[data-anta][type=checkbox][tone=brand]{--checkbox-tone-source: var(--anta-seed-brand);--checkbox-off-tone-source: var(--anta-seed-brand)}input[data-anta][type=checkbox][tone=info]{--checkbox-tone-source: var(--anta-seed-info);--checkbox-off-tone-source: var(--anta-seed-info)}input[data-anta][type=checkbox][tone=success]{--checkbox-tone-source: var(--anta-seed-success);--checkbox-off-tone-source: var(--anta-seed-success)}input[data-anta][type=checkbox][tone=warning]{--checkbox-tone-source: var(--anta-seed-warning);--checkbox-off-tone-source: var(--anta-seed-warning)}input[data-anta][type=checkbox][tone=critical]{--checkbox-tone-source: var(--anta-seed-critical);--checkbox-off-tone-source: var(--anta-seed-critical)}input[data-anta][type=checkbox][tone=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral],[tone-scope=selected]){--checkbox-bg: light-dark(oklch(from var(--checkbox-off-tone-source) .99 calc(c*.03) h), oklch(from var(--checkbox-off-tone-source) .15 calc(c*.18) h));--_checkbox-off-bg-selected: var(--checkbox-bg-selected);--_checkbox-border-base: color-mix(in oklch, var(--_checkbox-off-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: light-dark(oklch(from var(--_checkbox-border-base) calc(l + .17) c h), var(--_checkbox-border-base));--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: light-dark(var(--_checkbox-border-base), oklch(from var(--_checkbox-border-base) calc(l + .17) c h))}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);@supports (color: attr(probe type(<color>),red)){--checkbox-tone-source: attr(tone type(<color>), var(--anta-seed-neutral));--checkbox-off-tone-source: attr(tone type(<color>), var(--anta-seed-neutral))}}@media(hover:hover)and (pointer:fine){input[data-anta][type=checkbox]:not(:disabled):hover{border-color:var(--checkbox-border-hover)}input[data-anta][type=checkbox]:not(:disabled):hover:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}input[data-anta][type=checkbox]:not(:disabled):active{border-color:var(--checkbox-border-active)}input[data-anta][type=checkbox]:not(:disabled):active:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}input[data-anta][type=checkbox]:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}input[data-anta][type=checkbox]:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}input[data-anta][type=checkbox]:disabled{border-color:color-mix(in oklch,var(--text-1) 10%,transparent);background-color:color-mix(in oklch,var(--text-1) 10%,transparent);cursor:not-allowed}input[data-anta][type=checkbox]:disabled:is(:checked,:indeterminate){background-color:color-mix(in oklch,var(--text-1) 10%,transparent)}@media(forced-colors:active){a-checkbox:is(:state(checked),:state(indeterminate)):before{forced-color-adjust:none;background-color:Highlight;border-color:Highlight}a-checkbox:is(:state(checked),:state(indeterminate)):after{forced-color-adjust:none;background-color:HighlightText}a-checkbox:disabled:before{background-color:Canvas;border-color:GrayText}a-checkbox:disabled:is(:state(checked),:state(indeterminate)):after{background-color:GrayText}}}
|
|
1
|
+
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-checkbox{--checkbox-gap: 8px;--checkbox-box-size: 16px;--checkbox-bg: var(--bg-1);--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .6 c h), oklch(from var(--checkbox-tone-source) .42 c h));--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) .45 c h);--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-icon: light-dark(#f6f4f6, #ece9ec);--checkbox-icon-disabled: light-dark(#c1b9c1, #534c57);--checkbox-bg-disabled: light-dark(color-mix(in oklch, #44374b 10%, transparent), color-mix(in oklch, #e4d1ef 10%, transparent));--checkbox-border-disabled: var(--checkbox-bg-disabled);--checkbox-mask-size: 13px;--checkbox-mask-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");--checkbox-mask-indeterminate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");--checkbox-label-color: var(--text-2);--checkbox-label-color-disabled: var(--text-4);--checkbox-hint-color: var(--text-3);--checkbox-label-fs: 15px;--checkbox-label-lh: 20px;--checkbox-hint-fs: 13px;--checkbox-hint-lh: 16px;display:inline-grid;grid-template-columns:auto 1fr;align-items:start;column-gap:var(--checkbox-gap);vertical-align:middle;cursor:pointer;user-select:none;-webkit-user-drag:none;outline:none;color:var(--checkbox-label-color);font-family:var(--sans-serif);font-size:var(--checkbox-label-fs);line-height:var(--checkbox-label-lh);&:before{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);box-sizing:border-box;inline-size:16px;block-size:16px;border-radius:4px;background:var(--checkbox-bg);border:1.5px solid var(--checkbox-border);transition:background-color .15s ease-out,border-color .15s ease-out}&[round]{--checkbox-round: 999px;@supports (border-radius: attr(probe type(<length>),1px)){--checkbox-round: attr(round type(<length>), 999px)}}&[round]:before{border-radius:var(--checkbox-round, 999px)}&:after{content:"";grid-column:1;grid-row:1 / -1;align-self:start;margin-block-start:calc((var(--checkbox-label-lh) - var(--checkbox-box-size)) / 2);inline-size:16px;block-size:16px;background-color:transparent;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center;-webkit-mask-size:var(--checkbox-mask-size);mask-size:var(--checkbox-mask-size)}@media(hover:hover)and (pointer:fine){&:not(:disabled):hover:before{border-color:var(--checkbox-border-hover);transition:background-color 75ms ease-in,border-color 75ms ease-in}&:not(:disabled):hover:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}&:not(:disabled):active:before{border-color:var(--checkbox-border-active);transition:background-color 50ms linear,border-color 50ms linear}&:not(:disabled):active:is(:state(checked),:state(indeterminate)):before{background:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}&:is(:state(checked),:state(indeterminate)){&:before{background:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}&:after{background-color:var(--checkbox-icon)}}&:state(checked):after{-webkit-mask-image:var(--checkbox-mask-check);mask-image:var(--checkbox-mask-check)}&:state(indeterminate):after{-webkit-mask-image:var(--checkbox-mask-indeterminate);mask-image:var(--checkbox-mask-indeterminate)}&:focus-visible{outline:none}&:focus-visible:before{outline:1px solid var(--focus-ring);outline-offset:1px}&:disabled{cursor:not-allowed;color:var(--checkbox-label-color-disabled);&:before{background:var(--checkbox-bg-disabled);border-color:var(--checkbox-border-disabled);transition:none}&:is(:state(checked),:state(indeterminate)):after{background-color:var(--checkbox-icon-disabled)}a-checkbox-hint{color:var(--checkbox-label-color-disabled)}}&[size=small]{--checkbox-gap: 6px;--checkbox-box-size: 14px;--checkbox-label-fs: 13px;--checkbox-label-lh: 16px;--checkbox-hint-fs: 12px;--checkbox-hint-lh: 14px;--checkbox-mask-size: 11px;&:before,&:after{inline-size:14px;block-size:14px}}&[size=large]{--checkbox-box-size: 18px;--checkbox-label-fs: 17px;--checkbox-label-lh: 22px;--checkbox-hint-fs: 15px;--checkbox-hint-lh: 19px;--checkbox-mask-size: 15px;&:before,&:after{inline-size:18px;block-size:18px}}}a-checkbox-label,a-checkbox-hint{display:block;grid-column:2;min-width:0}a-checkbox-hint{color:var(--checkbox-hint-color);font-size:var(--checkbox-hint-fs);line-height:var(--checkbox-hint-lh);margin-block-start:2px}a-checkbox[tone]:not([tone=""],[tone=neutral]){--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .5 c h), oklch(from var(--checkbox-tone-source) .45 c h));--checkbox-bg-selected-hover: light-dark(oklch(from var(--checkbox-tone-source) .45 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .57 c h))}a-checkbox[tone=brand]{--checkbox-tone-source: var(--anta-seed-brand);--checkbox-off-tone-source: var(--anta-seed-brand)}a-checkbox[tone=info]{--checkbox-tone-source: var(--anta-seed-info);--checkbox-off-tone-source: var(--anta-seed-info)}a-checkbox[tone=success]{--checkbox-tone-source: var(--anta-seed-success);--checkbox-off-tone-source: var(--anta-seed-success)}a-checkbox[tone=warning]{--checkbox-tone-source: var(--anta-seed-warning);--checkbox-off-tone-source: var(--anta-seed-warning)}a-checkbox[tone=critical]{--checkbox-tone-source: var(--anta-seed-critical);--checkbox-off-tone-source: var(--anta-seed-critical)}a-checkbox[tone=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral)}a-checkbox[tone]:not([tone=""],[tone=neutral],[tone-scope=selected]){--checkbox-bg: light-dark(oklch(from var(--checkbox-off-tone-source) .99 calc(c*.03) h), oklch(from var(--checkbox-off-tone-source) .15 calc(c*.18) h));--_checkbox-off-bg-selected: var(--checkbox-bg-selected);--_checkbox-border-base: color-mix(in oklch, var(--_checkbox-off-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: light-dark(oklch(from var(--_checkbox-border-base) calc(l + .17) c h), var(--_checkbox-border-base));--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: light-dark(var(--_checkbox-border-base), oklch(from var(--_checkbox-border-base) calc(l + .17) c h))}a-checkbox[tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: transparent;--checkbox-off-tone-source: transparent;@supports (color: attr(probe type(<color>),red)){--checkbox-tone-source: attr(tone type(<color>), transparent);--checkbox-off-tone-source: attr(tone type(<color>), transparent)}}label:has(>input[data-anta][type=checkbox]){display:inline-flex;align-items:center;gap:8px;color:var(--text-2);font-family:var(--sans-serif);font-size:15px;line-height:20px}input[data-anta][type=checkbox]{--checkbox-box-size: 16px;--checkbox-mask-size: 13px;--checkbox-round: 4px;--checkbox-bg: var(--bg-1);--checkbox-border-neutral: var(--border-3);--checkbox-border: var(--checkbox-border-neutral);--checkbox-border-hover: var(--border-2);--checkbox-border-active: var(--border-1);--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .6 c h), oklch(from var(--checkbox-tone-source) .42 c h));--checkbox-bg-selected-hover: oklch(from var(--checkbox-tone-source) .45 c h);--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .5 c h));box-sizing:border-box;flex:0 0 var(--checkbox-box-size);inline-size:var(--checkbox-box-size);block-size:var(--checkbox-box-size);margin:0;appearance:none;-webkit-appearance:none;border:1.5px solid var(--checkbox-border);border-radius:var(--checkbox-round);background-color:var(--checkbox-bg);background-repeat:no-repeat;background-position:center;background-size:var(--checkbox-mask-size);cursor:pointer;vertical-align:middle;transition:background-color .15s ease-out,border-color .15s ease-out}label:has(>input[data-anta][type=checkbox][size=small]){gap:6px;font-size:13px;line-height:16px}label:has(>input[data-anta][type=checkbox][size=large]){font-size:17px;line-height:22px}input[data-anta][type=checkbox][size=small]{--checkbox-box-size: 14px;--checkbox-mask-size: 11px}input[data-anta][type=checkbox][size=large]{--checkbox-box-size: 18px;--checkbox-mask-size: 15px}input[data-anta][type=checkbox][round]{--checkbox-round: 999px;@supports (border-radius: attr(probe type(<length>),1px)){--checkbox-round: attr(round type(<length>), 999px)}}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral]){--checkbox-bg-selected: light-dark(oklch(from var(--checkbox-tone-source) .5 c h), oklch(from var(--checkbox-tone-source) .45 c h));--checkbox-bg-selected-hover: light-dark(oklch(from var(--checkbox-tone-source) .45 c h), oklch(from var(--checkbox-tone-source) .5 c h));--checkbox-bg-selected-active: light-dark(oklch(from var(--checkbox-tone-source) .4 c h), oklch(from var(--checkbox-tone-source) .57 c h))}input[data-anta][type=checkbox][tone=brand]{--checkbox-tone-source: var(--anta-seed-brand);--checkbox-off-tone-source: var(--anta-seed-brand)}input[data-anta][type=checkbox][tone=info]{--checkbox-tone-source: var(--anta-seed-info);--checkbox-off-tone-source: var(--anta-seed-info)}input[data-anta][type=checkbox][tone=success]{--checkbox-tone-source: var(--anta-seed-success);--checkbox-off-tone-source: var(--anta-seed-success)}input[data-anta][type=checkbox][tone=warning]{--checkbox-tone-source: var(--anta-seed-warning);--checkbox-off-tone-source: var(--anta-seed-warning)}input[data-anta][type=checkbox][tone=critical]{--checkbox-tone-source: var(--anta-seed-critical);--checkbox-off-tone-source: var(--anta-seed-critical)}input[data-anta][type=checkbox][tone=neutral]{--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral)}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=neutral],[tone-scope=selected]){--checkbox-bg: light-dark(oklch(from var(--checkbox-off-tone-source) .99 calc(c*.03) h), oklch(from var(--checkbox-off-tone-source) .15 calc(c*.18) h));--_checkbox-off-bg-selected: var(--checkbox-bg-selected);--_checkbox-border-base: color-mix(in oklch, var(--_checkbox-off-bg-selected) 70%, var(--checkbox-border-neutral));--checkbox-border: light-dark(oklch(from var(--_checkbox-border-base) calc(l + .17) c h), var(--_checkbox-border-base));--checkbox-border-hover: oklch(from var(--_checkbox-border-base) calc(l + .1) c h);--checkbox-border-active: light-dark(var(--_checkbox-border-base), oklch(from var(--_checkbox-border-base) calc(l + .17) c h))}input[data-anta][type=checkbox][tone]:not([tone=""],[tone=brand],[tone=neutral],[tone=info],[tone=success],[tone=warning],[tone=critical]){--checkbox-tone-source: var(--anta-seed-neutral);--checkbox-off-tone-source: var(--anta-seed-neutral);@supports (color: attr(probe type(<color>),red)){--checkbox-tone-source: attr(tone type(<color>), var(--anta-seed-neutral));--checkbox-off-tone-source: attr(tone type(<color>), var(--anta-seed-neutral))}}@media(hover:hover)and (pointer:fine){input[data-anta][type=checkbox]:not(:disabled):hover{border-color:var(--checkbox-border-hover)}input[data-anta][type=checkbox]:not(:disabled):hover:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected-hover);border-color:var(--checkbox-bg-selected-hover)}}input[data-anta][type=checkbox]:not(:disabled):active{border-color:var(--checkbox-border-active)}input[data-anta][type=checkbox]:not(:disabled):active:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected-active);border-color:var(--checkbox-bg-selected-active)}input[data-anta][type=checkbox]:is(:checked,:indeterminate){background-color:var(--checkbox-bg-selected);border-color:var(--checkbox-bg-selected)}input[data-anta][type=checkbox]:checked{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:indeterminate{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f6f4f6' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E")}input[data-anta][type=checkbox]:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}input[data-anta][type=checkbox]:disabled{border-color:color-mix(in oklch,var(--text-1) 10%,transparent);background-color:color-mix(in oklch,var(--text-1) 10%,transparent);cursor:not-allowed}input[data-anta][type=checkbox]:disabled:is(:checked,:indeterminate){background-color:color-mix(in oklch,var(--text-1) 10%,transparent)}@media(forced-colors:active){a-checkbox:is(:state(checked),:state(indeterminate)):before{forced-color-adjust:none;background-color:Highlight;border-color:Highlight}a-checkbox:is(:state(checked),:state(indeterminate)):after{forced-color-adjust:none;background-color:HighlightText}a-checkbox:disabled:before{background-color:Canvas;border-color:GrayText}a-checkbox:disabled:is(:state(checked),:state(indeterminate)):after{background-color:GrayText}}}
|
package/dist/elements/a-copy.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-copy,a-copy:not(:defined){display:contents}}
|
|
1
|
+
@layer base,anta,components,utilities;@layer anta.reset,anta.components,anta.theme;@layer anta.components{a-copy,a-copy:not(:defined){display:contents}a-copy::part(feedback){--_copy-opacity-from: 1;--_copy-opacity-to: 0;--_copy-easing: ease-out;--_copy-above-from: translateY( calc(-100% - 10px) );--_copy-above-to: translateY( calc(-100% - 1.5em) );--_copy-below-from: translateY(10px);--_copy-below-to: translateY(1.5em);position:fixed;margin:0;padding:0;border:0;right:auto;bottom:auto;background:none;overflow:visible;pointer-events:none;align-items:center;gap:4px;box-sizing:border-box;color:var(--text-2-success);font-family:var(--sans-serif);font-size:13px;line-height:16px;font-weight:500;white-space:nowrap}a-copy::part(feedback):popover-open{display:inline-flex}}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { HTMLElementBase } from "../anta_helpers";
|
|
2
2
|
import "./a-copy.css";
|
|
3
|
-
declare global {
|
|
4
|
-
interface Document {
|
|
5
|
-
hasCopyDelegation?: boolean;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
3
|
export declare class ACopyElement extends HTMLElementBase {
|
|
9
4
|
#private;
|
|
10
5
|
connectedCallback(): void;
|
|
11
6
|
/** Run the copy for the activated host. Called from the delegated click /
|
|
12
7
|
* menuselect handlers; the confirmation follows a successful `copydone`. */
|
|
13
8
|
activate(): void;
|
|
9
|
+
adoptedCallback(): void;
|
|
14
10
|
disconnectedCallback(): void;
|
|
15
11
|
}
|
|
16
12
|
export declare function register_a_copy(): void;
|
package/dist/elements/a-copy.js
CHANGED
|
@@ -4,104 +4,65 @@ import "./a-copy.css";
|
|
|
4
4
|
const BUTTON_HOST = "a-button, button, [role=button]";
|
|
5
5
|
const MENU_HOST = "a-menu-item, [role=menuitem]";
|
|
6
6
|
const ANY_HOST = `${BUTTON_HOST}, ${MENU_HOST}`;
|
|
7
|
-
const
|
|
7
|
+
const COPY_DELEGATION = /* @__PURE__ */ Symbol.for("anta.copy-delegation");
|
|
8
8
|
function copyChild(host) {
|
|
9
9
|
return host?.querySelector(":scope > a-copy") ?? null;
|
|
10
10
|
}
|
|
11
11
|
function hostBlocked(host) {
|
|
12
12
|
return host.hasAttribute("disabled") || host.hasAttribute("loading") || host.getAttribute("aria-disabled") === "true";
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
|
|
14
|
+
function copyDelegation(doc) {
|
|
15
|
+
if (doc[COPY_DELEGATION]) return doc[COPY_DELEGATION];
|
|
16
|
+
const origins = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
const hostFor = (event) => event.target?.closest?.(ANY_HOST);
|
|
18
|
+
const preRequest = (event, origin) => {
|
|
19
|
+
const host = hostFor(event);
|
|
18
20
|
if (!host || hostBlocked(host)) return;
|
|
19
21
|
const el = copyChild(host);
|
|
20
22
|
if (!el) return;
|
|
21
|
-
if (origin)
|
|
22
|
-
else
|
|
23
|
+
if (origin) origins.set(el, origin);
|
|
24
|
+
else origins.delete(el);
|
|
23
25
|
emitCopyRequest(el);
|
|
24
26
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
doc.hasCopyDelegation = true;
|
|
27
|
+
const pointerdown = (e) => preRequest(e, { x: e.clientX, y: e.clientY });
|
|
28
|
+
const keydown = (e) => {
|
|
29
|
+
if (e.key === "Enter" || e.key === " ") preRequest(e);
|
|
30
|
+
};
|
|
31
|
+
const click = (e) => {
|
|
32
|
+
const host = hostFor(e);
|
|
33
|
+
if (!host?.matches(BUTTON_HOST) || hostBlocked(host)) return;
|
|
34
|
+
const el = copyChild(host);
|
|
35
|
+
if (!el) return;
|
|
36
|
+
if (e.detail) origins.set(el, { x: e.clientX, y: e.clientY });
|
|
37
|
+
else origins.delete(el);
|
|
38
|
+
el.activate();
|
|
39
|
+
};
|
|
40
|
+
const menuselect = (e) => {
|
|
41
|
+
const host = hostFor(e);
|
|
42
|
+
if (!host?.matches(MENU_HOST) || hostBlocked(host)) return;
|
|
43
|
+
copyChild(host)?.activate();
|
|
44
|
+
};
|
|
45
|
+
doc.addEventListener("pointerdown", pointerdown, true);
|
|
46
|
+
doc.addEventListener("keydown", keydown, true);
|
|
47
|
+
doc.addEventListener("click", click, true);
|
|
48
|
+
doc.addEventListener("menuselect", menuselect, true);
|
|
49
|
+
const delegation = {
|
|
50
|
+
readers: /* @__PURE__ */ new Set(),
|
|
51
|
+
origins,
|
|
52
|
+
dispose: () => {
|
|
53
|
+
doc.removeEventListener("pointerdown", pointerdown, true);
|
|
54
|
+
doc.removeEventListener("keydown", keydown, true);
|
|
55
|
+
doc.removeEventListener("click", click, true);
|
|
56
|
+
doc.removeEventListener("menuselect", menuselect, true);
|
|
57
|
+
delete doc[COPY_DELEGATION];
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
doc[COPY_DELEGATION] = delegation;
|
|
61
|
+
return delegation;
|
|
62
62
|
}
|
|
63
63
|
const FEEDBACK_MS = 900;
|
|
64
64
|
const COPY_FEEDBACK_TEMPLATE = typeof document === "undefined" ? void 0 : (() => {
|
|
65
65
|
const template = document.createElement("template");
|
|
66
|
-
const style = document.createElement("style");
|
|
67
|
-
style.textContent = `
|
|
68
|
-
.feedback {
|
|
69
|
-
position: fixed;
|
|
70
|
-
margin: 0;
|
|
71
|
-
padding: 0;
|
|
72
|
-
border: 0;
|
|
73
|
-
inset: auto;
|
|
74
|
-
background: none;
|
|
75
|
-
overflow: visible;
|
|
76
|
-
pointer-events: none;
|
|
77
|
-
display: inline-flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
gap: 4px;
|
|
80
|
-
box-sizing: border-box;
|
|
81
|
-
color: var(--text-2-success);
|
|
82
|
-
font-family: var(--sans-serif);
|
|
83
|
-
font-size: 13px;
|
|
84
|
-
line-height: 16px;
|
|
85
|
-
font-weight: 500;
|
|
86
|
-
white-space: nowrap;
|
|
87
|
-
--_feedback-y-from: calc(-100% - 10px);
|
|
88
|
-
--_feedback-y-to: calc(-100% - 1.5em);
|
|
89
|
-
transform: translate(var(--_feedback-x), var(--_feedback-y-from));
|
|
90
|
-
}
|
|
91
|
-
.feedback[data-placement="below"] {
|
|
92
|
-
--_feedback-y-from: 10px;
|
|
93
|
-
--_feedback-y-to: 1.5em;
|
|
94
|
-
}
|
|
95
|
-
.feedback[data-measure-end] {
|
|
96
|
-
transform: translate(var(--_feedback-x), var(--_feedback-y-to));
|
|
97
|
-
}
|
|
98
|
-
.feedback:not(:popover-open) { display: none; }
|
|
99
|
-
.feedback[data-show] { animation: a-copy-feedback-rise ${FEEDBACK_MS}ms ease-out forwards; }
|
|
100
|
-
@keyframes a-copy-feedback-rise {
|
|
101
|
-
from { opacity: 1; transform: translate(var(--_feedback-x), var(--_feedback-y-from)); }
|
|
102
|
-
to { opacity: 0; transform: translate(var(--_feedback-x), var(--_feedback-y-to)); }
|
|
103
|
-
}
|
|
104
|
-
`;
|
|
105
66
|
const feedback = document.createElement("div");
|
|
106
67
|
feedback.className = "feedback";
|
|
107
68
|
feedback.part.add("feedback");
|
|
@@ -113,25 +74,50 @@ const COPY_FEEDBACK_TEMPLATE = typeof document === "undefined" ? void 0 : (() =>
|
|
|
113
74
|
const label = document.createElement("span");
|
|
114
75
|
label.className = "label";
|
|
115
76
|
feedback.append(icon, label);
|
|
116
|
-
template.content.append(
|
|
77
|
+
template.content.append(feedback);
|
|
117
78
|
return template;
|
|
118
79
|
})();
|
|
119
80
|
class ACopyElement extends HTMLElementBase {
|
|
120
81
|
#feedback;
|
|
121
82
|
#feedbackLabel;
|
|
122
83
|
#feedbackTimer;
|
|
84
|
+
#timerView;
|
|
85
|
+
#delegation;
|
|
86
|
+
#connectedDocument;
|
|
87
|
+
#generation = 0;
|
|
88
|
+
#completion;
|
|
89
|
+
#animation;
|
|
90
|
+
#motion;
|
|
91
|
+
#reconnectOrigin;
|
|
123
92
|
connectedCallback() {
|
|
124
|
-
|
|
93
|
+
this.#delegation = copyDelegation(this.doc);
|
|
94
|
+
this.#connectedDocument = this.doc;
|
|
95
|
+
this.#delegation.readers.add(this);
|
|
96
|
+
if (this.#reconnectOrigin?.doc === this.doc && this.#reconnectOrigin.origin) {
|
|
97
|
+
this.#delegation.origins.set(this, this.#reconnectOrigin.origin);
|
|
98
|
+
}
|
|
99
|
+
this.#reconnectOrigin = void 0;
|
|
125
100
|
this.addEventListener("copydone", this.#onCopyDone);
|
|
126
101
|
}
|
|
127
102
|
/** Run the copy for the activated host. Called from the delegated click /
|
|
128
103
|
* menuselect handlers; the confirmation follows a successful `copydone`. */
|
|
129
104
|
activate() {
|
|
130
|
-
|
|
105
|
+
const generation = this.#generation;
|
|
106
|
+
const origin = this.#delegation?.origins.get(this);
|
|
107
|
+
this.#delegation?.origins.delete(this);
|
|
108
|
+
runCopy(this, (ok) => {
|
|
109
|
+
this.#completion = { current: this.isConnected && generation === this.#generation, origin };
|
|
110
|
+
try {
|
|
111
|
+
this.dispatchEvent(new this.view.CustomEvent("copydone", { detail: { ok } }));
|
|
112
|
+
} finally {
|
|
113
|
+
this.#completion = void 0;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
131
116
|
}
|
|
132
117
|
#onCopyDone = (e) => {
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
if (e.target !== this || this.#completion?.current === false || !this.isConnected) return;
|
|
119
|
+
const origin = this.#completion ? this.#completion.origin : this.#delegation?.origins.get(this);
|
|
120
|
+
if (!this.#completion) this.#delegation?.origins.delete(this);
|
|
135
121
|
if (!this.hasAttribute("toast")) return;
|
|
136
122
|
if (!e.detail?.ok) return;
|
|
137
123
|
const host = this.closest(ANY_HOST);
|
|
@@ -154,38 +140,73 @@ class ACopyElement extends HTMLElementBase {
|
|
|
154
140
|
if (origin) {
|
|
155
141
|
feedback.style.left = `${origin.x}px`;
|
|
156
142
|
feedback.style.top = `${origin.y}px`;
|
|
157
|
-
feedback.style.
|
|
143
|
+
feedback.style.translate = "8px 0";
|
|
158
144
|
belowTop = origin.y;
|
|
159
145
|
} else {
|
|
160
146
|
const rect = host.getBoundingClientRect();
|
|
161
147
|
const rtl = this.view.getComputedStyle(host).direction === "rtl";
|
|
162
148
|
feedback.style.left = `${rtl ? rect.right - 12 : rect.left + 12}px`;
|
|
163
149
|
feedback.style.top = `${rect.top}px`;
|
|
164
|
-
feedback.style.
|
|
150
|
+
feedback.style.translate = rtl ? "-100% 0" : "0 0";
|
|
165
151
|
belowTop = rect.bottom;
|
|
166
152
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
if (!this.#motion) {
|
|
154
|
+
const styles = this.view.getComputedStyle(feedback);
|
|
155
|
+
const motion = {
|
|
156
|
+
opacity: [styles.getPropertyValue("--_copy-opacity-from").trim(), styles.getPropertyValue("--_copy-opacity-to").trim()],
|
|
157
|
+
easing: styles.getPropertyValue("--_copy-easing").trim(),
|
|
158
|
+
above: [styles.getPropertyValue("--_copy-above-from").trim(), styles.getPropertyValue("--_copy-above-to").trim()],
|
|
159
|
+
below: [styles.getPropertyValue("--_copy-below-from").trim(), styles.getPropertyValue("--_copy-below-to").trim()]
|
|
160
|
+
};
|
|
161
|
+
if (![...motion.opacity, ...motion.above, ...motion.below, motion.easing].every(Boolean)) return;
|
|
162
|
+
this.#motion = motion;
|
|
163
|
+
}
|
|
164
|
+
this.#clearFeedback();
|
|
171
165
|
feedback.showPopover();
|
|
172
|
-
feedback.
|
|
173
|
-
const
|
|
174
|
-
feedback.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
166
|
+
feedback.style.transform = this.#motion.above[1];
|
|
167
|
+
const below = feedback.getBoundingClientRect().top < 0;
|
|
168
|
+
if (below) feedback.style.top = `${belowTop}px`;
|
|
169
|
+
const transforms = below ? this.#motion.below : this.#motion.above;
|
|
170
|
+
feedback.style.transform = transforms[0];
|
|
171
|
+
if (!this.#animation) {
|
|
172
|
+
this.#animation = feedback.animate({ opacity: this.#motion.opacity, transform: transforms }, {
|
|
173
|
+
duration: FEEDBACK_MS,
|
|
174
|
+
easing: this.#motion.easing,
|
|
175
|
+
fill: "forwards"
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
this.#animation.effect.setKeyframes({ opacity: this.#motion.opacity, transform: transforms });
|
|
179
|
+
this.#animation.play();
|
|
178
180
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.#feedbackTimer = setTimeout(() =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
this.#animation.currentTime = 0;
|
|
182
|
+
this.#timerView = this.view;
|
|
183
|
+
this.#feedbackTimer = this.#timerView.setTimeout(() => this.#clearFeedback(), FEEDBACK_MS);
|
|
184
|
+
}
|
|
185
|
+
#clearFeedback() {
|
|
186
|
+
if (this.#feedbackTimer != null) this.#timerView?.clearTimeout(this.#feedbackTimer);
|
|
187
|
+
this.#feedbackTimer = void 0;
|
|
188
|
+
this.#timerView = void 0;
|
|
189
|
+
this.#animation?.cancel();
|
|
190
|
+
if (this.#feedback?.matches(":popover-open")) this.#feedback.hidePopover();
|
|
191
|
+
}
|
|
192
|
+
adoptedCallback() {
|
|
193
|
+
this.#animation?.cancel();
|
|
194
|
+
this.#animation = void 0;
|
|
195
|
+
this.#motion = void 0;
|
|
196
|
+
this.#reconnectOrigin = void 0;
|
|
197
|
+
this.#connectedDocument = void 0;
|
|
185
198
|
}
|
|
186
199
|
disconnectedCallback() {
|
|
187
|
-
|
|
188
|
-
|
|
200
|
+
this.#generation++;
|
|
201
|
+
this.#clearFeedback();
|
|
202
|
+
const pending = this.#reconnectOrigin = { doc: this.#connectedDocument, origin: this.#delegation?.origins.get(this) };
|
|
203
|
+
queueMicrotask(() => {
|
|
204
|
+
if (this.#reconnectOrigin === pending) this.#reconnectOrigin = void 0;
|
|
205
|
+
});
|
|
206
|
+
this.#delegation?.origins.delete(this);
|
|
207
|
+
this.#delegation?.readers.delete(this);
|
|
208
|
+
if (this.#delegation?.readers.size === 0) this.#delegation.dispose();
|
|
209
|
+
this.#delegation = void 0;
|
|
189
210
|
this.removeEventListener("copydone", this.#onCopyDone);
|
|
190
211
|
}
|
|
191
212
|
}
|