@antadesign/anta 0.3.19 → 0.3.21
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/README.md +1 -1
- package/dist/anta_helpers.d.ts +11 -2
- package/dist/anta_helpers.js +9 -0
- package/dist/components/Banner.d.ts +3 -3
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Calendar.d.ts +11 -12
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.d.ts +8 -9
- package/dist/components/Dialog.d.ts +1 -1
- package/dist/components/Expander.d.ts +5 -6
- package/dist/components/Input.d.ts +2 -2
- package/dist/components/Input.js +1 -1
- package/dist/components/InputAutocomplete.d.ts +8 -8
- package/dist/components/InputAutocomplete.js +24 -18
- package/dist/components/InputTime.d.ts +3 -3
- package/dist/components/InputTime.js +1 -1
- package/dist/components/Menu.d.ts +2 -2
- package/dist/components/MenuItem.d.ts +1 -1
- package/dist/components/MenuItem.js +1 -1
- package/dist/components/Progress.d.ts +1 -1
- package/dist/components/RadioGroup.d.ts +14 -15
- package/dist/components/RadioGroup.js +5 -2
- package/dist/components/Select.d.ts +33 -40
- package/dist/components/Select.js +6 -2
- package/dist/components/SelectFaceted.d.ts +27 -33
- package/dist/components/SelectFaceted.js +5 -1
- package/dist/components/Slider.d.ts +5 -5
- package/dist/components/Switch.d.ts +4 -4
- package/dist/components/TabPanel.d.ts +1 -2
- package/dist/components/TabPanel.js +0 -1
- package/dist/components/Tabs.d.ts +9 -9
- package/dist/components/Tabs.js +5 -2
- package/dist/components/Text.d.ts +5 -3
- package/dist/components/Text.js +7 -3
- package/dist/components/Title.d.ts +1 -1
- package/dist/components/Toaster.d.ts +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +1 -0
- package/dist/elements/a-expander.js +12 -2
- package/dist/elements/a-menu.d.ts +1 -8
- package/dist/elements/a-menu.js +1 -40
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-text.d.ts +4 -0
- package/dist/elements/a-text.js +10 -3
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +8 -1
- package/dist/elements/a-tooltip.js +88 -15
- package/dist/elements/index.d.ts +1 -1
- package/dist/general_types.d.ts +33 -22
- package/dist/index.d.ts +3 -3
- package/dist/theme-anta.css +1 -1
- package/docs/accessibility.md +4 -4
- package/docs/changelog.md +40 -13
- package/docs/comparison.md +1 -1
- package/docs/components/banner.md +17 -17
- package/docs/components/button.md +6 -6
- package/docs/components/card.md +5 -6
- package/docs/components/checkbox.md +17 -18
- package/docs/components/dialog.md +2 -2
- package/docs/components/expander.md +27 -30
- package/docs/components/icon.md +1 -1
- package/docs/components/input-autocomplete.md +15 -16
- package/docs/components/input-date.md +54 -59
- package/docs/components/input-time.md +7 -7
- package/docs/components/input.md +14 -14
- package/docs/components/menu.md +72 -8
- package/docs/components/progress.md +2 -2
- package/docs/components/radio.md +28 -25
- package/docs/components/select-faceted.md +95 -100
- package/docs/components/select.md +113 -115
- package/docs/components/slider.md +15 -10
- package/docs/components/switch.md +13 -13
- package/docs/components/tabs.md +23 -23
- package/docs/components/tag.md +5 -5
- package/docs/components/text.md +31 -7
- package/docs/components/title.md +1 -1
- package/docs/components/toaster.md +4 -4
- package/docs/components/tooltip.md +2 -2
- package/docs/credits.md +0 -4
- package/docs/index.md +1 -1
- package/docs/install-config.md +12 -7
- package/docs/normalization.md +6 -9
- package/docs/overview.md +1 -1
- package/docs/packages/stickers.md +1 -1
- package/docs/theming.md +15 -0
- package/package.json +3 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta{a-expander,details[data-anta]{--_expander-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3e%3cpath stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m9 18 6-6-6-6'/%3e%3c/svg%3e")}a-expander{--expander-text: var(--text-2);--expander-text-hover: var(--text-1);--expander-bg-secondary: var(--bg-2);--expander-border-secondary: var(--border-5);--expander-bg-primary: var(--bg-4);--expander-border-primary: var(--border-4);--expander-bg: var(--expander-bg-secondary);--expander-border: var(--expander-border-secondary);--expander-bg-hover-lift: .01;--expander-bg-hover: oklch(from var(--expander-bg) calc(l + var(--expander-bg-hover-lift)) c h);--expander-gutter: 24px;display:block;width:100%;box-sizing:border-box;border:1px solid var(--expander-border);border-radius:4px;color:var(--expander-text);background:var(--expander-bg);transition:background-color .1s ease}a-expander[round]{--expander-round: attr(round type(<length>));border-radius:var(--expander-round, var(--_expander-round-radius, 999px))}a-expander>span[slot=actions]{display:contents}a-expander:not(:defined) a-expander-details{display:none}a-expander:not(:defined)[state=open] a-expander-details,a-expander:not(:defined)[default-state=open] a-expander-details{display:block}a-expander:not(:defined) a-expander-summary{position:relative;padding:6px 4px 6px var(--expander-gutter)}a-expander:not(:defined) a-expander-summary:before{content:"";position:absolute;left:calc(var(--expander-gutter) - 16px - 2px);top:50%;width:16px;height:16px;transform:translateY(-50%);background-color:currentColor;-webkit-mask:var(--_expander-chevron) center / contain no-repeat;mask:var(--_expander-chevron) center / contain no-repeat;opacity:.6}a-expander:not(:defined){display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center}a-expander:not(:defined) a-expander-summary{grid-column:1}a-expander:not(:defined)>[slot=actions]{grid-column:2;display:flex;align-items:center;gap:2px;flex-shrink:0;margin-inline-start:8px;margin-inline-end:4px}a-expander:not(:defined) a-expander-details{grid-column:1 / -1}a-expander-summary{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px;line-height:20px;font-weight:584.62;letter-spacing:0;text-decoration-line:var(--_summary-underline, none);text-decoration-style:dotted;text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px;transition:color .15s ease}a-expander[level="1"] a-expander-summary{font-size:28px;line-height:32px}a-expander[level="2"] a-expander-summary{font-size:24px;line-height:28px}a-expander[level="3"] a-expander-summary{font-size:20px;line-height:24px}a-expander[level="4"] a-expander-summary{font-size:17px;line-height:20px}a-expander[level="6"] a-expander-summary{font-size:13px;line-height:16px}a-expander-details{display:block;padding:2px 4px 6px var(--expander-gutter);line-height:20px;overflow:auto}a-expander[priority=tertiary][outdent] a-expander-details{padding-inline-start:4px;margin-inline-start:-4px}a-expander[priority=primary]{--expander-bg: var(--expander-bg-primary);--expander-border: var(--expander-border-primary)}a-expander[priority=tertiary]{--expander-bg: transparent;--expander-border: transparent}a-expander:not([disabled]):not(:state(open)):hover{background:var(--expander-bg-hover)}a-expander:not([disabled]):not(:state(open)):active{background:var(--expander-bg)}a-expander[priority=tertiary][outdent]{--expander-gutter: 0px}a-expander[tone=brand]{--expander-text: var(--text-2-brand);--expander-text-hover: var(--text-1-brand);--expander-bg-secondary: var(--bg-2-brand);--expander-border-secondary: var(--border-5-brand);--expander-bg-primary: var(--bg-4-brand);--expander-border-primary: var(--border-4-brand)}a-expander[tone=info]{--expander-text: var(--text-2-info);--expander-text-hover: var(--text-1-info);--expander-bg-secondary: var(--bg-2-info);--expander-border-secondary: var(--border-5-info);--expander-bg-primary: var(--bg-4-info);--expander-border-primary: var(--border-4-info)}a-expander[tone=success]{--expander-text: var(--text-2-success);--expander-text-hover: var(--text-1-success);--expander-bg-secondary: var(--bg-2-success);--expander-border-secondary: var(--border-5-success);--expander-bg-primary: var(--bg-4-success);--expander-border-primary: var(--border-4-success)}a-expander[tone=warning]{--expander-text: var(--text-2-warning);--expander-text-hover: var(--text-1-warning);--expander-bg-secondary: var(--bg-2-warning);--expander-border-secondary: var(--border-5-warning);--expander-bg-primary: var(--bg-4-warning);--expander-border-primary: var(--border-4-warning)}a-expander[tone=critical]{--expander-text: var(--text-2-critical);--expander-text-hover: var(--text-1-critical);--expander-bg-secondary: var(--bg-2-critical);--expander-border-secondary: var(--border-5-critical);--expander-bg-primary: var(--bg-4-critical);--expander-border-primary: var(--border-4-critical)}a-expander[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--expander-tone-source: attr(tone type(<color>), currentColor);--expander-text: oklch(from var(--expander-tone-source) .5 .125 h);--expander-text-hover: oklch(from var(--expander-tone-source) .4 .11 h);--expander-bg-secondary: oklch(from var(--expander-tone-source) .99 .004 h);--expander-border-secondary: oklch(from var(--expander-tone-source) .935 .028 h);--expander-bg-primary: oklch(from var(--expander-tone-source) .955 .02 h);--expander-border-primary: oklch(from var(--expander-tone-source) .9 .04 h)}.dark a-expander[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--expander-text: oklch(from var(--expander-tone-source) .77 .11 h);--expander-text-hover: oklch(from var(--expander-tone-source) .85 .1 h);--expander-bg-secondary: oklch(from var(--expander-tone-source) .13 .02 h);--expander-border-secondary: oklch(from var(--expander-tone-source) .21 .045 h);--expander-bg-primary: oklch(from var(--expander-tone-source) .185 .05 h);--expander-border-primary: oklch(from var(--expander-tone-source) .26 .06 h)}a-expander[disabled],a-expander[disabled][tone]{--expander-text: #afa9b1}.dark a-expander[disabled],.dark a-expander[disabled][tone]{--expander-text: #635b65}details[data-anta]{--native-expander-gutter: 24px;--native-expander-summary-padding-block: 6px;--native-expander-summary-font-size: 15px;--native-expander-summary-line-height: 20px;--native-expander-chevron-size: 16px;--native-expander-text: var(--text-2);--native-expander-text-hover: var(--text-1);--native-expander-bg-secondary: var(--bg-2);--native-expander-border-secondary: var(--border-5);--native-expander-bg-primary: var(--bg-4);--native-expander-border-primary: var(--border-4);--native-expander-round-size: 16px;--native-expander-round: 4px;--native-expander-bg: transparent;--native-expander-border: transparent;display:block;inline-size:100%;box-sizing:border-box;border:0 solid var(--native-expander-border);border-radius:var(--native-expander-round);color:var(--native-expander-text);background:var(--native-expander-bg);font-family:var(--sans-serif);font-size:15px;font-feature-settings:"ss02","ss05","tnum";line-height:var(--native-expander-summary-line-height);transition:background-color .1s ease}details[data-anta][priority=secondary]{--native-expander-bg: var(--native-expander-bg-secondary);--native-expander-border: var(--native-expander-border-secondary);border-width:1px}details[data-anta][priority=primary]{--native-expander-bg: var(--native-expander-bg-primary);--native-expander-border: var(--native-expander-border-primary);border-width:1px}details[data-anta][level="1"]{--native-expander-summary-font-size: 28px;--native-expander-summary-line-height: 32px;--native-expander-round-size: 22px}details[data-anta][level="2"]{--native-expander-summary-font-size: 24px;--native-expander-summary-line-height: 28px;--native-expander-round-size: 20px}details[data-anta][level="3"]{--native-expander-summary-font-size: 20px;--native-expander-summary-line-height: 24px;--native-expander-round-size: 18px}details[data-anta][level="4"]{--native-expander-summary-font-size: 17px;--native-expander-summary-line-height: 20px}details[data-anta][level="6"]{--native-expander-summary-font-size: 13px;--native-expander-summary-line-height: 16px;--native-expander-round-size: 14px}details[data-anta][round]{--native-expander-round: var(--native-expander-round-size)}details[data-anta][round]:not([round=""]){--native-expander-round: attr(round type(<length>), var(--native-expander-round-size))}details[data-anta][priority=tertiary][outdent]{--native-expander-gutter: 0px}details[data-anta][tone=brand]{--native-expander-text: var(--text-2-brand);--native-expander-text-hover: var(--text-1-brand);--native-expander-bg-secondary: var(--bg-2-brand);--native-expander-border-secondary: var(--border-5-brand);--native-expander-bg-primary: var(--bg-4-brand);--native-expander-border-primary: var(--border-4-brand)}details[data-anta][tone=info]{--native-expander-text: var(--text-2-info);--native-expander-text-hover: var(--text-1-info);--native-expander-bg-secondary: var(--bg-2-info);--native-expander-border-secondary: var(--border-5-info);--native-expander-bg-primary: var(--bg-4-info);--native-expander-border-primary: var(--border-4-info)}details[data-anta][tone=success]{--native-expander-text: var(--text-2-success);--native-expander-text-hover: var(--text-1-success);--native-expander-bg-secondary: var(--bg-2-success);--native-expander-border-secondary: var(--border-5-success);--native-expander-bg-primary: var(--bg-4-success);--native-expander-border-primary: var(--border-4-success)}details[data-anta][tone=warning]{--native-expander-text: var(--text-2-warning);--native-expander-text-hover: var(--text-1-warning);--native-expander-bg-secondary: var(--bg-2-warning);--native-expander-border-secondary: var(--border-5-warning);--native-expander-bg-primary: var(--bg-4-warning);--native-expander-border-primary: var(--border-4-warning)}details[data-anta][tone=critical]{--native-expander-text: var(--text-2-critical);--native-expander-text-hover: var(--text-1-critical);--native-expander-bg-secondary: var(--bg-2-critical);--native-expander-border-secondary: var(--border-5-critical);--native-expander-bg-primary: var(--bg-4-critical);--native-expander-border-primary: var(--border-4-critical)}details[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-expander-tone-source: attr(tone type(<color>), currentColor);--native-expander-text: oklch(from var(--native-expander-tone-source) .5 .125 h);--native-expander-text-hover: oklch(from var(--native-expander-tone-source) .4 .11 h);--native-expander-bg-secondary: oklch(from var(--native-expander-tone-source) .99 .004 h);--native-expander-border-secondary: oklch(from var(--native-expander-tone-source) .935 .028 h);--native-expander-bg-primary: oklch(from var(--native-expander-tone-source) .955 .02 h);--native-expander-border-primary: oklch(from var(--native-expander-tone-source) .9 .04 h)}.dark details[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-expander-text: oklch(from var(--native-expander-tone-source) .77 .11 h);--native-expander-text-hover: oklch(from var(--native-expander-tone-source) .85 .1 h);--native-expander-bg-secondary: oklch(from var(--native-expander-tone-source) .13 .02 h);--native-expander-border-secondary: oklch(from var(--native-expander-tone-source) .21 .045 h);--native-expander-bg-primary: oklch(from var(--native-expander-tone-source) .185 .05 h);--native-expander-border-primary: oklch(from var(--native-expander-tone-source) .26 .06 h)}details[data-anta]>summary{position:relative;box-sizing:border-box;display:block;min-width:0;padding:var(--native-expander-summary-padding-block) 4px var(--native-expander-summary-padding-block) var(--native-expander-gutter);color:inherit;cursor:pointer;font:inherit;font-size:var(--native-expander-summary-font-size);line-height:var(--native-expander-summary-line-height);font-weight:584.62;letter-spacing:0;list-style:none;text-decoration-line:none;transition:color .15s ease}details[data-anta]>summary::-webkit-details-marker{display:none}details[data-anta]>summary::marker{content:""}details[data-anta]>summary:before{content:"";position:absolute;left:calc(var(--native-expander-gutter) - var(--native-expander-chevron-size) - 2px);top:var(--native-expander-summary-padding-block);width:var(--native-expander-chevron-size);height:var(--native-expander-summary-line-height);background-color:currentColor;-webkit-mask:var(--_expander-chevron) center / var(--native-expander-chevron-size) no-repeat;mask:var(--_expander-chevron) center / var(--native-expander-chevron-size) no-repeat;opacity:.6;transform:rotate(0);transition:transform .15s ease,opacity .15s ease,background-color .15s ease}details[data-anta][open]>summary:before{opacity:1;transform:rotate(90deg)}details[data-anta]:is([priority=primary],[priority=secondary]):not([open]):hover{background:oklch(from var(--native-expander-bg) calc(l + .01) c h)}details[data-anta]:is([priority=primary],[priority=secondary]):not([open]):active{background:var(--native-expander-bg)}details[data-anta]>summary:hover{color:var(--native-expander-text-hover);text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px}details[data-anta]>summary:hover:before{opacity:1}details[data-anta]>summary:active{color:var(--native-expander-text)}details[data-anta]>summary:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}details[data-anta]>:not(summary){display:block;padding:2px 4px 6px var(--native-expander-gutter);line-height:20px}@media(forced-colors:active){:is(a-expander,details[data-anta]){border-color:CanvasText}:is(a-expander,details[data-anta]):not([priority=primary],[priority=tertiary]){border-style:dashed}:is(a-expander,details[data-anta])[priority=tertiary]{border-color:Canvas}a-expander::part(summary):before,a-expander:not(:defined) a-expander-summary:before,details[data-anta]>summary:before{forced-color-adjust:none;background-color:CanvasText}a-expander[disabled]::part(summary):before{background-color:GrayText}}}
|
|
1
|
+
@layer anta{a-expander,details[data-anta]{--_expander-chevron: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3e%3cpath stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m9 18 6-6-6-6'/%3e%3c/svg%3e")}a-expander{--expander-text: var(--text-2);--expander-text-hover: var(--text-1);--expander-bg-secondary: var(--bg-2);--expander-border-secondary: var(--border-5);--expander-bg-primary: var(--bg-4);--expander-border-primary: var(--border-4);--expander-bg: var(--expander-bg-secondary);--expander-border: var(--expander-border-secondary);--expander-bg-hover-lift: .01;--expander-bg-hover: oklch(from var(--expander-bg) calc(l + var(--expander-bg-hover-lift)) c h);--expander-gutter: 24px;display:block;width:100%;box-sizing:border-box;border:1px solid var(--expander-border);border-radius:4px;color:var(--expander-text);background:var(--expander-bg);transition:background-color .1s ease}a-expander[round]{--expander-round: attr(round type(<length>));border-radius:var(--expander-round, var(--_expander-round-radius, 999px))}a-expander>span[slot=actions]{display:contents}a-expander:not(:defined) a-expander-details{display:none}a-expander:not(:defined)[state=open] a-expander-details,a-expander:not(:defined)[default-state=open] a-expander-details{display:block}a-expander:not(:defined) a-expander-summary{position:relative;padding:6px 4px 6px var(--expander-gutter)}a-expander:not(:defined) a-expander-summary:before{content:"";position:absolute;left:calc(var(--expander-gutter) - 16px - 2px);top:50%;width:16px;height:16px;transform:translateY(-50%);background-color:currentColor;-webkit-mask:var(--_expander-chevron) center / contain no-repeat;mask:var(--_expander-chevron) center / contain no-repeat;opacity:.6}a-expander:not(:defined){display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center}a-expander:not(:defined) a-expander-summary{grid-column:1}a-expander:not(:defined)>[slot=actions]{grid-column:2;display:flex;align-items:center;gap:2px;flex-shrink:0;margin-inline-start:8px;margin-inline-end:4px}a-expander:not(:defined) a-expander-details{grid-column:1 / -1}a-expander-summary{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px;line-height:20px;font-weight:584.62;letter-spacing:0;text-decoration-line:var(--_summary-underline, none);text-decoration-style:dotted;text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px;transition:color .15s ease}a-expander[level="1"] a-expander-summary{font-size:28px;line-height:32px}a-expander[level="2"] a-expander-summary{font-size:24px;line-height:28px}a-expander[level="3"] a-expander-summary{font-size:20px;line-height:24px}a-expander[level="4"] a-expander-summary{font-size:17px;line-height:20px}a-expander[level="6"] a-expander-summary{font-size:13px;line-height:16px}a-expander-details{display:block;padding:2px 4px 6px var(--expander-gutter);line-height:20px;overflow:auto}a-expander[priority=tertiary][outdent] a-expander-details{padding-inline-start:4px;margin-inline-start:-4px}a-expander[priority=primary]{--expander-bg: var(--expander-bg-primary);--expander-border: var(--expander-border-primary)}a-expander[priority=tertiary]{--expander-bg: transparent;--expander-border: transparent}a-expander:not([disabled]):not(:state(open)):hover{background:var(--expander-bg-hover)}a-expander:not([disabled]):not(:state(open)):active{background:var(--expander-bg)}a-expander[priority=tertiary][outdent]{--expander-gutter: 0px}a-expander[tone=brand]{--expander-text: var(--text-2-brand);--expander-text-hover: var(--text-1-brand);--expander-bg-secondary: var(--bg-2-brand);--expander-border-secondary: var(--border-5-brand);--expander-bg-primary: var(--bg-4-brand);--expander-border-primary: var(--border-4-brand)}a-expander[tone=info]{--expander-text: var(--text-2-info);--expander-text-hover: var(--text-1-info);--expander-bg-secondary: var(--bg-2-info);--expander-border-secondary: var(--border-5-info);--expander-bg-primary: var(--bg-4-info);--expander-border-primary: var(--border-4-info)}a-expander[tone=success]{--expander-text: var(--text-2-success);--expander-text-hover: var(--text-1-success);--expander-bg-secondary: var(--bg-2-success);--expander-border-secondary: var(--border-5-success);--expander-bg-primary: var(--bg-4-success);--expander-border-primary: var(--border-4-success)}a-expander[tone=warning]{--expander-text: var(--text-2-warning);--expander-text-hover: var(--text-1-warning);--expander-bg-secondary: var(--bg-2-warning);--expander-border-secondary: var(--border-5-warning);--expander-bg-primary: var(--bg-4-warning);--expander-border-primary: var(--border-4-warning)}a-expander[tone=critical]{--expander-text: var(--text-2-critical);--expander-text-hover: var(--text-1-critical);--expander-bg-secondary: var(--bg-2-critical);--expander-border-secondary: var(--border-5-critical);--expander-bg-primary: var(--bg-4-critical);--expander-border-primary: var(--border-4-critical)}a-expander[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--expander-tone-source: attr(tone type(<color>), currentColor);--expander-text: oklch(from var(--expander-tone-source) .5 .125 h);--expander-text-hover: oklch(from var(--expander-tone-source) .4 .11 h);--expander-bg-secondary: oklch(from var(--expander-tone-source) .99 .004 h);--expander-border-secondary: oklch(from var(--expander-tone-source) .935 .028 h);--expander-bg-primary: oklch(from var(--expander-tone-source) .955 .02 h);--expander-border-primary: oklch(from var(--expander-tone-source) .9 .04 h)}.dark a-expander[tone]:not([tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--expander-text: oklch(from var(--expander-tone-source) .77 .11 h);--expander-text-hover: oklch(from var(--expander-tone-source) .85 .1 h);--expander-bg-secondary: oklch(from var(--expander-tone-source) .13 .02 h);--expander-border-secondary: oklch(from var(--expander-tone-source) .21 .045 h);--expander-bg-primary: oklch(from var(--expander-tone-source) .185 .05 h);--expander-border-primary: oklch(from var(--expander-tone-source) .26 .06 h)}a-expander[disabled],a-expander[disabled][tone]{--expander-text: #afa9b1}.dark a-expander[disabled],.dark a-expander[disabled][tone]{--expander-text: #635b65}details[data-anta]{--native-expander-gutter: 24px;--native-expander-summary-padding-block: 6px;--native-expander-summary-font-size: 15px;--native-expander-summary-line-height: 20px;--native-expander-chevron-size: 16px;--native-expander-text: var(--text-2);--native-expander-text-hover: var(--text-1);--native-expander-bg-secondary: var(--bg-2);--native-expander-border-secondary: var(--border-5);--native-expander-bg-primary: var(--bg-4);--native-expander-border-primary: var(--border-4);--native-expander-round-size: 16px;--native-expander-round: 4px;--native-expander-bg: transparent;--native-expander-border: transparent;display:block;inline-size:100%;box-sizing:border-box;border:0 solid var(--native-expander-border);border-radius:var(--native-expander-round);color:var(--native-expander-text);background:var(--native-expander-bg);font-family:var(--sans-serif);font-size:15px;font-feature-settings:"ss02","ss05","tnum";line-height:var(--native-expander-summary-line-height);transition:background-color .1s ease}details[data-anta][priority=secondary]{--native-expander-bg: var(--native-expander-bg-secondary);--native-expander-border: var(--native-expander-border-secondary);border-width:1px}details[data-anta][priority=primary]{--native-expander-bg: var(--native-expander-bg-primary);--native-expander-border: var(--native-expander-border-primary);border-width:1px}details[data-anta][level="1"]{--native-expander-summary-font-size: 28px;--native-expander-summary-line-height: 32px;--native-expander-round-size: 22px}details[data-anta][level="2"]{--native-expander-summary-font-size: 24px;--native-expander-summary-line-height: 28px;--native-expander-round-size: 20px}details[data-anta][level="3"]{--native-expander-summary-font-size: 20px;--native-expander-summary-line-height: 24px;--native-expander-round-size: 18px}details[data-anta][level="4"]{--native-expander-summary-font-size: 17px;--native-expander-summary-line-height: 20px}details[data-anta][level="6"]{--native-expander-summary-font-size: 13px;--native-expander-summary-line-height: 16px;--native-expander-round-size: 14px}details[data-anta][round]{--native-expander-round: var(--native-expander-round-size)}details[data-anta][round]:not([round=""]){--native-expander-round: attr(round type(<length>), var(--native-expander-round-size))}details[data-anta][priority=tertiary][outdent]{--native-expander-gutter: 0px}details[data-anta][tone=brand]{--native-expander-text: var(--text-2-brand);--native-expander-text-hover: var(--text-1-brand);--native-expander-bg-secondary: var(--bg-2-brand);--native-expander-border-secondary: var(--border-5-brand);--native-expander-bg-primary: var(--bg-4-brand);--native-expander-border-primary: var(--border-4-brand)}details[data-anta][tone=info]{--native-expander-text: var(--text-2-info);--native-expander-text-hover: var(--text-1-info);--native-expander-bg-secondary: var(--bg-2-info);--native-expander-border-secondary: var(--border-5-info);--native-expander-bg-primary: var(--bg-4-info);--native-expander-border-primary: var(--border-4-info)}details[data-anta][tone=success]{--native-expander-text: var(--text-2-success);--native-expander-text-hover: var(--text-1-success);--native-expander-bg-secondary: var(--bg-2-success);--native-expander-border-secondary: var(--border-5-success);--native-expander-bg-primary: var(--bg-4-success);--native-expander-border-primary: var(--border-4-success)}details[data-anta][tone=warning]{--native-expander-text: var(--text-2-warning);--native-expander-text-hover: var(--text-1-warning);--native-expander-bg-secondary: var(--bg-2-warning);--native-expander-border-secondary: var(--border-5-warning);--native-expander-bg-primary: var(--bg-4-warning);--native-expander-border-primary: var(--border-4-warning)}details[data-anta][tone=critical]{--native-expander-text: var(--text-2-critical);--native-expander-text-hover: var(--text-1-critical);--native-expander-bg-secondary: var(--bg-2-critical);--native-expander-border-secondary: var(--border-5-critical);--native-expander-bg-primary: var(--bg-4-critical);--native-expander-border-primary: var(--border-4-critical)}details[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-expander-tone-source: attr(tone type(<color>), currentColor);--native-expander-text: oklch(from var(--native-expander-tone-source) .5 .125 h);--native-expander-text-hover: oklch(from var(--native-expander-tone-source) .4 .11 h);--native-expander-bg-secondary: oklch(from var(--native-expander-tone-source) .99 .004 h);--native-expander-border-secondary: oklch(from var(--native-expander-tone-source) .935 .028 h);--native-expander-bg-primary: oklch(from var(--native-expander-tone-source) .955 .02 h);--native-expander-border-primary: oklch(from var(--native-expander-tone-source) .9 .04 h)}.dark details[data-anta][tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--native-expander-text: oklch(from var(--native-expander-tone-source) .77 .11 h);--native-expander-text-hover: oklch(from var(--native-expander-tone-source) .85 .1 h);--native-expander-bg-secondary: oklch(from var(--native-expander-tone-source) .13 .02 h);--native-expander-border-secondary: oklch(from var(--native-expander-tone-source) .21 .045 h);--native-expander-bg-primary: oklch(from var(--native-expander-tone-source) .185 .05 h);--native-expander-border-primary: oklch(from var(--native-expander-tone-source) .26 .06 h)}details[data-anta]>summary{position:relative;box-sizing:border-box;display:block;min-width:0;padding:var(--native-expander-summary-padding-block) 4px var(--native-expander-summary-padding-block) var(--native-expander-gutter);color:inherit;cursor:pointer;font:inherit;font-size:var(--native-expander-summary-font-size);line-height:var(--native-expander-summary-line-height);font-weight:584.62;letter-spacing:0;list-style:none;text-decoration-line:none;transition:color .15s ease}details[data-anta]>summary::-webkit-details-marker{display:none}details[data-anta]>summary::marker{content:""}details[data-anta]>summary:before{content:"";position:absolute;left:calc(var(--native-expander-gutter) - var(--native-expander-chevron-size) - 2px);top:var(--native-expander-summary-padding-block);width:var(--native-expander-chevron-size);height:var(--native-expander-summary-line-height);background-color:currentColor;-webkit-mask:var(--_expander-chevron) center / var(--native-expander-chevron-size) no-repeat;mask:var(--_expander-chevron) center / var(--native-expander-chevron-size) no-repeat;opacity:.6;transform:rotate(0);transition:transform .15s ease,opacity .15s ease,background-color .15s ease}details[data-anta][open]>summary:before{opacity:1;transform:rotate(90deg)}details[data-anta]:is([priority=primary],[priority=secondary]):not([open]):hover{background:oklch(from var(--native-expander-bg) calc(l + .01) c h)}details[data-anta]:is([priority=primary],[priority=secondary]):not([open]):active{background:var(--native-expander-bg)}details[data-anta]>summary:hover{color:var(--native-expander-text-hover);text-decoration-line:underline;text-decoration-style:dotted;text-decoration-color:color-mix(in oklch,currentColor 75%,transparent);text-decoration-thickness:1px;text-underline-offset:3px}details[data-anta]>summary:hover:before{opacity:1}details[data-anta]>summary:active{color:var(--native-expander-text)}details[data-anta]>summary:focus-visible{outline:1px solid var(--focus-ring);outline-offset:1px}details[data-anta]>:not(summary){display:block;padding:2px 4px 6px var(--native-expander-gutter);line-height:20px}@media(forced-colors:active){:is(a-expander,details[data-anta]){border-color:CanvasText}:is(a-expander,details[data-anta]):not([priority=primary],[priority=tertiary]){border-style:dashed}:is(a-expander,details[data-anta])[priority=tertiary]{border-color:Canvas}a-expander::part(summary):before,a-expander:not(:defined) a-expander-summary:before,details[data-anta]>summary:before{forced-color-adjust:none;background-color:CanvasText}a-expander[disabled]::part(summary):before{background-color:GrayText}}}a-expander-details>p:last-child,a-expander-details>:not([slot])>p:last-child,details[data-anta]>p:last-child,details[data-anta]>:not(summary)>p:last-child{margin-block-end:0}
|
|
@@ -52,7 +52,7 @@ const SHADOW_STYLE = `
|
|
|
52
52
|
align-items: center;
|
|
53
53
|
gap: 0;
|
|
54
54
|
cursor: pointer;
|
|
55
|
-
user-select:
|
|
55
|
+
user-select: text;
|
|
56
56
|
border-radius: 2px;
|
|
57
57
|
outline: none;
|
|
58
58
|
}
|
|
@@ -132,6 +132,7 @@ const parseState = parseOpenState;
|
|
|
132
132
|
class AExpanderElement extends HTMLElementBase {
|
|
133
133
|
static observedAttributes = ["state", "disabled", "round"];
|
|
134
134
|
summary;
|
|
135
|
+
titleSlot;
|
|
135
136
|
region;
|
|
136
137
|
header;
|
|
137
138
|
// A dedicated shadow <style> the element rewrites to publish the measured
|
|
@@ -161,6 +162,7 @@ class AExpanderElement extends HTMLElementBase {
|
|
|
161
162
|
this.summary.setAttribute("part", "summary");
|
|
162
163
|
const titleSlot = document.createElement("slot");
|
|
163
164
|
titleSlot.name = "title";
|
|
165
|
+
this.titleSlot = titleSlot;
|
|
164
166
|
this.summary.append(titleSlot);
|
|
165
167
|
this.summary.addEventListener("click", this.onSummaryClick);
|
|
166
168
|
const header = document.createElement("div");
|
|
@@ -267,12 +269,20 @@ class AExpanderElement extends HTMLElementBase {
|
|
|
267
269
|
const scope = end === -1 ? path : path.slice(0, end);
|
|
268
270
|
return scope.some((n) => n instanceof Element && ignoresToggle(n));
|
|
269
271
|
}
|
|
272
|
+
/** A selection that reaches projected title content came from a drag. Keep it
|
|
273
|
+
* selected instead of treating its release as an activation. */
|
|
274
|
+
#titleHasSelection() {
|
|
275
|
+
const selection = this.ownerDocument.getSelection();
|
|
276
|
+
if (!selection || selection.isCollapsed || selection.rangeCount === 0) return false;
|
|
277
|
+
const range = selection.getRangeAt(0);
|
|
278
|
+
return this.titleSlot.assignedNodes().some((node) => range.intersectsNode(node));
|
|
279
|
+
}
|
|
270
280
|
/** Compute the requested next state, announce it (cancelable, *before*
|
|
271
281
|
* applying), then — uncontrolled only, and only if not vetoed — apply it.
|
|
272
282
|
* Controlled: never self-apply; the consumer answers via the `state`
|
|
273
283
|
* attribute. See STATEFUL-COMPONENTS.md. */
|
|
274
284
|
onSummaryClick = (e) => {
|
|
275
|
-
if (this.#clickIgnoresToggle(e)) return;
|
|
285
|
+
if (this.#clickIgnoresToggle(e) || e.detail !== 0 && this.#titleHasSelection()) return;
|
|
276
286
|
const prev = this.#current;
|
|
277
287
|
const next = prev === "open" ? "closed" : "open";
|
|
278
288
|
const ok = this.dispatchEvent(
|
|
@@ -98,8 +98,7 @@ export declare class AMenuElement extends HTMLElementBase {
|
|
|
98
98
|
* a multi-select lands on its topmost checked row. */
|
|
99
99
|
private seatInitialFocus;
|
|
100
100
|
/** Scroll THIS menu's body so `item` sits inside the visible scroll viewport,
|
|
101
|
-
* touching only the internal `.scroll` container
|
|
102
|
-
* scroll would trip the anchor-scrolled-out dismiss. No-op for a menu short
|
|
101
|
+
* touching only the internal `.scroll` container. No-op for a menu short
|
|
103
102
|
* enough not to scroll. */
|
|
104
103
|
private scrollItemIntoView;
|
|
105
104
|
/** Fade the scrolling body's content into the top / bottom edges — but only on the
|
|
@@ -169,12 +168,6 @@ export declare class AMenuElement extends HTMLElementBase {
|
|
|
169
168
|
* mutates deep in its subtree, not this menu's direct children, so it won't
|
|
170
169
|
* spuriously reset the cursor. */
|
|
171
170
|
private startComboObserver;
|
|
172
|
-
/** Watch the root trigger and dismiss the system once it scrolls out of the
|
|
173
|
-
* spot it held at open (see trackPosition). Deferred a frame so the trigger's
|
|
174
|
-
* post-open layout has settled before the rect is snapshotted; guarded in case
|
|
175
|
-
* the menu closed in between. Tracks the root anchor only — submenus ride
|
|
176
|
-
* inside it, so if the root anchor goes, the whole system should go. */
|
|
177
|
-
private armPositionTracker;
|
|
178
171
|
/** Apply CLOSE to the DOM (no event). Closes this menu and everything stacked
|
|
179
172
|
* above it (its submenus). */
|
|
180
173
|
private hide;
|
package/dist/elements/a-menu.js
CHANGED
|
@@ -7,14 +7,12 @@ const MIN_HEIGHT = 96;
|
|
|
7
7
|
const SUBMENU_OPEN_DELAY = 130;
|
|
8
8
|
const SUBMENU_CLOSE_DELAY = 130;
|
|
9
9
|
const TYPEAHEAD_RESET = 500;
|
|
10
|
-
const ANCHOR_VISIBLE_RATIO = 0.5;
|
|
11
10
|
const SELF_ACTIVATING = 'a-button, button, a[href], input[type="button"], input[type="submit"], input[type="reset"], [role="button"]';
|
|
12
11
|
const EDITABLE_FIELD = "input:not([readonly]), textarea:not([readonly]), a-input:not([readonly]), a-input-time:not([readonly])";
|
|
13
12
|
const openStack = [];
|
|
14
13
|
let docBound = false;
|
|
15
14
|
let boundDoc = null;
|
|
16
15
|
let boundView = null;
|
|
17
|
-
let removePosTracker = null;
|
|
18
16
|
function bindDocListeners(doc, view) {
|
|
19
17
|
if (docBound) return;
|
|
20
18
|
doc.addEventListener("pointerdown", onDocPointerDown, true);
|
|
@@ -33,31 +31,10 @@ function unbindDocListeners() {
|
|
|
33
31
|
boundDoc?.removeEventListener("keyup", onDocKeyUp, true);
|
|
34
32
|
boundDoc?.removeEventListener("contextmenu", onDocContextMenu, true);
|
|
35
33
|
boundView?.removeEventListener("resize", onResize);
|
|
36
|
-
removePosTracker?.();
|
|
37
|
-
removePosTracker = null;
|
|
38
34
|
boundDoc = null;
|
|
39
35
|
boundView = null;
|
|
40
36
|
docBound = false;
|
|
41
37
|
}
|
|
42
|
-
function trackPosition(el, onEscape) {
|
|
43
|
-
if (typeof IntersectionObserver === "undefined") return () => {
|
|
44
|
-
};
|
|
45
|
-
const doc = el.ownerDocument;
|
|
46
|
-
const rect = el.getBoundingClientRect();
|
|
47
|
-
const vw = doc.documentElement.clientWidth;
|
|
48
|
-
const vh = doc.documentElement.clientHeight;
|
|
49
|
-
const rootMargin = `${-rect.top}px ${-(vw - rect.right)}px ${-(vh - rect.bottom)}px ${-rect.left}px`;
|
|
50
|
-
const win = doc.defaultView;
|
|
51
|
-
const root = win && win !== win.top ? doc.documentElement : null;
|
|
52
|
-
const io = new IntersectionObserver(
|
|
53
|
-
([entry]) => {
|
|
54
|
-
if (!entry.isIntersecting) onEscape();
|
|
55
|
-
},
|
|
56
|
-
{ root, rootMargin, threshold: ANCHOR_VISIBLE_RATIO }
|
|
57
|
-
);
|
|
58
|
-
io.observe(el);
|
|
59
|
-
return () => io.disconnect();
|
|
60
|
-
}
|
|
61
38
|
function pathHitsMenus(e, primaryClick = false) {
|
|
62
39
|
const path = e.composedPath();
|
|
63
40
|
for (const m of openStack) {
|
|
@@ -471,8 +448,7 @@ class AMenuElement extends HTMLElementBase {
|
|
|
471
448
|
if (viaKeyboard) (selected ?? items[0])?.focus({ preventScroll: true });
|
|
472
449
|
}
|
|
473
450
|
/** Scroll THIS menu's body so `item` sits inside the visible scroll viewport,
|
|
474
|
-
* touching only the internal `.scroll` container
|
|
475
|
-
* scroll would trip the anchor-scrolled-out dismiss. No-op for a menu short
|
|
451
|
+
* touching only the internal `.scroll` container. No-op for a menu short
|
|
476
452
|
* enough not to scroll. */
|
|
477
453
|
scrollItemIntoView(item) {
|
|
478
454
|
const c = this.scrollEl;
|
|
@@ -696,7 +672,6 @@ class AMenuElement extends HTMLElementBase {
|
|
|
696
672
|
openStack.push(this);
|
|
697
673
|
if (wasEmpty) {
|
|
698
674
|
bindDocListeners(this.doc, this.view);
|
|
699
|
-
this.armPositionTracker();
|
|
700
675
|
}
|
|
701
676
|
const search = this.#searchField;
|
|
702
677
|
if (search) {
|
|
@@ -722,20 +697,6 @@ class AMenuElement extends HTMLElementBase {
|
|
|
722
697
|
});
|
|
723
698
|
this.comboObserver.observe(this, { childList: true });
|
|
724
699
|
}
|
|
725
|
-
/** Watch the root trigger and dismiss the system once it scrolls out of the
|
|
726
|
-
* spot it held at open (see trackPosition). Deferred a frame so the trigger's
|
|
727
|
-
* post-open layout has settled before the rect is snapshotted; guarded in case
|
|
728
|
-
* the menu closed in between. Tracks the root anchor only — submenus ride
|
|
729
|
-
* inside it, so if the root anchor goes, the whole system should go. */
|
|
730
|
-
armPositionTracker() {
|
|
731
|
-
const anchor = this.triggerAnchor;
|
|
732
|
-
if (!anchor) return;
|
|
733
|
-
this.view.requestAnimationFrame(() => {
|
|
734
|
-
if (!this._shown || openStack[0] !== this) return;
|
|
735
|
-
removePosTracker?.();
|
|
736
|
-
removePosTracker = trackPosition(anchor, () => dismiss());
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
700
|
/** Apply CLOSE to the DOM (no event). Closes this menu and everything stacked
|
|
740
701
|
* above it (its submenus). */
|
|
741
702
|
hide() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta{:where(a-progress,progress[data-anta]){--progress-bg: var(--bg-4);--progress-border-color: var(--border-4);--progress-indicator-bg: var(--bg-5);--progress-indicator-edge: linear-gradient( 90deg, var(--progress-indicator-bg) 0%, var(--progress-border-color) 100% );--progress-text-color: var(--text-2);--progress-hint-color: var(--text-3);--progress-loading-angle: 125deg;--progress-loading-x-period: calc(40px + 5cqi) ;--progress-loading-period: calc( var(--progress-loading-x-period) * cos(var(--progress-loading-angle) - 90deg) );--progress-loading-stripe: calc(var(--progress-loading-period) * 2 / 5);--progress-loading-stripe-gap: calc(var(--progress-loading-period) * 3 / 5);--progress-loading-opacity: .15;--progress-loading-blur: clamp(8px, 2cqi, 16px);--progress-loading-duration: .5s;--progress-padding-block: 4px;--progress-padding-inline: 8px;--progress-min-height: 8px;--progress-label-size: 13px;--progress-label-line-height: 16px}a-progress{display:block;container-type:inline-size;padding:var(--progress-padding-block) var(--progress-padding-inline);min-height:var(--progress-min-height);background:var(--progress-bg);border:0px solid var(--progress-border-color);border-radius:0}:where(a-progress,progress[data-anta])[size=small]{--progress-padding-block: 2px;--progress-padding-inline: 6px;--progress-label-size: 12px;--progress-label-line-height: 14px}:where(a-progress,progress[data-anta])[size=large]{--progress-padding-block: 6px;--progress-padding-inline: 10px;--progress-label-size: 15px;--progress-label-line-height: 20px}a-progress[round]{--progress-round: 999px;border-radius:var(--progress-round)}@supports (border-radius: attr(round type(<length>),999px)){a-progress[round]{--progress-round: attr(round type(<length>), 999px)}}:where(a-progress,progress[data-anta])[tone=brand]{--progress-bg: var(--bg-4-brand);--progress-border-color: var(--border-4-brand);--progress-indicator-bg: var(--bg-5-brand);--progress-text-color: var(--text-2-brand);--progress-hint-color: var(--text-3-brand)}:where(a-progress,progress[data-anta])[tone=info]{--progress-bg: var(--bg-4-info);--progress-border-color: var(--border-4-info);--progress-indicator-bg: var(--bg-5-info);--progress-text-color: var(--text-2-info);--progress-hint-color: var(--text-3-info)}:where(a-progress,progress[data-anta])[tone=success]{--progress-bg: var(--bg-4-success);--progress-border-color: var(--border-4-success);--progress-indicator-bg: var(--bg-5-success);--progress-text-color: var(--text-2-success);--progress-hint-color: var(--text-3-success)}:where(a-progress,progress[data-anta])[tone=warning]{--progress-bg: var(--bg-4-warning);--progress-border-color: var(--border-4-warning);--progress-indicator-bg: var(--bg-5-warning);--progress-text-color: var(--text-2-warning);--progress-hint-color: var(--text-3-warning)}:where(a-progress,progress[data-anta])[tone=critical]{--progress-bg: var(--bg-4-critical);--progress-border-color: var(--border-4-critical);--progress-indicator-bg: var(--bg-5-critical);--progress-text-color: var(--text-2-critical);--progress-hint-color: var(--text-3-critical)}@supports (color: attr(tone type(<color>),transparent)){:where(a-progress,progress[data-anta])[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--progress-tone-source: attr(tone type(<color>), transparent);--progress-bg: oklch(from var(--progress-tone-source) .955 .02 h);--progress-border-color: oklch(from var(--progress-tone-source) .9 .04 h);--progress-indicator-bg: oklch(from var(--progress-tone-source) .935 .03 h);--progress-text-color: oklch(from var(--progress-tone-source) .43 .15 h);--progress-hint-color: color-mix(in oklch, var(--progress-text-color) 82%, transparent);.dark &{--progress-bg: oklch(from var(--progress-tone-source) .185 .05 h);--progress-border-color: oklch(from var(--progress-tone-source) .26 .06 h);--progress-indicator-bg: oklch(from var(--progress-tone-source) .205 .055 h);--progress-text-color: oklch(from var(--progress-tone-source) .77 .11 h);--progress-hint-color: color-mix(in oklch, var(--progress-text-color) 80%, transparent)}}}a-progress-label{display:flex;align-items:flex-start;gap:.5ch;font-variant-numeric:lining-nums tabular-nums;font-feature-settings:"ss02","ss05";letter-spacing:.03em;font-size:var(--progress-label-size);line-height:var(--progress-label-line-height)}a-progress-number{flex-shrink:0;color:var(--progress-text-color)}a-progress-text{flex:1 1 auto;min-width:0;color:var(--progress-text-color)}a-progress-hint{flex-shrink:0;margin-left:auto;color:var(--progress-hint-color)}progress[data-anta]{--anta-native-progress-height: calc( var(--progress-min-height) + var(--progress-padding-block) + var(--progress-padding-block) );--anta-native-progress-radius: 0px;--anta-native-progress-fill: linear-gradient( 90deg, var(--progress-indicator-bg) 0%, var(--progress-indicator-bg) calc(100% - 90px) , var(--progress-border-color) 100% );box-sizing:border-box;display:block;position:relative;container-type:inline-size;inline-size:100%;block-size:var(--anta-native-progress-height);margin:0;padding:0;border:0;border-radius:var(--anta-native-progress-radius);appearance:none;-webkit-appearance:none;-moz-appearance:none;background:var(--progress-bg);overflow:hidden;vertical-align:middle}progress[data-anta][round]{--anta-native-progress-radius: 999px}@supports (border-radius: attr(round type(<length>),999px)){progress[data-anta][round]{--anta-native-progress-radius: attr(round type(<length>), 999px)}}progress[data-anta]::-webkit-progress-bar{border-radius:var(--anta-native-progress-radius);background:var(--progress-bg)}progress[data-anta]::-webkit-progress-value{border-radius:var(--anta-native-progress-radius);background:var(--anta-native-progress-fill)}progress[data-anta]::-moz-progress-bar{border:0;border-radius:var(--anta-native-progress-radius);background:var(--anta-native-progress-fill)}progress[data-anta]:not([value]):before{content:"";position:absolute;top:0;bottom:0;left:calc(0px - var(--progress-loading-x-period));width:calc(100% + var(--progress-loading-x-period));pointer-events:none;background:repeating-linear-gradient(var(--progress-loading-angle),transparent 0,transparent var(--progress-loading-stripe-gap),var(--progress-text-color) var(--progress-loading-stripe-gap),var(--progress-text-color) calc(var(--progress-loading-stripe-gap) + var(--progress-loading-stripe)));filter:blur(var(--progress-loading-blur));opacity:var(--progress-loading-opacity);will-change:transform}@media(prefers-reduced-motion:no-preference){progress[data-anta]:not([value]):before{animation:progress-native-loading-slide var(--progress-loading-duration) linear infinite;animation-delay:-9999s}}@keyframes progress-native-loading-slide{to{transform:translate(var(--progress-loading-x-period))}}@media(forced-colors:active){:where(a-progress,progress[data-anta]){forced-color-adjust:none;--progress-bg: Canvas !important;--progress-border-color: CanvasText !important;--progress-indicator-bg: SelectedItem !important;--progress-indicator-edge: SelectedItem !important;--progress-indicator-edge-border: 1px solid SelectedItemText !important;--progress-text-color: CanvasText !important;--progress-hint-color: CanvasText !important;border:1px dotted CanvasText!important}.dark :where(a-progress,progress[data-anta]){--progress-indicator-bg: Highlight !important;--progress-indicator-edge: Highlight !important;--progress-indicator-edge-border: 1px solid HighlightText !important}}@media(forced-colors:active)and (prefers-color-scheme:dark){:where(a-progress,progress[data-anta]){--progress-indicator-bg: Highlight !important;--progress-indicator-edge: Highlight !important;--progress-indicator-edge-border: 1px solid HighlightText !important}}}
|
|
1
|
+
@layer anta{:where(a-progress,progress[data-anta]){--progress-bg: var(--bg-4);--progress-border-color: var(--border-4);--progress-indicator-bg: var(--bg-5);--progress-indicator-edge: linear-gradient( 90deg, var(--progress-indicator-bg) 0%, var(--progress-border-color) 100% );--progress-text-color: var(--text-2);--progress-hint-color: var(--text-3);--progress-loading-angle: 125deg;--progress-loading-x-period: calc(40px + 5cqi) ;--progress-loading-period: calc( var(--progress-loading-x-period) * cos(var(--progress-loading-angle) - 90deg) );--progress-loading-stripe: calc(var(--progress-loading-period) * 2 / 5);--progress-loading-stripe-gap: calc(var(--progress-loading-period) * 3 / 5);--progress-loading-opacity: .15;--progress-loading-blur: clamp(8px, 2cqi, 16px);--progress-loading-duration: .5s;--progress-padding-block: 4px;--progress-padding-inline: 8px;--progress-min-height: 8px;--progress-label-size: 13px;--progress-label-line-height: 16px}a-progress{display:block;container-type:inline-size;padding:var(--progress-padding-block) var(--progress-padding-inline);min-height:var(--progress-min-height);background:var(--progress-bg);border:0px solid var(--progress-border-color);border-radius:0}:where(a-progress,progress[data-anta])[size=small]{--progress-padding-block: 2px;--progress-padding-inline: 6px;--progress-label-size: 12px;--progress-label-line-height: 14px}:where(a-progress,progress[data-anta])[size=large]{--progress-padding-block: 6px;--progress-padding-inline: 10px;--progress-label-size: 15px;--progress-label-line-height: 20px}a-progress[round]{--progress-round: 999px;border-radius:var(--progress-round)}@supports (border-radius: attr(round type(<length>),999px)){a-progress[round]{--progress-round: attr(round type(<length>), 999px)}}:where(a-progress,progress[data-anta])[tone=brand]{--progress-bg: var(--bg-4-brand);--progress-border-color: var(--border-4-brand);--progress-indicator-bg: var(--bg-5-brand);--progress-text-color: var(--text-2-brand);--progress-hint-color: var(--text-3-brand)}:where(a-progress,progress[data-anta])[tone=info]{--progress-bg: var(--bg-4-info);--progress-border-color: var(--border-4-info);--progress-indicator-bg: var(--bg-5-info);--progress-text-color: var(--text-2-info);--progress-hint-color: var(--text-3-info)}:where(a-progress,progress[data-anta])[tone=success]{--progress-bg: var(--bg-4-success);--progress-border-color: var(--border-4-success);--progress-indicator-bg: var(--bg-5-success);--progress-text-color: var(--text-2-success);--progress-hint-color: var(--text-3-success)}:where(a-progress,progress[data-anta])[tone=warning]{--progress-bg: var(--bg-4-warning);--progress-border-color: var(--border-4-warning);--progress-indicator-bg: var(--bg-5-warning);--progress-text-color: var(--text-2-warning);--progress-hint-color: var(--text-3-warning)}:where(a-progress,progress[data-anta])[tone=critical]{--progress-bg: var(--bg-4-critical);--progress-border-color: var(--border-4-critical);--progress-indicator-bg: var(--bg-5-critical);--progress-text-color: var(--text-2-critical);--progress-hint-color: var(--text-3-critical)}@supports (color: attr(tone type(<color>),transparent)){:where(a-progress,progress[data-anta])[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--progress-tone-source: attr(tone type(<color>), transparent);--progress-bg: oklch(from var(--progress-tone-source) .955 .02 h);--progress-border-color: oklch(from var(--progress-tone-source) .9 .04 h);--progress-indicator-bg: oklch(from var(--progress-tone-source) .935 .03 h);--progress-text-color: oklch(from var(--progress-tone-source) .43 .15 h);--progress-hint-color: color-mix(in oklch, var(--progress-text-color) 82%, transparent);.dark &{--progress-bg: oklch(from var(--progress-tone-source) .185 .05 h);--progress-border-color: oklch(from var(--progress-tone-source) .26 .06 h);--progress-indicator-bg: oklch(from var(--progress-tone-source) .205 .055 h);--progress-text-color: oklch(from var(--progress-tone-source) .77 .11 h);--progress-hint-color: color-mix(in oklch, var(--progress-text-color) 80%, transparent)}}}a-progress-label{display:flex;align-items:flex-start;gap:.5ch;font-variant-numeric:lining-nums tabular-nums;font-feature-settings:"ss02","ss05";letter-spacing:.03em;font-size:var(--progress-label-size);line-height:var(--progress-label-line-height)}a-progress-number{flex-shrink:0;color:var(--progress-text-color)}a-progress-text{flex:1 1 auto;min-width:0;color:var(--progress-text-color)}a-progress-hint{flex-shrink:0;margin-left:auto;color:var(--progress-hint-color)}progress[data-anta]{--anta-native-progress-height: calc( var(--progress-min-height) + var(--progress-padding-block) + var(--progress-padding-block) );--anta-native-progress-radius: 0px;--anta-native-progress-fill: linear-gradient( 90deg, var(--progress-indicator-bg) 0%, var(--progress-indicator-bg) calc(100% - 90px) , var(--progress-border-color) 100% );box-sizing:border-box;display:block;position:relative;container-type:inline-size;inline-size:100%;block-size:var(--anta-native-progress-height);margin:0;padding:0;border:0;border-radius:var(--anta-native-progress-radius);appearance:none;-webkit-appearance:none;-moz-appearance:none;background:var(--progress-bg);overflow:hidden;vertical-align:middle}progress[data-anta][round]{--anta-native-progress-radius: 999px}@supports (border-radius: attr(round type(<length>),999px)){progress[data-anta][round]{--anta-native-progress-radius: attr(round type(<length>), 999px)}}progress[data-anta]::-webkit-progress-bar{border-radius:var(--anta-native-progress-radius);background:var(--progress-bg)}progress[data-anta]::-webkit-progress-value{border-radius:var(--anta-native-progress-radius);background:var(--anta-native-progress-fill)}progress[data-anta]::-moz-progress-bar{border:0;border-radius:var(--anta-native-progress-radius);background:var(--anta-native-progress-fill)}progress[data-anta]:not([value]):before{content:"";position:absolute;top:0;bottom:0;left:calc(0px - var(--progress-loading-x-period));width:calc(100% + var(--progress-loading-x-period));pointer-events:none;background:repeating-linear-gradient(var(--progress-loading-angle),transparent 0,transparent var(--progress-loading-stripe-gap),var(--progress-text-color) var(--progress-loading-stripe-gap),var(--progress-text-color) calc(var(--progress-loading-stripe-gap) + var(--progress-loading-stripe)));filter:blur(var(--progress-loading-blur));opacity:var(--progress-loading-opacity);will-change:transform}@media(prefers-reduced-motion:no-preference){progress[data-anta]:not([value]):before{animation:progress-native-loading-slide var(--progress-loading-duration) linear infinite;animation-delay:-9999s}}@keyframes progress-native-loading-slide{to{transform:translate(var(--progress-loading-x-period))}}@media(forced-colors:active){:where(a-progress,progress[data-anta]){forced-color-adjust:none;--progress-bg: Canvas !important;--progress-border-color: CanvasText !important;--progress-indicator-bg: SelectedItem !important;--progress-indicator-edge: SelectedItem !important;--progress-indicator-edge-border: 1px solid SelectedItemText !important;--progress-text-color: CanvasText !important;--progress-hint-color: CanvasText !important;border:1px dotted CanvasText!important}.dark :where(a-progress,progress[data-anta]){--progress-indicator-bg: Highlight !important;--progress-indicator-edge: Highlight !important;--progress-indicator-edge-border: 1px solid HighlightText !important}}@media(forced-colors:active)and (prefers-color-scheme:dark){:where(a-progress,progress[data-anta]){--progress-indicator-bg: Highlight !important;--progress-indicator-edge: Highlight !important;--progress-indicator-edge-border: 1px solid HighlightText !important}}}a-progress>p:last-child,a-progress>:not([slot])>p:last-child{margin-block-end:0}
|
|
@@ -35,6 +35,10 @@ export declare class ATextElement extends HTMLElementBase {
|
|
|
35
35
|
connectedCallback(): void;
|
|
36
36
|
disconnectedCallback(): void;
|
|
37
37
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
38
|
+
/** True when `truncate` currently hides some of the slotted content. This is
|
|
39
|
+
* a UI-thread layout read, used by a nested `a-tooltip`; it never writes to
|
|
40
|
+
* the host or light DOM. */
|
|
41
|
+
get isTruncated(): boolean;
|
|
38
42
|
/** Create or remove the chevron to match `expandable`, then refresh it. */
|
|
39
43
|
private syncExpandButton;
|
|
40
44
|
private handleToggle;
|
package/dist/elements/a-text.js
CHANGED
|
@@ -141,6 +141,15 @@ class ATextElement extends HTMLElementBase {
|
|
|
141
141
|
get #isCollapsible() {
|
|
142
142
|
return this.hasAttribute("collapsible");
|
|
143
143
|
}
|
|
144
|
+
/** True when `truncate` currently hides some of the slotted content. This is
|
|
145
|
+
* a UI-thread layout read, used by a nested `a-tooltip`; it never writes to
|
|
146
|
+
* the host or light DOM. */
|
|
147
|
+
get isTruncated() {
|
|
148
|
+
if (!this.hasAttribute("truncate") || this.expanded) return false;
|
|
149
|
+
const s = this.slotEl;
|
|
150
|
+
if (s.clientWidth === 0 && s.clientHeight === 0) return false;
|
|
151
|
+
return s.scrollHeight > s.clientHeight + 1 || s.scrollWidth > s.clientWidth + 1;
|
|
152
|
+
}
|
|
144
153
|
/** Create or remove the chevron to match `expandable`, then refresh it. */
|
|
145
154
|
syncExpandButton() {
|
|
146
155
|
if (this.#isExpandable && !this.expandBtn) {
|
|
@@ -183,9 +192,7 @@ class ATextElement extends HTMLElementBase {
|
|
|
183
192
|
* clips. Frozen on while expanded; height catches wrapped text, width a long word. */
|
|
184
193
|
measureOverflow() {
|
|
185
194
|
if (!this.#isExpandable || this.expanded) return;
|
|
186
|
-
|
|
187
|
-
const over = s.scrollHeight > s.clientHeight + 1 || s.scrollWidth > s.clientWidth + 1;
|
|
188
|
-
s.classList.toggle("overflowing", over);
|
|
195
|
+
this.slotEl.classList.toggle("overflowing", this.isTruncated);
|
|
189
196
|
}
|
|
190
197
|
/** Reflect state onto the button (label + `aria-expanded` + `.expanded`); a
|
|
191
198
|
* one-way expand removes it once open. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta{a-tooltip:not(:defined){display:none}@media(hover:none)and (pointer:coarse){:where(:has(>a-tooltip)){-webkit-touch-callout:none;user-select:none}}a-tooltip{--tooltip-bg: color-mix(in oklch, var(--bg-1) 80%, transparent);--tooltip-shadow: 0 1px 8px color-mix(in oklch, var(--text-1) 15%, transparent), 0 0 1px color-mix(in oklch, var(--text-1) 50%, transparent);--tooltip-radius: 3px;--tooltip-max-width: min( calc(100vw - 20px) , 80ch);--tooltip-border: none;--tooltip-backdrop-filter: blur(8px)}a-tooltip[round]{--tooltip-radius: attr(round type(<length>), 20px)}.dark a-tooltip{--tooltip-bg: color-mix(in oklch, var(--bg-1) 70%, transparent);--tooltip-shadow: 0 2px 16px color-mix(in oklch, black 70%, transparent), inset 0 0 0 1px color-mix(in oklch, white 15%, transparent)}@media(forced-colors:active){a-tooltip{--tooltip-border: 1px dotted CanvasText}}}
|
|
1
|
+
@layer anta{a-tooltip:not(:defined){display:none}@media(hover:none)and (pointer:coarse){:where(:has(>a-tooltip)){-webkit-touch-callout:none;user-select:none}}a-tooltip{--tooltip-bg: color-mix(in oklch, var(--bg-1) 80%, transparent);--tooltip-shadow: 0 1px 8px color-mix(in oklch, var(--text-1) 15%, transparent), 0 0 1px color-mix(in oklch, var(--text-1) 50%, transparent);--tooltip-radius: 3px;--tooltip-max-width: min( calc(100vw - 20px) , 80ch);--tooltip-border: none;--tooltip-backdrop-filter: blur(8px)}a-tooltip[round]{--tooltip-radius: attr(round type(<length>), 20px)}.dark a-tooltip{--tooltip-bg: color-mix(in oklch, var(--bg-1) 70%, transparent);--tooltip-shadow: 0 2px 16px color-mix(in oklch, black 70%, transparent), inset 0 0 0 1px color-mix(in oklch, white 15%, transparent)}@media(forced-colors:active){a-tooltip{--tooltip-border: 1px dotted CanvasText}}}a-tooltip>p:last-child,a-tooltip>:not([slot])>p:last-child{margin-block-end:0}
|
|
@@ -64,6 +64,13 @@ export declare class ATooltipElement extends HTMLElementBase {
|
|
|
64
64
|
* fed the latest cursor event, so it shows at the cursor and so moving back
|
|
65
65
|
* onto an anchor after the tooltip was dismissed re-arms it. */
|
|
66
66
|
private makeDebouncedShow;
|
|
67
|
+
private hasExplicitTextTooltip;
|
|
68
|
+
/** Text rendered by the anchor, excluding every tooltip's light-DOM content.
|
|
69
|
+
* An automatic text tooltip has no light children itself, but nested custom
|
|
70
|
+
* tooltips might; including their hidden content would produce a misleading
|
|
71
|
+
* fallback string. */
|
|
72
|
+
private anchorText;
|
|
73
|
+
private syncAutomaticTextContent;
|
|
67
74
|
/** The element whose overflow decides whether the tooltip shows: a
|
|
68
75
|
* `truncated-selector` resolved within the anchor wins; else the first of
|
|
69
76
|
* Anta's ellipsizing label parts inside the anchor; else the anchor itself
|
|
@@ -109,7 +116,7 @@ export declare class ATooltipElement extends HTMLElementBase {
|
|
|
109
116
|
private position;
|
|
110
117
|
/** Opacity for the inner bubble from the cursor's distance to the anchor rect
|
|
111
118
|
* (0 inside the rect): 1 within PROX_NEAR, a linear ramp to 0 at PROX_FAR.
|
|
112
|
-
* Cursor-follow only — drives the "fade as you move away"
|
|
119
|
+
* Cursor-follow only — drives the "fade as you move away" behavior. */
|
|
113
120
|
private proximityOpacity;
|
|
114
121
|
show: (e?: MouseEvent) => void;
|
|
115
122
|
hide: () => void;
|
|
@@ -13,6 +13,7 @@ const PROX_FAR = 100;
|
|
|
13
13
|
const PROX_FADE_MS = 60;
|
|
14
14
|
const ENTER_TOUCH_DELAY = 500;
|
|
15
15
|
const TRUNCATING_PARTS = "a-tab-label, a-button-label";
|
|
16
|
+
const AUTOMATIC_TEXT_TOOLTIP = "data-anta-text-tooltip";
|
|
16
17
|
const LEAVE_TOUCH_DELAY = 1500;
|
|
17
18
|
const TOUCH_SLOP = 10;
|
|
18
19
|
let currentOpen = null;
|
|
@@ -45,16 +46,37 @@ function releaseOpen(el) {
|
|
|
45
46
|
graceTimer = void 0;
|
|
46
47
|
}, GRACE_MS);
|
|
47
48
|
}
|
|
48
|
-
const
|
|
49
|
+
const anchorToTooltips = /* @__PURE__ */ new WeakMap();
|
|
50
|
+
function preferredTooltip(registry) {
|
|
51
|
+
let automatic;
|
|
52
|
+
let explicit;
|
|
53
|
+
for (const tooltip of registry.tooltips) {
|
|
54
|
+
if (tooltip.hasAttribute(AUTOMATIC_TEXT_TOOLTIP)) automatic = tooltip;
|
|
55
|
+
else explicit = tooltip;
|
|
56
|
+
}
|
|
57
|
+
return explicit ?? automatic;
|
|
58
|
+
}
|
|
59
|
+
function syncAnchorListeners(anchor, registry) {
|
|
60
|
+
const preferred = preferredTooltip(registry);
|
|
61
|
+
for (const tooltip of registry.tooltips) {
|
|
62
|
+
if (tooltip !== preferred) tooltip.teardownListeners();
|
|
63
|
+
}
|
|
64
|
+
if (!preferred || !registry.intersecting) {
|
|
65
|
+
preferred?.teardownListeners();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
const current = anchorToTooltips.get(anchor);
|
|
70
|
+
if (current !== registry || !current.intersecting || preferredTooltip(current) !== preferred) return;
|
|
71
|
+
preferred.setupListeners();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
49
74
|
function handleIntersection(entries) {
|
|
50
75
|
for (const entry of entries) {
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} else if (tooltip.listening && !entry.isIntersecting) {
|
|
56
|
-
requestAnimationFrame(() => tooltip.teardownListeners());
|
|
57
|
-
}
|
|
76
|
+
const registry = anchorToTooltips.get(entry.target);
|
|
77
|
+
if (!registry) continue;
|
|
78
|
+
registry.intersecting = entry.isIntersecting;
|
|
79
|
+
syncAnchorListeners(entry.target, registry);
|
|
58
80
|
}
|
|
59
81
|
}
|
|
60
82
|
const lazyObserver = typeof IntersectionObserver !== "undefined" ? new IntersectionObserver(handleIntersection, { root: null, rootMargin: "0px", threshold: 0 }) : null;
|
|
@@ -178,15 +200,26 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
178
200
|
const parent = this.parentElement;
|
|
179
201
|
if (!parent) return;
|
|
180
202
|
this.anchor = parent;
|
|
181
|
-
|
|
182
|
-
|
|
203
|
+
let registry = anchorToTooltips.get(parent);
|
|
204
|
+
if (!registry) {
|
|
205
|
+
registry = { tooltips: /* @__PURE__ */ new Set(), intersecting: false };
|
|
206
|
+
anchorToTooltips.set(parent, registry);
|
|
207
|
+
lazyObserver?.observe(parent);
|
|
208
|
+
}
|
|
209
|
+
registry.tooltips.add(this);
|
|
210
|
+
syncAnchorListeners(parent, registry);
|
|
183
211
|
}
|
|
184
212
|
disconnectedCallback() {
|
|
185
213
|
this.cleanup();
|
|
186
214
|
if (this.anchor) {
|
|
187
|
-
|
|
188
|
-
|
|
215
|
+
const anchor = this.anchor;
|
|
216
|
+
const registry = anchorToTooltips.get(anchor);
|
|
217
|
+
registry?.tooltips.delete(this);
|
|
218
|
+
if (registry && registry.tooltips.size === 0) {
|
|
219
|
+
anchorToTooltips.delete(anchor);
|
|
189
220
|
lazyObserver?.unobserve(this.anchor);
|
|
221
|
+
} else if (registry) {
|
|
222
|
+
syncAnchorListeners(anchor, registry);
|
|
190
223
|
}
|
|
191
224
|
this.anchor = null;
|
|
192
225
|
}
|
|
@@ -228,6 +261,34 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
228
261
|
get #truncatedOnly() {
|
|
229
262
|
return this.hasAttribute("truncated-only");
|
|
230
263
|
}
|
|
264
|
+
/** JSX `<Text truncate>` emits an empty marked tooltip. It takes its content
|
|
265
|
+
* from the anchor, while a consumer-provided sibling tooltip takes precedence
|
|
266
|
+
* even when that sibling is empty. */
|
|
267
|
+
get #isAutomaticTextTooltip() {
|
|
268
|
+
return this.hasAttribute(AUTOMATIC_TEXT_TOOLTIP);
|
|
269
|
+
}
|
|
270
|
+
hasExplicitTextTooltip() {
|
|
271
|
+
const anchor = this.anchor;
|
|
272
|
+
if (!this.#isAutomaticTextTooltip || !anchor) return false;
|
|
273
|
+
return Array.from(anchor.children).some(
|
|
274
|
+
(child) => child !== this && child.localName === "a-tooltip" && !child.hasAttribute(AUTOMATIC_TEXT_TOOLTIP)
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
/** Text rendered by the anchor, excluding every tooltip's light-DOM content.
|
|
278
|
+
* An automatic text tooltip has no light children itself, but nested custom
|
|
279
|
+
* tooltips might; including their hidden content would produce a misleading
|
|
280
|
+
* fallback string. */
|
|
281
|
+
anchorText() {
|
|
282
|
+
const read = (node) => {
|
|
283
|
+
if (node.nodeType === 3) return node.textContent ?? "";
|
|
284
|
+
if (node.nodeType === 1 && node.localName === "a-tooltip") return "";
|
|
285
|
+
return Array.from(node.childNodes).map(read).join("");
|
|
286
|
+
};
|
|
287
|
+
return this.anchor ? Array.from(this.anchor.childNodes).map(read).join("").trim() : "";
|
|
288
|
+
}
|
|
289
|
+
syncAutomaticTextContent() {
|
|
290
|
+
if (this.#isAutomaticTextTooltip) this.bubble.textContent = this.anchorText();
|
|
291
|
+
}
|
|
231
292
|
/** The element whose overflow decides whether the tooltip shows: a
|
|
232
293
|
* `truncated-selector` resolved within the anchor wins; else the first of
|
|
233
294
|
* Anta's ellipsizing label parts inside the anchor; else the anchor itself
|
|
@@ -252,6 +313,8 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
252
313
|
isTargetTruncated() {
|
|
253
314
|
const t = this.resolveTruncationTarget();
|
|
254
315
|
if (!t) return false;
|
|
316
|
+
const reported = t.isTruncated;
|
|
317
|
+
if (typeof reported === "boolean") return reported;
|
|
255
318
|
if (t.clientWidth === 0 && t.clientHeight === 0) return false;
|
|
256
319
|
return t.scrollWidth - t.clientWidth > 1 || t.scrollHeight - t.clientHeight > 1;
|
|
257
320
|
}
|
|
@@ -260,6 +323,7 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
260
323
|
* (so formatting whitespace / an empty conditional doesn't open a blank bubble).
|
|
261
324
|
* Re-checked on every show(), so a tooltip populated later self-corrects. */
|
|
262
325
|
isEmpty() {
|
|
326
|
+
if (this.#isAutomaticTextTooltip) return this.anchorText() === "";
|
|
263
327
|
return this.children.length === 0 && (this.textContent ?? "").trim() === "";
|
|
264
328
|
}
|
|
265
329
|
/** While shown, watch the slotted content so a bubble whose content is
|
|
@@ -279,10 +343,16 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
279
343
|
if (typeof MutationObserver === "undefined") return;
|
|
280
344
|
if (!this.contentObserver) {
|
|
281
345
|
this.contentObserver = new MutationObserver(() => {
|
|
282
|
-
if (this.shown
|
|
346
|
+
if (!this.shown) return;
|
|
347
|
+
this.syncAutomaticTextContent();
|
|
348
|
+
if (this.isEmpty()) this.hide();
|
|
283
349
|
});
|
|
284
350
|
}
|
|
285
|
-
this.contentObserver.observe(this
|
|
351
|
+
this.contentObserver.observe(this.#isAutomaticTextTooltip ? this.anchor ?? this : this, {
|
|
352
|
+
childList: true,
|
|
353
|
+
characterData: true,
|
|
354
|
+
subtree: true
|
|
355
|
+
});
|
|
286
356
|
}
|
|
287
357
|
// --- positioning (sets only the shadow container's own transform) ---
|
|
288
358
|
// Single pending position frame: a burst of mousemoves within one frame
|
|
@@ -341,7 +411,7 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
341
411
|
}
|
|
342
412
|
/** Opacity for the inner bubble from the cursor's distance to the anchor rect
|
|
343
413
|
* (0 inside the rect): 1 within PROX_NEAR, a linear ramp to 0 at PROX_FAR.
|
|
344
|
-
* Cursor-follow only — drives the "fade as you move away"
|
|
414
|
+
* Cursor-follow only — drives the "fade as you move away" behavior. */
|
|
345
415
|
proximityOpacity(e) {
|
|
346
416
|
if (!this.anchor) return 1;
|
|
347
417
|
const r = anchorRect(this.anchor);
|
|
@@ -356,8 +426,10 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
356
426
|
show = (e) => {
|
|
357
427
|
if (!this.anchor) return;
|
|
358
428
|
if (isMenuOpen() && !isInsideOpenMenu(this.anchor)) return;
|
|
429
|
+
if (this.hasExplicitTextTooltip()) return;
|
|
359
430
|
if (this.isEmpty()) return;
|
|
360
431
|
if (this.#truncatedOnly && !this.isTargetTruncated()) return;
|
|
432
|
+
this.syncAutomaticTextContent();
|
|
361
433
|
this.cancelHide();
|
|
362
434
|
if (currentOpen && currentOpen !== this && this.anchor.contains(currentOpen.anchor)) {
|
|
363
435
|
return;
|
|
@@ -472,6 +544,7 @@ class ATooltipElement extends HTMLElementBase {
|
|
|
472
544
|
/** Open now if another tooltip is hot (skip delay), else (re)arm the delayed
|
|
473
545
|
* show with the latest cursor event. */
|
|
474
546
|
trigger(e) {
|
|
547
|
+
if (this.hasExplicitTextTooltip()) return;
|
|
475
548
|
if (this.isEmpty()) return;
|
|
476
549
|
if (this.#truncatedOnly && !this.isTargetTruncated()) return;
|
|
477
550
|
if (isHot()) {
|
package/dist/elements/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* set + injects every element's CSS. Importing this barrel for side effects —
|
|
7
7
|
* `import '@antadesign/anta/elements'` — gives you everything.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* To reduce bundle size, import only the element(s) you use:
|
|
10
10
|
* import '@antadesign/anta/elements/a-tooltip' // registers a-tooltip + its CSS, nothing else
|
|
11
11
|
* That granular path pulls in only that element's code and CSS, nothing else.
|
|
12
12
|
*
|