@adobe/spectrum-wc-core 0.0.0-snapshot.20260922095923
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 +39 -0
- package/dist/_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js +9 -0
- package/dist/components/accordion/Accordion.base.d.ts +59 -0
- package/dist/components/accordion/Accordion.base.js +69 -0
- package/dist/components/accordion/Accordion.base.js.map +1 -0
- package/dist/components/accordion/Accordion.types.d.ts +22 -0
- package/dist/components/accordion/Accordion.types.js +21 -0
- package/dist/components/accordion/Accordion.types.js.map +1 -0
- package/dist/components/accordion/AccordionItem.base.d.ts +96 -0
- package/dist/components/accordion/AccordionItem.base.js +93 -0
- package/dist/components/accordion/AccordionItem.base.js.map +1 -0
- package/dist/components/accordion/index.d.ts +14 -0
- package/dist/components/accordion/index.js +4 -0
- package/dist/components/action-button/ActionButton.types.d.ts +15 -0
- package/dist/components/action-button/ActionButton.types.js +12 -0
- package/dist/components/action-button/ActionButton.types.js.map +1 -0
- package/dist/components/action-button/index.d.ts +12 -0
- package/dist/components/action-button/index.js +2 -0
- package/dist/components/action-group/ActionGroup.base.d.ts +108 -0
- package/dist/components/action-group/ActionGroup.base.js +53 -0
- package/dist/components/action-group/ActionGroup.base.js.map +1 -0
- package/dist/components/action-group/ActionGroup.types.d.ts +17 -0
- package/dist/components/action-group/ActionGroup.types.js +12 -0
- package/dist/components/action-group/ActionGroup.types.js.map +1 -0
- package/dist/components/action-group/index.d.ts +13 -0
- package/dist/components/action-group/index.js +3 -0
- package/dist/components/alert-banner/AlertBanner.base.d.ts +36 -0
- package/dist/components/alert-banner/AlertBanner.base.js +57 -0
- package/dist/components/alert-banner/AlertBanner.base.js.map +1 -0
- package/dist/components/alert-banner/AlertBanner.types.d.ts +13 -0
- package/dist/components/alert-banner/AlertBanner.types.js +10 -0
- package/dist/components/alert-banner/AlertBanner.types.js.map +1 -0
- package/dist/components/alert-banner/index.d.ts +13 -0
- package/dist/components/alert-banner/index.js +3 -0
- package/dist/components/asset/Asset.base.d.ts +101 -0
- package/dist/components/asset/Asset.base.js +130 -0
- package/dist/components/asset/Asset.base.js.map +1 -0
- package/dist/components/asset/Asset.types.d.ts +31 -0
- package/dist/components/asset/Asset.types.js +14 -0
- package/dist/components/asset/Asset.types.js.map +1 -0
- package/dist/components/asset/index.d.ts +13 -0
- package/dist/components/asset/index.js +3 -0
- package/dist/components/avatar/Avatar.base.d.ts +53 -0
- package/dist/components/avatar/Avatar.base.js +52 -0
- package/dist/components/avatar/Avatar.base.js.map +1 -0
- package/dist/components/avatar/Avatar.types.d.ts +19 -0
- package/dist/components/avatar/Avatar.types.js +24 -0
- package/dist/components/avatar/Avatar.types.js.map +1 -0
- package/dist/components/avatar/index.d.ts +13 -0
- package/dist/components/avatar/index.js +3 -0
- package/dist/components/badge/Badge.base.d.ts +114 -0
- package/dist/components/badge/Badge.base.js +49 -0
- package/dist/components/badge/Badge.base.js.map +1 -0
- package/dist/components/badge/Badge.types.d.ts +21 -0
- package/dist/components/badge/Badge.types.js +43 -0
- package/dist/components/badge/Badge.types.js.map +1 -0
- package/dist/components/badge/index.d.ts +13 -0
- package/dist/components/badge/index.js +3 -0
- package/dist/components/button/Button.base.d.ts +78 -0
- package/dist/components/button/Button.base.js +51 -0
- package/dist/components/button/Button.base.js.map +1 -0
- package/dist/components/button/Button.types.d.ts +19 -0
- package/dist/components/button/Button.types.js +16 -0
- package/dist/components/button/Button.types.js.map +1 -0
- package/dist/components/button/index.d.ts +13 -0
- package/dist/components/button/index.js +3 -0
- package/dist/components/button-group/ButtonGroup.base.d.ts +89 -0
- package/dist/components/button-group/ButtonGroup.base.js +60 -0
- package/dist/components/button-group/ButtonGroup.base.js.map +1 -0
- package/dist/components/button-group/ButtonGroup.types.d.ts +17 -0
- package/dist/components/button-group/ButtonGroup.types.js +15 -0
- package/dist/components/button-group/ButtonGroup.types.js.map +1 -0
- package/dist/components/button-group/index.d.ts +13 -0
- package/dist/components/button-group/index.js +3 -0
- package/dist/components/card/Card.base.d.ts +172 -0
- package/dist/components/card/Card.base.js +123 -0
- package/dist/components/card/Card.base.js.map +1 -0
- package/dist/components/card/Card.types.d.ts +18 -0
- package/dist/components/card/Card.types.js +21 -0
- package/dist/components/card/Card.types.js.map +1 -0
- package/dist/components/card/index.d.ts +13 -0
- package/dist/components/card/index.js +3 -0
- package/dist/components/color-handle/ColorHandle.base.d.ts +51 -0
- package/dist/components/color-handle/ColorHandle.base.js +39 -0
- package/dist/components/color-handle/ColorHandle.base.js.map +1 -0
- package/dist/components/color-handle/ColorHandle.types.d.ts +30 -0
- package/dist/components/color-handle/color-contrast.d.ts +55 -0
- package/dist/components/color-handle/color-contrast.js +49 -0
- package/dist/components/color-handle/color-contrast.js.map +1 -0
- package/dist/components/color-handle/index.d.ts +14 -0
- package/dist/components/color-handle/index.js +3 -0
- package/dist/components/color-loupe/ColorLoupe.base.d.ts +41 -0
- package/dist/components/color-loupe/ColorLoupe.base.js +21 -0
- package/dist/components/color-loupe/ColorLoupe.base.js.map +1 -0
- package/dist/components/color-loupe/index.d.ts +12 -0
- package/dist/components/color-loupe/index.js +2 -0
- package/dist/components/divider/Divider.base.d.ts +43 -0
- package/dist/components/divider/Divider.base.js +42 -0
- package/dist/components/divider/Divider.base.js.map +1 -0
- package/dist/components/divider/Divider.types.d.ts +15 -0
- package/dist/components/divider/Divider.types.js +10 -0
- package/dist/components/divider/Divider.types.js.map +1 -0
- package/dist/components/divider/index.d.ts +13 -0
- package/dist/components/divider/index.js +3 -0
- package/dist/components/dropzone/Dropzone.base.d.ts +74 -0
- package/dist/components/dropzone/Dropzone.base.js +82 -0
- package/dist/components/dropzone/Dropzone.base.js.map +1 -0
- package/dist/components/dropzone/Dropzone.types.d.ts +43 -0
- package/dist/components/dropzone/Dropzone.types.js +15 -0
- package/dist/components/dropzone/Dropzone.types.js.map +1 -0
- package/dist/components/dropzone/index.d.ts +13 -0
- package/dist/components/dropzone/index.js +3 -0
- package/dist/components/icon/Icon.base.d.ts +36 -0
- package/dist/components/icon/Icon.base.js +28 -0
- package/dist/components/icon/Icon.base.js.map +1 -0
- package/dist/components/icon/Icon.types.d.ts +13 -0
- package/dist/components/icon/Icon.types.js +12 -0
- package/dist/components/icon/Icon.types.js.map +1 -0
- package/dist/components/icon/index.d.ts +13 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.d.ts +60 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.js +59 -0
- package/dist/components/illustrated-message/IllustratedMessage.base.js.map +1 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.d.ts +15 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.js +10 -0
- package/dist/components/illustrated-message/IllustratedMessage.types.js.map +1 -0
- package/dist/components/illustrated-message/index.d.ts +13 -0
- package/dist/components/illustrated-message/index.js +3 -0
- package/dist/components/infield-button/InfieldButton.base.d.ts +28 -0
- package/dist/components/infield-button/InfieldButton.base.js +22 -0
- package/dist/components/infield-button/InfieldButton.base.js.map +1 -0
- package/dist/components/infield-button/InfieldButton.types.d.ts +13 -0
- package/dist/components/infield-button/InfieldButton.types.js +11 -0
- package/dist/components/infield-button/InfieldButton.types.js.map +1 -0
- package/dist/components/infield-button/index.d.ts +13 -0
- package/dist/components/infield-button/index.js +3 -0
- package/dist/components/meter/Meter.base.d.ts +40 -0
- package/dist/components/meter/Meter.base.js +32 -0
- package/dist/components/meter/Meter.base.js.map +1 -0
- package/dist/components/meter/Meter.types.d.ts +13 -0
- package/dist/components/meter/Meter.types.js +11 -0
- package/dist/components/meter/Meter.types.js.map +1 -0
- package/dist/components/meter/index.d.ts +13 -0
- package/dist/components/meter/index.js +3 -0
- package/dist/components/popover/Popover.base.d.ts +226 -0
- package/dist/components/popover/Popover.base.js +287 -0
- package/dist/components/popover/Popover.base.js.map +1 -0
- package/dist/components/popover/Popover.types.d.ts +39 -0
- package/dist/components/popover/Popover.types.js +24 -0
- package/dist/components/popover/Popover.types.js.map +1 -0
- package/dist/components/popover/index.d.ts +13 -0
- package/dist/components/popover/index.js +3 -0
- package/dist/components/progress-bar/ProgressBar.base.d.ts +34 -0
- package/dist/components/progress-bar/ProgressBar.base.js +21 -0
- package/dist/components/progress-bar/ProgressBar.base.js.map +1 -0
- package/dist/components/progress-bar/ProgressBar.types.d.ts +12 -0
- package/dist/components/progress-bar/index.d.ts +13 -0
- package/dist/components/progress-bar/index.js +2 -0
- package/dist/components/progress-circle/ProgressCircle.base.d.ts +83 -0
- package/dist/components/progress-circle/ProgressCircle.base.js +77 -0
- package/dist/components/progress-circle/ProgressCircle.base.js.map +1 -0
- package/dist/components/progress-circle/ProgressCircle.types.d.ts +15 -0
- package/dist/components/progress-circle/ProgressCircle.types.js +10 -0
- package/dist/components/progress-circle/ProgressCircle.types.js.map +1 -0
- package/dist/components/progress-circle/index.d.ts +13 -0
- package/dist/components/progress-circle/index.js +3 -0
- package/dist/components/status-light/StatusLight.base.d.ts +69 -0
- package/dist/components/status-light/StatusLight.base.js +32 -0
- package/dist/components/status-light/StatusLight.base.js.map +1 -0
- package/dist/components/status-light/StatusLight.types.d.ts +19 -0
- package/dist/components/status-light/StatusLight.types.js +32 -0
- package/dist/components/status-light/StatusLight.types.js.map +1 -0
- package/dist/components/status-light/index.d.ts +13 -0
- package/dist/components/status-light/index.js +3 -0
- package/dist/components/tabs/Tab.base.d.ts +49 -0
- package/dist/components/tabs/Tab.base.js +39 -0
- package/dist/components/tabs/Tab.base.js.map +1 -0
- package/dist/components/tabs/Tab.types.d.ts +17 -0
- package/dist/components/tabs/TabPanel.base.d.ts +49 -0
- package/dist/components/tabs/TabPanel.base.js +36 -0
- package/dist/components/tabs/TabPanel.base.js.map +1 -0
- package/dist/components/tabs/TabPanel.types.d.ts +17 -0
- package/dist/components/tabs/Tabs.base.d.ts +221 -0
- package/dist/components/tabs/Tabs.base.js +213 -0
- package/dist/components/tabs/Tabs.base.js.map +1 -0
- package/dist/components/tabs/Tabs.types.d.ts +55 -0
- package/dist/components/tabs/Tabs.types.js +6 -0
- package/dist/components/tabs/Tabs.types.js.map +1 -0
- package/dist/components/tabs/index.d.ts +17 -0
- package/dist/components/tabs/index.js +5 -0
- package/dist/components/tooltip/Tooltip.base.d.ts +159 -0
- package/dist/components/tooltip/Tooltip.base.js +198 -0
- package/dist/components/tooltip/Tooltip.base.js.map +1 -0
- package/dist/components/tooltip/Tooltip.types.d.ts +18 -0
- package/dist/components/tooltip/Tooltip.types.js +15 -0
- package/dist/components/tooltip/Tooltip.types.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +13 -0
- package/dist/components/tooltip/index.js +3 -0
- package/dist/controllers/color-controller/index.d.ts +12 -0
- package/dist/controllers/color-controller/index.js +2 -0
- package/dist/controllers/color-controller/src/color-controller.d.ts +226 -0
- package/dist/controllers/color-controller/src/color-controller.js +253 -0
- package/dist/controllers/color-controller/src/color-controller.js.map +1 -0
- package/dist/controllers/drag-and-drop-controller/index.d.ts +12 -0
- package/dist/controllers/drag-and-drop-controller/index.js +2 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.d.ts +68 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js +56 -0
- package/dist/controllers/drag-and-drop-controller/src/drag-and-drop-controller.js.map +1 -0
- package/dist/controllers/focusgroup-navigation-controller/index.d.ts +12 -0
- package/dist/controllers/focusgroup-navigation-controller/index.js +2 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.d.ts +496 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js +345 -0
- package/dist/controllers/focusgroup-navigation-controller/src/focusgroup-navigation-controller.js.map +1 -0
- package/dist/controllers/hover-controller/index.d.ts +12 -0
- package/dist/controllers/hover-controller/index.js +2 -0
- package/dist/controllers/hover-controller/src/hover-controller.d.ts +118 -0
- package/dist/controllers/hover-controller/src/hover-controller.js +90 -0
- package/dist/controllers/hover-controller/src/hover-controller.js.map +1 -0
- package/dist/controllers/index.d.ts +26 -0
- package/dist/controllers/index.js +18 -0
- package/dist/controllers/language-resolution.d.ts +87 -0
- package/dist/controllers/language-resolution.js +56 -0
- package/dist/controllers/language-resolution.js.map +1 -0
- package/dist/controllers/live-selection-controller/index.d.ts +12 -0
- package/dist/controllers/live-selection-controller/index.js +2 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.d.ts +144 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.js +36 -0
- package/dist/controllers/live-selection-controller/src/live-selection-controller.js.map +1 -0
- package/dist/controllers/page-scroll-lock-controller/index.d.ts +12 -0
- package/dist/controllers/page-scroll-lock-controller/index.js +2 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.d.ts +20 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js +30 -0
- package/dist/controllers/page-scroll-lock-controller/src/page-scroll-lock.js.map +1 -0
- package/dist/controllers/pending-controller/index.d.ts +12 -0
- package/dist/controllers/pending-controller/index.js +2 -0
- package/dist/controllers/pending-controller/src/pending-controller.d.ts +95 -0
- package/dist/controllers/pending-controller/src/pending-controller.js +55 -0
- package/dist/controllers/pending-controller/src/pending-controller.js.map +1 -0
- package/dist/controllers/placement-controller/index.d.ts +12 -0
- package/dist/controllers/placement-controller/index.js +4 -0
- package/dist/controllers/placement-controller/src/fallback-placements.d.ts +9 -0
- package/dist/controllers/placement-controller/src/fallback-placements.js +71 -0
- package/dist/controllers/placement-controller/src/fallback-placements.js.map +1 -0
- package/dist/controllers/placement-controller/src/placement-controller.d.ts +152 -0
- package/dist/controllers/placement-controller/src/placement-controller.js +129 -0
- package/dist/controllers/placement-controller/src/placement-controller.js.map +1 -0
- package/dist/controllers/placement-controller/src/placement-conversion.d.ts +35 -0
- package/dist/controllers/placement-controller/src/placement-conversion.js +54 -0
- package/dist/controllers/placement-controller/src/placement-conversion.js.map +1 -0
- package/dist/controllers/placement-controller/src/types.d.ts +128 -0
- package/dist/controllers/placement-controller/src/types.js +29 -0
- package/dist/controllers/placement-controller/src/types.js.map +1 -0
- package/dist/controllers/slot-attribute-propagation-controller/index.d.ts +12 -0
- package/dist/controllers/slot-attribute-propagation-controller/index.js +2 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.d.ts +65 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js +33 -0
- package/dist/controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js.map +1 -0
- package/dist/controllers/slot-presence-controller/index.d.ts +12 -0
- package/dist/controllers/slot-presence-controller/index.js +2 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.d.ts +57 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js +44 -0
- package/dist/controllers/slot-presence-controller/src/slot-presence-controller.js.map +1 -0
- package/dist/controllers/slot-text-controller/index.d.ts +12 -0
- package/dist/controllers/slot-text-controller/index.js +2 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.d.ts +92 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js +53 -0
- package/dist/controllers/slot-text-controller/src/slot-text-controller.js.map +1 -0
- package/dist/directives/index.d.ts +15 -0
- package/dist/directives/index.js +3 -0
- package/dist/directives/pending-spinner/index.d.ts +12 -0
- package/dist/directives/pending-spinner/index.js +1 -0
- package/dist/directives/pending-spinner/src/pending-spinner.d.ts +22 -0
- package/dist/directives/pending-spinner/src/pending-spinner.js +39 -0
- package/dist/directives/pending-spinner/src/pending-spinner.js.map +1 -0
- package/dist/element/define-element.d.ts +16 -0
- package/dist/element/define-element.js +8 -0
- package/dist/element/define-element.js.map +1 -0
- package/dist/element/index.d.ts +14 -0
- package/dist/element/index.js +4 -0
- package/dist/element/spectrum-element.d.ts +69 -0
- package/dist/element/spectrum-element.js +85 -0
- package/dist/element/spectrum-element.js.map +1 -0
- package/dist/element/version.d.ts +19 -0
- package/dist/element/version.js +6 -0
- package/dist/element/version.js.map +1 -0
- package/dist/mixins/disabled-mixin.d.ts +30 -0
- package/dist/mixins/disabled-mixin.js +27 -0
- package/dist/mixins/disabled-mixin.js.map +1 -0
- package/dist/mixins/index.d.ts +16 -0
- package/dist/mixins/index.js +5 -0
- package/dist/mixins/linear-progress-mixin.d.ts +41 -0
- package/dist/mixins/linear-progress-mixin.js +115 -0
- package/dist/mixins/linear-progress-mixin.js.map +1 -0
- package/dist/mixins/pending-mixin.d.ts +45 -0
- package/dist/mixins/pending-mixin.js +50 -0
- package/dist/mixins/pending-mixin.js.map +1 -0
- package/dist/mixins/sized-mixin.d.ts +49 -0
- package/dist/mixins/sized-mixin.js +42 -0
- package/dist/mixins/sized-mixin.js.map +1 -0
- package/dist/utils/actual-placement.d.ts +10 -0
- package/dist/utils/actual-placement.js +8 -0
- package/dist/utils/actual-placement.js.map +1 -0
- package/dist/utils/capitalize.d.ts +26 -0
- package/dist/utils/capitalize.js +8 -0
- package/dist/utils/capitalize.js.map +1 -0
- package/dist/utils/deep-contains.d.ts +26 -0
- package/dist/utils/deep-contains.js +14 -0
- package/dist/utils/deep-contains.js.map +1 -0
- package/dist/utils/dev-validation.d.ts +88 -0
- package/dist/utils/dev-validation.js +33 -0
- package/dist/utils/dev-validation.js.map +1 -0
- package/dist/utils/dismissible-stack.d.ts +26 -0
- package/dist/utils/dismissible-stack.js +16 -0
- package/dist/utils/dismissible-stack.js.map +1 -0
- package/dist/utils/focusable-selectors.d.ts +43 -0
- package/dist/utils/focusable-selectors.js +18 -0
- package/dist/utils/focusable-selectors.js.map +1 -0
- package/dist/utils/get-active-element.d.ts +31 -0
- package/dist/utils/get-active-element.js +11 -0
- package/dist/utils/get-active-element.js.map +1 -0
- package/dist/utils/get-label-from-slot.d.ts +12 -0
- package/dist/utils/get-label-from-slot.js +10 -0
- package/dist/utils/get-label-from-slot.js.map +1 -0
- package/dist/utils/index.d.ts +22 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/is-focus-visible-in-tree.d.ts +33 -0
- package/dist/utils/is-focus-visible-in-tree.js +11 -0
- package/dist/utils/is-focus-visible-in-tree.js.map +1 -0
- package/dist/utils/resolve-trigger.d.ts +42 -0
- package/dist/utils/resolve-trigger.js +23 -0
- package/dist/utils/resolve-trigger.js.map +1 -0
- package/dist/utils/transition.d.ts +53 -0
- package/dist/utils/transition.js +26 -0
- package/dist/utils/transition.js.map +1 -0
- package/package.json +644 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
|
|
2
|
+
import { SlotAttributePropagationController as t } from "../../controllers/slot-attribute-propagation-controller/src/slot-attribute-propagation-controller.js";
|
|
3
|
+
import { SlotTextController as n } from "../../controllers/slot-text-controller/src/slot-text-controller.js";
|
|
4
|
+
import { CARD_DENSITIES as r, CARD_VALID_SIZES as i, CARD_VARIANTS as a, SWC_CARD_CLICK_EVENT as o } from "./Card.types.js";
|
|
5
|
+
import { property as s } from "lit/decorators.js";
|
|
6
|
+
import { SpectrumElement as c } from "@adobe/spectrum-wc-core/element/index.js";
|
|
7
|
+
import { SizedMixin as l } from "@adobe/spectrum-wc-core/mixins/index.js";
|
|
8
|
+
import { isDebug as u, validateEnum as d, warnIf as f } from "@adobe/spectrum-wc-core/utils/index.js";
|
|
9
|
+
//#region components/card/Card.base.ts
|
|
10
|
+
var p, m = class e extends l(c, { validSizes: i }) {
|
|
11
|
+
constructor(...r) {
|
|
12
|
+
super(...r), this.variant = "primary", this.density = "regular", this.titleAsLink = !1, this.selectable = !1, this._sizePropagation = new t(this, {
|
|
13
|
+
attribute: "size",
|
|
14
|
+
getValue: () => e.getSmallerSize(this.size),
|
|
15
|
+
slotName: "actions"
|
|
16
|
+
}), this.slotText = new n(this), this.handleActionsSlotChange = () => {
|
|
17
|
+
this._sizePropagation.propagate(), this.checkActionsSupport();
|
|
18
|
+
}, this.handleSurfaceClick = (t) => {
|
|
19
|
+
var n;
|
|
20
|
+
if (!this.titleAsLink && !this.selectable || t instanceof MouseEvent && ((n = document.getSelection()) == null ? void 0 : n.isCollapsed) === !1) return;
|
|
21
|
+
let r = t.composedPath(), i = r.slice(0, r.indexOf(this)), a = this.getActionsSlotElement();
|
|
22
|
+
if (!(a && i.includes(a) || i.some(e.isFocusable))) {
|
|
23
|
+
if (this.titleAsLink) {
|
|
24
|
+
var s;
|
|
25
|
+
(s = this.getTitleLinkElement()) == null || s.click();
|
|
26
|
+
}
|
|
27
|
+
this.selectable && this.dispatchEvent(new Event(o, {
|
|
28
|
+
bubbles: !0,
|
|
29
|
+
composed: !0
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
}, this.handleSelectableKeydown = (e) => {
|
|
33
|
+
(e.code === "Enter" || e.code === "Space") && (e.preventDefault(), this.handleSurfaceClick(e));
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
get slotHasContent() {
|
|
37
|
+
return this.slotText.hasContent;
|
|
38
|
+
}
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
super.connectedCallback(), this.addEventListener("click", this.handleSurfaceClick);
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
this.removeEventListener("click", this.handleSurfaceClick), this.removeEventListener("keydown", this.handleSelectableKeydown), super.disconnectedCallback();
|
|
44
|
+
}
|
|
45
|
+
firstUpdated(e) {
|
|
46
|
+
var t;
|
|
47
|
+
super.firstUpdated(e), (t = this.renderRoot) == null || (t = t.querySelector("slot[name=\"actions\"]")) == null || t.addEventListener("slotchange", this.handleActionsSlotChange);
|
|
48
|
+
}
|
|
49
|
+
update(e) {
|
|
50
|
+
let { VARIANTS: t, DENSITIES: n } = this.constructor;
|
|
51
|
+
e.has("variant") && d(this, {
|
|
52
|
+
prop: "variant",
|
|
53
|
+
value: this.variant,
|
|
54
|
+
valid: t,
|
|
55
|
+
url: "https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs"
|
|
56
|
+
}), e.has("density") && d(this, {
|
|
57
|
+
prop: "density",
|
|
58
|
+
value: this.density,
|
|
59
|
+
valid: n,
|
|
60
|
+
url: "https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs",
|
|
61
|
+
options: { level: "low" }
|
|
62
|
+
}), super.update(e);
|
|
63
|
+
}
|
|
64
|
+
updated(e) {
|
|
65
|
+
super.updated(e), e.has("selectable") && (this.selectable ? (this.setAttribute("tabindex", "0"), this.addEventListener("keydown", this.handleSelectableKeydown)) : (this.removeAttribute("tabindex"), this.removeEventListener("keydown", this.handleSelectableKeydown))), f(this, e.has("titleAsLink") && this.titleAsLink && !this.getTitleLinkElement(), `<${this.localName}> has "title-as-link" set but no link element was found in the "title" slot.`, "https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs", {
|
|
66
|
+
level: "high",
|
|
67
|
+
issues: ["title-as-link"]
|
|
68
|
+
}), e.has("size") && this.checkActionsSupport();
|
|
69
|
+
}
|
|
70
|
+
getTitleSlotElement() {
|
|
71
|
+
var e, t;
|
|
72
|
+
return (e = (t = this.renderRoot) == null ? void 0 : t.querySelector("slot[name=\"title\"]")) == null ? null : e;
|
|
73
|
+
}
|
|
74
|
+
getActionsSlotElement() {
|
|
75
|
+
var e, t;
|
|
76
|
+
return (e = (t = this.renderRoot) == null ? void 0 : t.querySelector("slot[name=\"actions\"]")) == null ? null : e;
|
|
77
|
+
}
|
|
78
|
+
get actionsSupported() {
|
|
79
|
+
return this.size !== "xs";
|
|
80
|
+
}
|
|
81
|
+
checkActionsSupport() {
|
|
82
|
+
var e, t;
|
|
83
|
+
u() && f(this, !this.actionsSupported && ((e = (t = this.getActionsSlotElement()) == null ? void 0 : t.assignedElements({ flatten: !0 }).length) == null ? 0 : e) > 0, `<${this.localName}> has content in the "actions" slot, but actions are not supported for this card (size="${this.size}").`, "https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs", {
|
|
84
|
+
level: "medium",
|
|
85
|
+
issues: ["actions"]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
getTitleLinkElement() {
|
|
89
|
+
var e;
|
|
90
|
+
let t = (e = this.getTitleSlotElement()) == null ? void 0 : e.assignedElements({ flatten: !0 });
|
|
91
|
+
for (let e of t == null ? [] : t) {
|
|
92
|
+
if (e instanceof HTMLAnchorElement && e.href) return e;
|
|
93
|
+
let t = e.querySelector("a[href]");
|
|
94
|
+
if (t) return t;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
static isFocusable(e) {
|
|
99
|
+
return e instanceof HTMLElement && e.tabIndex >= 0;
|
|
100
|
+
}
|
|
101
|
+
static getSmallerSize(e) {
|
|
102
|
+
let t = i.indexOf(e);
|
|
103
|
+
return i[Math.max(t - 1, 0)];
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
p = m, p.VARIANTS = a, p.DENSITIES = r, e([s({
|
|
107
|
+
type: String,
|
|
108
|
+
reflect: !0
|
|
109
|
+
})], m.prototype, "variant", void 0), e([s({
|
|
110
|
+
type: String,
|
|
111
|
+
reflect: !0
|
|
112
|
+
})], m.prototype, "density", void 0), e([s({
|
|
113
|
+
type: Boolean,
|
|
114
|
+
reflect: !0,
|
|
115
|
+
attribute: "title-as-link"
|
|
116
|
+
})], m.prototype, "titleAsLink", void 0), e([s({
|
|
117
|
+
type: Boolean,
|
|
118
|
+
reflect: !0
|
|
119
|
+
})], m.prototype, "selectable", void 0);
|
|
120
|
+
//#endregion
|
|
121
|
+
export { m as CardBase };
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=Card.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.base.js","names":[],"sources":["../../../components/card/Card.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\nimport {\n type ElementSize,\n SizedMixin,\n} from '@adobe/spectrum-wc-core/mixins/index.js';\nimport {\n isDebug,\n validateEnum,\n warnIf,\n} from '@adobe/spectrum-wc-core/utils/index.js';\n\nimport { SlotAttributePropagationController } from '../../controllers/slot-attribute-propagation-controller/index.js';\nimport { SlotTextController } from '../../controllers/slot-text-controller/index.js';\nimport {\n CARD_DENSITIES,\n CARD_VALID_SIZES,\n CARD_VARIANTS,\n type CardDensity,\n type CardSize,\n type CardVariant,\n SWC_CARD_CLICK_EVENT,\n} from './Card.types.js';\n\n/**\n * Abstract base class for all card-family components. Owns the semantics\n * shared across every card type: sizing, visual variant, and density.\n *\n * @attribute {ElementSize} size - The size of the card.\n *\n * @fires swc-card-click - Dispatched when a `selectable` card is activated (click, Enter, or Space).\n *\n * @slot preview - Primary preview content\n * @slot title - Card title\n * @slot actions - Optional action controls\n * @slot description - Supporting description text\n * @slot footer - Optional footer content\n * @slot - Additional body content\n *\n * @cssprop --swc-card-base-max-inline-size - Maximum inline size of the card. Defaults to 280px, overridden per size.\n * @cssprop --swc-card-base-border-radius - Corner radius of the card. Defaults to the extra-large corner-radius token, overridden per size.\n * @cssprop --swc-card-base-box-shadow - Box shadow (elevation) of the card. Defaults to the emphasized drop-shadow token; overridden by the tertiary variant, selectable focus, and title-as-link/selectable hover.\n * @cssprop --swc-card-base-background-color - Background color of the card. Defaults to the layer-2 background token; overridden by the secondary, tertiary, and quiet variants.\n * @cssprop --swc-card-base-preview-aspect-ratio - Aspect ratio of the preview slot. Defaults to 3/2.\n * @cssprop --swc-card-base-title-font-size - Font size of the title slot. Defaults to the medium font-size token, overridden per size.\n * @cssprop --swc-card-base-title-line-height - Line height of the title slot. Defaults to the medium line-height token, overridden per size.\n * @cssprop --swc-card-base-description-font-size - Font size of the description slot and default slot content. Defaults to a smaller font-size token, overridden per size.\n * @cssprop --swc-card-base-action-component-height - Height used to vertically balance slotted actions content. Defaults to the smallest component-height token, overridden per size.\n * @cssprop --swc-card-base-content-header-gap - Column gap between the title and actions slots. Defaults to the medium base-gap token, overridden per size.\n * @cssprop --swc-card-base-content-padding - Padding of the content region. Defaults to the medium container-padding token; overridden by density.\n * @cssprop --swc-card-base-content-padding-regular - Content padding used at the default (regular) density, per size.\n * @cssprop --swc-card-base-content-padding-compact - Content padding used at compact density, per size.\n * @cssprop --swc-card-base-content-padding-spacious - Content padding used at spacious density, per size.\n */\nexport abstract class CardBase extends SizedMixin(SpectrumElement, {\n validSizes: CARD_VALID_SIZES,\n}) {\n // ─────────────────────────\n // API TO OVERRIDE\n // ─────────────────────────\n\n /**\n * @internal\n */\n static readonly VARIANTS: readonly CardVariant[] = CARD_VARIANTS;\n\n /**\n * @internal\n */\n static readonly DENSITIES: readonly CardDensity[] = CARD_DENSITIES;\n\n // ──────────────────\n // SHARED API\n // ──────────────────\n\n /**\n * The visual variant of the card.\n *\n * @default primary\n */\n @property({ type: String, reflect: true })\n public variant: CardVariant = 'primary';\n\n /**\n * The density of the card, controlling internal spacing and gaps.\n *\n * @default regular\n */\n @property({ type: String, reflect: true })\n public density: CardDensity = 'regular';\n\n /**\n * Indicates the consumer has wrapped their `title` slot content in a real\n * link. Extends that link's hit area to cover the card surface while\n * leaving navigation entirely consumer-owned; Card accepts no `href`.\n */\n @property({ type: Boolean, reflect: true, attribute: 'title-as-link' })\n public titleAsLink = false;\n\n /**\n * Makes the card focusable and captures surface clicks (excluding nested\n * interactive targets) to dispatch a `swc-card-click` event, independent\n * of `titleAsLink`.\n *\n * @todo No ARIA role is set yet; deferred until a future `CardView`\n * selection model determines the appropriate role.\n */\n @property({ type: Boolean, reflect: true })\n public selectable = false;\n\n // ──────────────────────\n // IMPLEMENTATION\n // ──────────────────────\n\n /**\n * Keeps a slotted action control's `size` one step smaller than the\n * card's own `size`.\n */\n private readonly _sizePropagation = new SlotAttributePropagationController(\n this,\n {\n attribute: 'size',\n getValue: () => CardBase.getSmallerSize(this.size),\n slotName: 'actions',\n }\n );\n\n /**\n * Observes whether the default slot has meaningful content. Each concrete\n * card's `render()` must bind `@slotchange=${this.slotText.handleSlotChange}`\n * on the default slot (via `renderCardTemplate`'s `onDefaultSlotChange`) for\n * changes after the first render to be tracked.\n *\n * @internal\n */\n protected slotText = new SlotTextController(this);\n\n /**\n * Whether the default slot has meaningful content. Consumed by each concrete\n * card's `render()` (through `renderCardTemplate`'s `hasDefaultSlotContent`)\n * to toggle the `--hasDefault` class.\n *\n * @internal\n */\n protected get slotHasContent(): boolean {\n return this.slotText.hasContent;\n }\n\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('click', this.handleSurfaceClick);\n }\n\n public override disconnectedCallback(): void {\n this.removeEventListener('click', this.handleSurfaceClick);\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n super.disconnectedCallback();\n }\n\n protected override firstUpdated(changedProperties: PropertyValues): void {\n super.firstUpdated(changedProperties);\n // renderCardTemplate() doesn't take a slotchange callback, so the\n // listener is attached imperatively rather than declaratively in the\n // template; the slot node itself persists across re-renders.\n this.renderRoot\n ?.querySelector('slot[name=\"actions\"]')\n ?.addEventListener('slotchange', this.handleActionsSlotChange);\n }\n\n protected override update(changedProperties: PropertyValues): void {\n const { VARIANTS, DENSITIES } = this.constructor as typeof CardBase;\n\n if (changedProperties.has('variant')) {\n validateEnum(this, {\n prop: 'variant',\n value: this.variant,\n valid: VARIANTS,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs',\n });\n }\n\n if (changedProperties.has('density')) {\n validateEnum(this, {\n prop: 'density',\n value: this.density,\n valid: DENSITIES,\n url: 'https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs',\n options: { level: 'low' },\n });\n }\n\n super.update(changedProperties);\n }\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('selectable')) {\n if (this.selectable) {\n this.setAttribute('tabindex', '0');\n this.addEventListener('keydown', this.handleSelectableKeydown);\n } else {\n this.removeAttribute('tabindex');\n this.removeEventListener('keydown', this.handleSelectableKeydown);\n }\n }\n\n warnIf(\n this,\n changedProperties.has('titleAsLink') &&\n this.titleAsLink &&\n !this.getTitleLinkElement(),\n `<${this.localName}> has \"title-as-link\" set but no link element was found in the \"title\" slot.`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs',\n { level: 'high', issues: ['title-as-link'] }\n );\n\n if (changedProperties.has('size')) {\n this.checkActionsSupport();\n }\n }\n\n /**\n * @internal\n *\n * The card's own `title` slot element.\n */\n protected getTitleSlotElement(): HTMLSlotElement | null {\n return this.renderRoot?.querySelector('slot[name=\"title\"]') ?? null;\n }\n\n /**\n * @internal\n *\n * The card's own `actions` slot element.\n */\n protected getActionsSlotElement(): HTMLSlotElement | null {\n return this.renderRoot?.querySelector('slot[name=\"actions\"]') ?? null;\n }\n\n /**\n * Whether the `actions` slot is supported for this card's current state.\n * `xs` cards don't have room for it. Concrete classes may override this\n * to exclude the slot for other reasons, independent of size.\n */\n protected get actionsSupported(): boolean {\n return this.size !== 'xs';\n }\n\n /**\n * @internal\n *\n * Warns in dev mode when the `actions` slot has content but isn't\n * supported for the current state. Visual suppression is handled in\n * CSS, not here.\n */\n private checkActionsSupport(): void {\n if (!isDebug()) {\n return;\n }\n warnIf(\n this,\n !this.actionsSupported &&\n (this.getActionsSlotElement()?.assignedElements({ flatten: true })\n .length ?? 0) > 0,\n `<${this.localName}> has content in the \"actions\" slot, but actions are not supported for this card (size=\"${this.size}\").`,\n 'https://spectrum-web-components.adobe.com/?path=/docs/components-card--docs',\n { level: 'medium', issues: ['actions'] }\n );\n }\n\n /**\n * @internal\n *\n * The `title` slot's link: either the assigned element itself\n * (`<a slot=\"title\" href=\"...\">`) or an anchor nested inside a wrapper\n * (`<span slot=\"title\"><a href=\"...\">`). Requires `href`.\n */\n protected getTitleLinkElement(): HTMLAnchorElement | null {\n const assigned = this.getTitleSlotElement()?.assignedElements({\n flatten: true,\n });\n for (const element of assigned ?? []) {\n if (element instanceof HTMLAnchorElement && element.href) {\n return element;\n }\n const nested = element.querySelector<HTMLAnchorElement>('a[href]');\n if (nested) {\n return nested;\n }\n }\n return null;\n }\n\n /**\n * @internal\n *\n * Whether `node` has its own interaction/focus semantics, via the\n * `tabIndex` IDL property rather than the `tabindex` attribute; this\n * also correctly excludes `tabindex=\"-1\"` and disabled controls.\n */\n private static isFocusable(node: EventTarget): boolean {\n return node instanceof HTMLElement && node.tabIndex >= 0;\n }\n\n /**\n * @internal\n *\n * The size one step below `size` in `CARD_VALID_SIZES`, clamped at the\n * smallest size.\n */\n private static getSmallerSize(size: ElementSize): CardSize {\n const index = CARD_VALID_SIZES.indexOf(size as CardSize);\n return CARD_VALID_SIZES[Math.max(index - 1, 0)];\n }\n\n /**\n * Re-propagates the `actions` slot's `size` for elements assigned after\n * the initial render, wired to the slot's `slotchange` in\n * `firstUpdated()`.\n */\n protected readonly handleActionsSlotChange = (): void => {\n this._sizePropagation.propagate();\n this.checkActionsSupport();\n };\n\n /**\n * Proxies a qualifying surface click to `titleAsLink`'s link and/or\n * dispatches `swc-card-click` for `selectable`, after filtering out\n * clicks that landed on a nested interactive target or followed a\n * text-selection drag.\n */\n protected readonly handleSurfaceClick = (event: Event): void => {\n if (!this.titleAsLink && !this.selectable) {\n return;\n }\n // A text-selection drag still fires `click` on mouseup; a non-collapsed\n // selection at that point means the user was selecting text, not\n // clicking through the card.\n if (\n event instanceof MouseEvent &&\n document.getSelection()?.isCollapsed === false\n ) {\n return;\n }\n const path = event.composedPath();\n const precedingPath = path.slice(0, path.indexOf(this));\n const actionsSlot = this.getActionsSlotElement();\n const hitInteractiveTarget =\n // The actions slot is always excluded, since it's contractually\n // for interactive content regardless of whether a control reflects\n // focusability correctly.\n (actionsSlot && precedingPath.includes(actionsSlot)) ||\n precedingPath.some(CardBase.isFocusable);\n if (hitInteractiveTarget) {\n return;\n }\n if (this.titleAsLink) {\n this.getTitleLinkElement()?.click();\n }\n if (this.selectable) {\n this.dispatchEvent(\n new Event(SWC_CARD_CLICK_EVENT, { bubbles: true, composed: true })\n );\n }\n };\n\n /**\n * Enter and Space both activate the card, even though a bare link\n * conventionally responds to Enter only; the card's own activation\n * contract takes precedence once `selectable` makes it the focused\n * target.\n */\n protected readonly handleSelectableKeydown = (event: KeyboardEvent): void => {\n if (event.code === 'Enter' || event.code === 'Space') {\n event.preventDefault();\n this.handleSurfaceClick(event);\n }\n };\n}\n"],"mappings":";;;;;;;;;OAoEsB,IAAtB,MAAsB,UAAiB,EAAW,GAAiB,EACjE,YAAY,GACb,CAAC,CAAC;;8BAyB6B,0BAQA,8BAQT,sBAWD,4BAUgB,IAAI,EACtC,MACA;GACE,WAAW;GACX,gBAAgB,EAAS,eAAe,KAAK,KAAK;GAClD,UAAU;GACX,CACF,kBAUoB,IAAI,EAAmB,KAAK,uCA0LQ;AAEvD,GADA,KAAK,iBAAiB,WAAW,EACjC,KAAK,qBAAqB;gCASa,MAAuB;;AAO9D,OANI,CAAC,KAAK,eAAe,CAAC,KAAK,cAO7B,aAAiB,gBAAA,IACjB,SAAS,cAAc,KAAA,OAAA,KAAA,IAAA,EAAE,iBAAgB,GAEzC;GAEF,IAAM,IAAO,EAAM,cAAc,EAC3B,IAAgB,EAAK,MAAM,GAAG,EAAK,QAAQ,KAAK,CAAC,EACjD,IAAc,KAAK,uBAAuB;AAK7C,cAAe,EAAc,SAAS,EAAY,IACnD,EAAc,KAAK,EAAS,YAAY,GAI1C;QAAI,KAAK,aAAa;;AACpB,MAAA,IAAA,KAAK,qBAAqB,KAAA,QAAA,EAAE,OAAO;;AAErC,IAAI,KAAK,cACP,KAAK,cACH,IAAI,MAAM,GAAsB;KAAE,SAAS;KAAM,UAAU;KAAM,CAAC,CACnE;;qCAUyC,MAA+B;AAC3E,IAAI,EAAM,SAAS,WAAW,EAAM,SAAS,aAC3C,EAAM,gBAAgB,EACtB,KAAK,mBAAmB,EAAM;;;CAxOlC,IAAc,iBAA0B;AACtC,SAAO,KAAK,SAAS;;CAGvB,oBAA0C;AAExC,EADA,MAAM,mBAAmB,EACzB,KAAK,iBAAiB,SAAS,KAAK,mBAAmB;;CAGzD,uBAA6C;AAG3C,EAFA,KAAK,oBAAoB,SAAS,KAAK,mBAAmB,EAC1D,KAAK,oBAAoB,WAAW,KAAK,wBAAwB,EACjE,MAAM,sBAAsB;;CAG9B,aAAgC,GAAyC;;AAKvE,EAJA,MAAM,aAAa,EAAkB,GAIrC,IAAA,KAAK,eAAA,SAAA,IAAA,EACD,cAAc,yBAAuB,KAAA,QAAA,EACrC,iBAAiB,cAAc,KAAK,wBAAwB;;CAGlE,OAA0B,GAAyC;EACjE,IAAM,EAAE,aAAU,iBAAc,KAAK;AAqBrC,EAnBI,EAAkB,IAAI,UAAU,IAClC,EAAa,MAAM;GACjB,MAAM;GACN,OAAO,KAAK;GACZ,OAAO;GACP,KAAK;GACN,CAAC,EAGA,EAAkB,IAAI,UAAU,IAClC,EAAa,MAAM;GACjB,MAAM;GACN,OAAO,KAAK;GACZ,OAAO;GACP,KAAK;GACL,SAAS,EAAE,OAAO,OAAO;GAC1B,CAAC,EAGJ,MAAM,OAAO,EAAkB;;CAGjC,QAA2B,GAAyC;AAuBlE,EAtBA,MAAM,QAAQ,EAAkB,EAE5B,EAAkB,IAAI,aAAa,KACjC,KAAK,cACP,KAAK,aAAa,YAAY,IAAI,EAClC,KAAK,iBAAiB,WAAW,KAAK,wBAAwB,KAE9D,KAAK,gBAAgB,WAAW,EAChC,KAAK,oBAAoB,WAAW,KAAK,wBAAwB,IAIrE,EACE,MACA,EAAkB,IAAI,cAAc,IAClC,KAAK,eACL,CAAC,KAAK,qBAAqB,EAC7B,IAAI,KAAK,UAAU,+EACnB,+EACA;GAAE,OAAO;GAAQ,QAAQ,CAAC,gBAAgB;GAAE,CAC7C,EAEG,EAAkB,IAAI,OAAO,IAC/B,KAAK,qBAAqB;;CAS9B,sBAAwD;;AACtD,UAAA,KAAA,IAAO,KAAK,eAAA,OAAA,KAAA,IAAA,EAAY,cAAc,uBAAqB,KAAA,OAAI,OAAJ;;CAQ7D,wBAA0D;;AACxD,UAAA,KAAA,IAAO,KAAK,eAAA,OAAA,KAAA,IAAA,EAAY,cAAc,yBAAuB,KAAA,OAAI,OAAJ;;CAQ/D,IAAc,mBAA4B;AACxC,SAAO,KAAK,SAAS;;CAUvB,sBAAoC;;AAC7B,KAAS,IAGd,EACE,MACA,CAAC,KAAK,sBAAA,KAAA,IACH,KAAK,uBAAuB,KAAA,OAAA,KAAA,IAAA,EAAE,iBAAiB,EAAE,SAAS,IAAM,CAAC,CAC/D,WAAA,OAAU,IAAV,KAAe,GACpB,IAAI,KAAK,UAAU,0FAA0F,KAAK,KAAK,MACvH,+EACA;GAAE,OAAO;GAAU,QAAQ,CAAC,UAAU;GAAE,CACzC;;CAUH,sBAA0D;;EACxD,IAAM,KAAA,IAAW,KAAK,qBAAqB,KAAA,OAAA,KAAA,IAAA,EAAE,iBAAiB,EAC5D,SAAS,IACV,CAAC;AACF,OAAK,IAAM,KAAW,KAAA,OAAY,EAAE,GAAd,GAAgB;AACpC,OAAI,aAAmB,qBAAqB,EAAQ,KAClD,QAAO;GAET,IAAM,IAAS,EAAQ,cAAiC,UAAU;AAClE,OAAI,EACF,QAAO;;AAGX,SAAO;;CAUT,OAAe,YAAY,GAA4B;AACrD,SAAO,aAAgB,eAAe,EAAK,YAAY;;CASzD,OAAe,eAAe,GAA6B;EACzD,IAAM,IAAQ,EAAiB,QAAQ,EAAiB;AACxD,SAAO,EAAiB,KAAK,IAAI,IAAQ,GAAG,EAAE;;;oBAzPG,iBAKC,MAWnD,EAAS;CAAE,MAAM;CAAQ,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,WAAA,KAAA,EAAA,KAQzC,EAAS;CAAE,MAAM;CAAQ,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,WAAA,KAAA,EAAA,KAQzC,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;CAAiB,CAAC,CAAA,EAAA,EAAA,WAAA,eAAA,KAAA,EAAA,KAWtE,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,cAAA,KAAA,EAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CARD_VALID_SIZES: readonly ["xs", "s", "m", "l", "xl"];
|
|
13
|
+
export declare const CARD_VARIANTS: readonly ["primary", "secondary", "tertiary", "quiet"];
|
|
14
|
+
export declare const CARD_DENSITIES: readonly ["compact", "regular", "spacious"];
|
|
15
|
+
export declare const SWC_CARD_CLICK_EVENT: "swc-card-click";
|
|
16
|
+
export type CardSize = (typeof CARD_VALID_SIZES)[number];
|
|
17
|
+
export type CardVariant = (typeof CARD_VARIANTS)[number];
|
|
18
|
+
export type CardDensity = (typeof CARD_DENSITIES)[number];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region components/card/Card.types.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"xs",
|
|
4
|
+
"s",
|
|
5
|
+
"m",
|
|
6
|
+
"l",
|
|
7
|
+
"xl"
|
|
8
|
+
], t = [
|
|
9
|
+
"primary",
|
|
10
|
+
"secondary",
|
|
11
|
+
"tertiary",
|
|
12
|
+
"quiet"
|
|
13
|
+
], n = [
|
|
14
|
+
"compact",
|
|
15
|
+
"regular",
|
|
16
|
+
"spacious"
|
|
17
|
+
], r = "swc-card-click";
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as CARD_DENSITIES, e as CARD_VALID_SIZES, t as CARD_VARIANTS, r as SWC_CARD_CLICK_EVENT };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=Card.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.types.js","names":[],"sources":["../../../components/card/Card.types.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { ElementSize } from '@adobe/spectrum-wc-core/mixins/index.js';\n\n// ──────────────────\n// SHARED\n// ──────────────────\n\nexport const CARD_VALID_SIZES = [\n 'xs',\n 's',\n 'm',\n 'l',\n 'xl',\n] as const satisfies readonly ElementSize[];\n\nexport const CARD_VARIANTS = [\n 'primary',\n 'secondary',\n 'tertiary',\n 'quiet',\n] as const;\n\nexport const CARD_DENSITIES = ['compact', 'regular', 'spacious'] as const;\n\nexport const SWC_CARD_CLICK_EVENT = 'swc-card-click' as const;\n\n// ──────────────────\n// TYPES\n// ──────────────────\n\nexport type CardSize = (typeof CARD_VALID_SIZES)[number];\nexport type CardVariant = (typeof CARD_VARIANTS)[number];\nexport type CardDensity = (typeof CARD_DENSITIES)[number];\n"],"mappings":";AAkBA,IAAa,IAAmB;CAC9B;CACA;CACA;CACA;CACA;CACD,EAEY,IAAgB;CAC3B;CACA;CACA;CACA;CACD,EAEY,IAAiB;CAAC;CAAW;CAAW;CAAW,EAEnD,IAAuB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from './Card.base.js';
|
|
13
|
+
export * from './Card.types.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CARD_DENSITIES as e, CARD_VALID_SIZES as t, CARD_VARIANTS as n, SWC_CARD_CLICK_EVENT as r } from "./Card.types.js";
|
|
2
|
+
import { CardBase as i } from "./Card.base.js";
|
|
3
|
+
export { e as CARD_DENSITIES, t as CARD_VALID_SIZES, n as CARD_VARIANTS, i as CardBase, r as SWC_CARD_CLICK_EVENT };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { SpectrumElement } from '../../element/index.js';
|
|
3
|
+
import { ColorHandleProperties } from './ColorHandle.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* A non-interactive primitive: a draggable dot rendered on top of a color
|
|
6
|
+
* area, slider, or wheel that shows the currently picked color (over an
|
|
7
|
+
* opacity checkerboard) and pops a loupe on touch.
|
|
8
|
+
*
|
|
9
|
+
* The handle owns no ARIA role/name and is not independently focusable;
|
|
10
|
+
* accessibility is provided by the parent color picker. Its only net-new a11y
|
|
11
|
+
* obligation is WCAG 1.4.11 non-text contrast via an adaptive border, applied
|
|
12
|
+
* in the rendering layer.
|
|
13
|
+
*
|
|
14
|
+
* @element swc-color-handle
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class ColorHandleBase extends SpectrumElement implements ColorHandleProperties {
|
|
17
|
+
/**
|
|
18
|
+
* The CSS color value shown inside the handle. Supports any valid CSS color
|
|
19
|
+
* string, including alpha transparency (which reveals the checkerboard).
|
|
20
|
+
*
|
|
21
|
+
* Default is semi-transparent red so the opacity checkerboard is visible
|
|
22
|
+
* when the component is rendered without a `color` attribute.
|
|
23
|
+
*/
|
|
24
|
+
color: string;
|
|
25
|
+
/** Reflected. Suppresses the loupe (`open && !disabled`). */
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Reflected. Set by the parent color component when the parent picker is
|
|
29
|
+
* focused (keyboard or programmatic); enlarges the handle as the focus
|
|
30
|
+
* indicator.
|
|
31
|
+
*/
|
|
32
|
+
focused: boolean;
|
|
33
|
+
/** Reflected. Shows the built-in loupe; auto-toggled by touch pointers. */
|
|
34
|
+
open: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Reflected. `true` shows the inner color swatch (1st-gen behavior);
|
|
37
|
+
* `false` renders an outline-only handle.
|
|
38
|
+
*/
|
|
39
|
+
fill: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The adaptive dark-border opacity for the current `color`, derived by the
|
|
42
|
+
* white-first strategy so the handle chrome meets WCAG 1.4.11 (≥3:1) across
|
|
43
|
+
* the color spectrum. The rendering layer applies this to the dark borders.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
protected get borderAlpha(): number;
|
|
48
|
+
private handlePointerdown;
|
|
49
|
+
private handlePointerup;
|
|
50
|
+
protected firstUpdated(changed: PropertyValues): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
|
|
2
|
+
import { computeBorderAlpha as t } from "./color-contrast.js";
|
|
3
|
+
import { property as n } from "lit/decorators.js";
|
|
4
|
+
import { SpectrumElement as r } from "@adobe/spectrum-wc-core/element/index.js";
|
|
5
|
+
//#region components/color-handle/ColorHandle.base.ts
|
|
6
|
+
var i = class extends r {
|
|
7
|
+
constructor(...e) {
|
|
8
|
+
super(...e), this.color = "rgba(255, 0, 0, 0.5)", this.disabled = !1, this.focused = !1, this.open = !1, this.fill = !0;
|
|
9
|
+
}
|
|
10
|
+
get borderAlpha() {
|
|
11
|
+
return t(this.color);
|
|
12
|
+
}
|
|
13
|
+
handlePointerdown(e) {
|
|
14
|
+
e.pointerType === "touch" && (this.open = !0, this.setPointerCapture(e.pointerId));
|
|
15
|
+
}
|
|
16
|
+
handlePointerup(e) {
|
|
17
|
+
e.pointerType === "touch" && (this.open = !1, this.releasePointerCapture(e.pointerId));
|
|
18
|
+
}
|
|
19
|
+
firstUpdated(e) {
|
|
20
|
+
super.firstUpdated(e), this.addEventListener("pointerdown", this.handlePointerdown), this.addEventListener("pointerup", this.handlePointerup), this.addEventListener("pointercancel", this.handlePointerup);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
e([n({ type: String })], i.prototype, "color", void 0), e([n({
|
|
24
|
+
type: Boolean,
|
|
25
|
+
reflect: !0
|
|
26
|
+
})], i.prototype, "disabled", void 0), e([n({
|
|
27
|
+
type: Boolean,
|
|
28
|
+
reflect: !0
|
|
29
|
+
})], i.prototype, "focused", void 0), e([n({
|
|
30
|
+
type: Boolean,
|
|
31
|
+
reflect: !0
|
|
32
|
+
})], i.prototype, "open", void 0), e([n({
|
|
33
|
+
type: Boolean,
|
|
34
|
+
reflect: !0
|
|
35
|
+
})], i.prototype, "fill", void 0);
|
|
36
|
+
//#endregion
|
|
37
|
+
export { i as ColorHandleBase };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=ColorHandle.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorHandle.base.js","names":[],"sources":["../../../components/color-handle/ColorHandle.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\n\nimport { computeBorderAlpha } from './color-contrast.js';\nimport { ColorHandleProperties } from './ColorHandle.types.js';\n\n/**\n * A non-interactive primitive: a draggable dot rendered on top of a color\n * area, slider, or wheel that shows the currently picked color (over an\n * opacity checkerboard) and pops a loupe on touch.\n *\n * The handle owns no ARIA role/name and is not independently focusable;\n * accessibility is provided by the parent color picker. Its only net-new a11y\n * obligation is WCAG 1.4.11 non-text contrast via an adaptive border, applied\n * in the rendering layer.\n *\n * @element swc-color-handle\n */\nexport abstract class ColorHandleBase\n extends SpectrumElement\n implements ColorHandleProperties\n{\n // ─────────────────\n // SHARED API\n // ─────────────────\n\n /**\n * The CSS color value shown inside the handle. Supports any valid CSS color\n * string, including alpha transparency (which reveals the checkerboard).\n *\n * Default is semi-transparent red so the opacity checkerboard is visible\n * when the component is rendered without a `color` attribute.\n */\n @property({ type: String })\n public color = 'rgba(255, 0, 0, 0.5)';\n\n /** Reflected. Suppresses the loupe (`open && !disabled`). */\n @property({ type: Boolean, reflect: true })\n public disabled = false;\n\n /**\n * Reflected. Set by the parent color component when the parent picker is\n * focused (keyboard or programmatic); enlarges the handle as the focus\n * indicator.\n */\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n /** Reflected. Shows the built-in loupe; auto-toggled by touch pointers. */\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * Reflected. `true` shows the inner color swatch (1st-gen behavior);\n * `false` renders an outline-only handle.\n */\n @property({ type: Boolean, reflect: true })\n public fill = true;\n\n // ──────────────────────────\n // ADAPTIVE CONTRAST\n // ──────────────────────────\n\n /**\n * The adaptive dark-border opacity for the current `color`, derived by the\n * white-first strategy so the handle chrome meets WCAG 1.4.11 (≥3:1) across\n * the color spectrum. The rendering layer applies this to the dark borders.\n *\n * @internal\n */\n protected get borderAlpha(): number {\n return computeBorderAlpha(this.color);\n }\n\n // ──────────────────────────\n // POINTER / TOUCH BEHAVIOR\n // ──────────────────────────\n\n // Only touch opens the loupe, so only touch reserves the pointer. Mouse and\n // stylus are left alone rather than capturing pointers nothing consumes.\n private handlePointerdown(event: PointerEvent): void {\n if (event.pointerType !== 'touch') {\n return;\n }\n this.open = true;\n this.setPointerCapture(event.pointerId);\n }\n\n private handlePointerup(event: PointerEvent): void {\n if (event.pointerType !== 'touch') {\n return;\n }\n this.open = false;\n this.releasePointerCapture(event.pointerId);\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.addEventListener('pointerdown', this.handlePointerdown);\n this.addEventListener('pointerup', this.handlePointerup);\n this.addEventListener('pointercancel', this.handlePointerup);\n }\n}\n"],"mappings":";;;;;AAgCA,IAAsB,IAAtB,cACU,EAEV;;4BAaiB,wCAIG,mBAQD,gBAIH,gBAOA;;CAad,IAAc,cAAsB;AAClC,SAAO,EAAmB,KAAK,MAAM;;CASvC,kBAA0B,GAA2B;AAC/C,IAAM,gBAAgB,YAG1B,KAAK,OAAO,IACZ,KAAK,kBAAkB,EAAM,UAAU;;CAGzC,gBAAwB,GAA2B;AAC7C,IAAM,gBAAgB,YAG1B,KAAK,OAAO,IACZ,KAAK,sBAAsB,EAAM,UAAU;;CAG7C,aAAgC,GAA+B;AAI7D,EAHA,MAAM,aAAa,EAAQ,EAC3B,KAAK,iBAAiB,eAAe,KAAK,kBAAkB,EAC5D,KAAK,iBAAiB,aAAa,KAAK,gBAAgB,EACxD,KAAK,iBAAiB,iBAAiB,KAAK,gBAAgB;;;GAnE7D,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,EAAA,EAAA,WAAA,SAAA,KAAA,EAAA,KAI1B,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,YAAA,KAAA,EAAA,KAQ1C,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,WAAA,KAAA,EAAA,KAI1C,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,QAAA,KAAA,EAAA,KAO1C,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,QAAA,KAAA,EAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The public property contract for `swc-color-handle`.
|
|
14
|
+
*
|
|
15
|
+
* Color Handle exposes no variant, size, or treatment enums; its surface is a
|
|
16
|
+
* single string color plus four boolean flags. This interface documents that
|
|
17
|
+
* contract; the concrete decorated properties live on `ColorHandleBase`.
|
|
18
|
+
*/
|
|
19
|
+
export interface ColorHandleProperties {
|
|
20
|
+
/** CSS color shown inside the handle; alpha reveals the opacity checkerboard. */
|
|
21
|
+
color: string;
|
|
22
|
+
/** Suppresses the loupe even when `open`. */
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
/** Parent-set focus flag; enlarges the handle as the focus indicator. */
|
|
25
|
+
focused: boolean;
|
|
26
|
+
/** Shows the built-in loupe; auto-toggled by touch. */
|
|
27
|
+
open: boolean;
|
|
28
|
+
/** `true` shows the inner color swatch; `false` renders an outline-only handle. */
|
|
29
|
+
fill: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Adaptive white-first dual-border contrast helper (SWC-2295, RSP-2021,
|
|
14
|
+
* SDS-16402).
|
|
15
|
+
*
|
|
16
|
+
* The color handle renders a dark border, a white separator, and a second dark
|
|
17
|
+
* border. To meet WCAG 1.4.11 non-text contrast (≥3:1) across the color
|
|
18
|
+
* spectrum, the opacity (α) of the dark borders is computed adaptively:
|
|
19
|
+
*
|
|
20
|
+
* - If the white separator already meets 3:1 against the underlying color, the
|
|
21
|
+
* dark borders stay at the floor opacity for softer, uniform chrome
|
|
22
|
+
* (white-first).
|
|
23
|
+
* - Otherwise α climbs from the floor until the dark border itself meets 3:1.
|
|
24
|
+
*
|
|
25
|
+
* **v1 limitation (A1):** the underlying color is approximated by the handle's
|
|
26
|
+
* own `color`, not by sampling the surrounding gradient. This is accurate on
|
|
27
|
+
* smooth gradients and approximate at steep or saturated edges.
|
|
28
|
+
*/
|
|
29
|
+
/** Minimum dark-border opacity (matches the 1st-gen static 42%). */
|
|
30
|
+
export declare const COLOR_HANDLE_ALPHA_FLOOR = 0.42;
|
|
31
|
+
/** WCAG 1.4.11 non-text contrast target. */
|
|
32
|
+
export declare const COLOR_HANDLE_CONTRAST_TARGET = 3;
|
|
33
|
+
type Rgb = [number, number, number];
|
|
34
|
+
/** Standard WCAG 2.2 contrast ratio between two opaque sRGB colors. */
|
|
35
|
+
export declare function contrastRatio(colorA: Rgb, colorB: Rgb): number;
|
|
36
|
+
/**
|
|
37
|
+
* Predicts the rendered color of a black border painted at opacity α over an
|
|
38
|
+
* opaque background.
|
|
39
|
+
*/
|
|
40
|
+
export declare function compositeBlackOver([r, g, b]: Rgb, alpha: number): Rgb;
|
|
41
|
+
/**
|
|
42
|
+
* The minimum α in `[floor, 1]` that makes a black border composited over
|
|
43
|
+
* `adjacency` meet `target` contrast against that same adjacency.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findMinAlpha(adjacency: Rgb, target?: number, floor?: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Computes the adaptive dark-border opacity for a handle showing `color`,
|
|
48
|
+
* using the white-first strategy. Returns the floor when `color` cannot be
|
|
49
|
+
* parsed so the border is never weaker than 1st-gen.
|
|
50
|
+
*/
|
|
51
|
+
export declare function computeBorderAlpha(color: string, { target, floor, }?: {
|
|
52
|
+
target?: number;
|
|
53
|
+
floor?: number;
|
|
54
|
+
}): number;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import e from "colorjs.io";
|
|
2
|
+
//#region components/color-handle/color-contrast.ts
|
|
3
|
+
var t = .42, n = 3, r = [
|
|
4
|
+
255,
|
|
5
|
+
255,
|
|
6
|
+
255
|
|
7
|
+
];
|
|
8
|
+
function i(e) {
|
|
9
|
+
let t = e / 255;
|
|
10
|
+
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
11
|
+
}
|
|
12
|
+
function a([e, t, n]) {
|
|
13
|
+
return .2126 * i(e) + .7152 * i(t) + .0722 * i(n);
|
|
14
|
+
}
|
|
15
|
+
function o(e, t) {
|
|
16
|
+
let n = a(e), r = a(t), i = Math.max(n, r), o = Math.min(n, r);
|
|
17
|
+
return (i + .05) / (o + .05);
|
|
18
|
+
}
|
|
19
|
+
function s([e, t, n], r) {
|
|
20
|
+
return [
|
|
21
|
+
Math.round(e * (1 - r)),
|
|
22
|
+
Math.round(t * (1 - r)),
|
|
23
|
+
Math.round(n * (1 - r))
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
function c(e, n = 3, r = t) {
|
|
27
|
+
for (let t = r; t <= 1.000000001; t += .01) if (o(s(e, t), e) >= n) return Math.min(1, Math.round(t * 100) / 100);
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
function l(t) {
|
|
31
|
+
try {
|
|
32
|
+
let [n, r, i] = new e(t).to("srgb").coords, a = (e) => Math.max(0, Math.min(255, Math.round(e * 255)));
|
|
33
|
+
return [
|
|
34
|
+
a(n),
|
|
35
|
+
a(r),
|
|
36
|
+
a(i)
|
|
37
|
+
];
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function u(e, { target: n = 3, floor: i = t } = {}) {
|
|
43
|
+
let a = l(e);
|
|
44
|
+
return !a || o(r, a) >= n ? i : c(a, n, i);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { t as COLOR_HANDLE_ALPHA_FLOOR, n as COLOR_HANDLE_CONTRAST_TARGET, s as compositeBlackOver, u as computeBorderAlpha, o as contrastRatio, c as findMinAlpha };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=color-contrast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-contrast.js","names":[],"sources":["../../../components/color-handle/color-contrast.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport Color from 'colorjs.io';\n\n/**\n * Adaptive white-first dual-border contrast helper (SWC-2295, RSP-2021,\n * SDS-16402).\n *\n * The color handle renders a dark border, a white separator, and a second dark\n * border. To meet WCAG 1.4.11 non-text contrast (≥3:1) across the color\n * spectrum, the opacity (α) of the dark borders is computed adaptively:\n *\n * - If the white separator already meets 3:1 against the underlying color, the\n * dark borders stay at the floor opacity for softer, uniform chrome\n * (white-first).\n * - Otherwise α climbs from the floor until the dark border itself meets 3:1.\n *\n * **v1 limitation (A1):** the underlying color is approximated by the handle's\n * own `color`, not by sampling the surrounding gradient. This is accurate on\n * smooth gradients and approximate at steep or saturated edges.\n */\n\n/** Minimum dark-border opacity (matches the 1st-gen static 42%). */\nexport const COLOR_HANDLE_ALPHA_FLOOR = 0.42;\n\n/** WCAG 1.4.11 non-text contrast target. */\nexport const COLOR_HANDLE_CONTRAST_TARGET = 3;\n\ntype Rgb = [number, number, number];\n\nconst WHITE: Rgb = [255, 255, 255];\n\nfunction srgbToLinear(channel: number): number {\n const c = channel / 255;\n return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n}\n\nfunction relativeLuminance([r, g, b]: Rgb): number {\n return (\n 0.2126 * srgbToLinear(r) +\n 0.7152 * srgbToLinear(g) +\n 0.0722 * srgbToLinear(b)\n );\n}\n\n/** Standard WCAG 2.2 contrast ratio between two opaque sRGB colors. */\nexport function contrastRatio(colorA: Rgb, colorB: Rgb): number {\n const la = relativeLuminance(colorA);\n const lb = relativeLuminance(colorB);\n const hi = Math.max(la, lb);\n const lo = Math.min(la, lb);\n return (hi + 0.05) / (lo + 0.05);\n}\n\n/**\n * Predicts the rendered color of a black border painted at opacity α over an\n * opaque background.\n */\nexport function compositeBlackOver([r, g, b]: Rgb, alpha: number): Rgb {\n return [\n Math.round(r * (1 - alpha)),\n Math.round(g * (1 - alpha)),\n Math.round(b * (1 - alpha)),\n ];\n}\n\n/**\n * The minimum α in `[floor, 1]` that makes a black border composited over\n * `adjacency` meet `target` contrast against that same adjacency.\n */\nexport function findMinAlpha(\n adjacency: Rgb,\n target: number = COLOR_HANDLE_CONTRAST_TARGET,\n floor: number = COLOR_HANDLE_ALPHA_FLOOR\n): number {\n for (let a = floor; a <= 1 + 1e-9; a += 0.01) {\n if (contrastRatio(compositeBlackOver(adjacency, a), adjacency) >= target) {\n return Math.min(1, Math.round(a * 100) / 100);\n }\n }\n return 1;\n}\n\n/**\n * Parses a CSS color string to opaque sRGB channels in `[0, 255]`. Alpha is\n * intentionally dropped: the border sits over the composited swatch, whose hue\n * is what matters for the contrast decision. Returns `null` for unparseable\n * input so callers can fall back to the floor.\n */\nfunction parseToRgb255(color: string): Rgb | null {\n try {\n const [r, g, b] = new Color(color).to('srgb').coords;\n const clamp = (c: number): number =>\n Math.max(0, Math.min(255, Math.round(c * 255)));\n return [clamp(r), clamp(g), clamp(b)];\n } catch {\n return null;\n }\n}\n\n/**\n * Computes the adaptive dark-border opacity for a handle showing `color`,\n * using the white-first strategy. Returns the floor when `color` cannot be\n * parsed so the border is never weaker than 1st-gen.\n */\nexport function computeBorderAlpha(\n color: string,\n {\n target = COLOR_HANDLE_CONTRAST_TARGET,\n floor = COLOR_HANDLE_ALPHA_FLOOR,\n }: { target?: number; floor?: number } = {}\n): number {\n const adjacency = parseToRgb255(color);\n if (!adjacency) {\n return floor;\n }\n // White-first: if the white separator already carries 3:1, keep the softer\n // floor; otherwise escalate α until the dark border itself passes.\n if (contrastRatio(WHITE, adjacency) >= target) {\n return floor;\n }\n return findMinAlpha(adjacency, target, floor);\n}\n"],"mappings":";;AAiCA,IAAa,IAA2B,KAG3B,IAA+B,GAItC,IAAa;CAAC;CAAK;CAAK;CAAI;AAElC,SAAS,EAAa,GAAyB;CAC7C,IAAM,IAAI,IAAU;AACpB,QAAO,KAAK,SAAU,IAAI,UAAkB,IAAI,QAAS,UAAO;;AAGlE,SAAS,EAAkB,CAAC,GAAG,GAAG,IAAiB;AACjD,QACE,QAAS,EAAa,EAAE,GACxB,QAAS,EAAa,EAAE,GACxB,QAAS,EAAa,EAAE;;AAK5B,SAAgB,EAAc,GAAa,GAAqB;CAC9D,IAAM,IAAK,EAAkB,EAAO,EAC9B,IAAK,EAAkB,EAAO,EAC9B,IAAK,KAAK,IAAI,GAAI,EAAG,EACrB,IAAK,KAAK,IAAI,GAAI,EAAG;AAC3B,SAAQ,IAAK,QAAS,IAAK;;AAO7B,SAAgB,EAAmB,CAAC,GAAG,GAAG,IAAS,GAAoB;AACrE,QAAO;EACL,KAAK,MAAM,KAAK,IAAI,GAAO;EAC3B,KAAK,MAAM,KAAK,IAAI,GAAO;EAC3B,KAAK,MAAM,KAAK,IAAI,GAAO;EAC5B;;AAOH,SAAgB,EACd,GACA,IAAA,GACA,IAAgB,GACR;AACR,MAAK,IAAI,IAAI,GAAO,KAAK,aAAU,KAAK,IACtC,KAAI,EAAc,EAAmB,GAAW,EAAE,EAAE,EAAU,IAAI,EAChE,QAAO,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,IAAI,GAAG,IAAI;AAGjD,QAAO;;AAST,SAAS,EAAc,GAA2B;AAChD,KAAI;EACF,IAAM,CAAC,GAAG,GAAG,KAAK,IAAI,EAAM,EAAM,CAAC,GAAG,OAAO,CAAC,QACxC,KAAS,MACb,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC;AACjD,SAAO;GAAC,EAAM,EAAE;GAAE,EAAM,EAAE;GAAE,EAAM,EAAE;GAAC;aAC/B;AACN,SAAO;;;AASX,SAAgB,EACd,GACA,EACE,YAAA,GACA,WAAQ,MAC+B,EAAE,EACnC;CACR,IAAM,IAAY,EAAc,EAAM;AAStC,QARI,CAAC,KAKD,EAAc,GAAO,EAAU,IAAI,IAC9B,IAEF,EAAa,GAAW,GAAQ,EAAM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from './ColorHandle.base.js';
|
|
13
|
+
export * from './ColorHandle.types.js';
|
|
14
|
+
export * from './color-contrast.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { COLOR_HANDLE_ALPHA_FLOOR as e, COLOR_HANDLE_CONTRAST_TARGET as t, compositeBlackOver as n, computeBorderAlpha as r, contrastRatio as i, findMinAlpha as a } from "./color-contrast.js";
|
|
2
|
+
import { ColorHandleBase as o } from "./ColorHandle.base.js";
|
|
3
|
+
export { e as COLOR_HANDLE_ALPHA_FLOOR, t as COLOR_HANDLE_CONTRAST_TARGET, o as ColorHandleBase, n as compositeBlackOver, r as computeBorderAlpha, i as contrastRatio, a as findMinAlpha };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SpectrumElement } from '../../element/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Minimum inner-border opacity (matches the existing `transparent-black-200`
|
|
4
|
+
* token) so the default look on mid/dark colors is unchanged.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COLOR_LOUPE_ALPHA_FLOOR = 0.12;
|
|
7
|
+
/**
|
|
8
|
+
* A visual magnifier that shows the currently picked color, including
|
|
9
|
+
* transparency over an opacity checkerboard, inside a loupe shape.
|
|
10
|
+
*
|
|
11
|
+
* The loupe is not an interactive control — accessibility semantics are
|
|
12
|
+
* provided by the parent color picker / color field.
|
|
13
|
+
*
|
|
14
|
+
* @element swc-color-loupe
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class ColorLoupeBase extends SpectrumElement {
|
|
17
|
+
/**
|
|
18
|
+
* Whether the loupe is visible. When `false` the loupe is hidden via
|
|
19
|
+
* CSS opacity and transform transitions.
|
|
20
|
+
*/
|
|
21
|
+
open: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The CSS color value to display inside the loupe.
|
|
24
|
+
* Supports any valid CSS color string, including those with alpha
|
|
25
|
+
* transparency (which reveals the checkerboard behind).
|
|
26
|
+
*
|
|
27
|
+
* Default is semi-transparent red so the opacity checkerboard is visible
|
|
28
|
+
* when the component is rendered without a `color` attribute.
|
|
29
|
+
*/
|
|
30
|
+
color: string;
|
|
31
|
+
/**
|
|
32
|
+
* The adaptive inner-border opacity for the current `color`, derived by the
|
|
33
|
+
* white-first strategy (shared with `<swc-color-handle>`) so the loupe
|
|
34
|
+
* chrome meets WCAG 1.4.11 (≥3:1) across the color spectrum. The white
|
|
35
|
+
* outer border is unchanged; the rendering layer applies this value to the
|
|
36
|
+
* inner border only.
|
|
37
|
+
*
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
protected get borderAlpha(): number;
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __decorate as e } from "../../_virtual/_@oxc-project_runtime@0.124.0/helpers/decorate.js";
|
|
2
|
+
import { property as t } from "lit/decorators.js";
|
|
3
|
+
import { SpectrumElement as n } from "@adobe/spectrum-wc-core/element/index.js";
|
|
4
|
+
import { computeBorderAlpha as r } from "@adobe/spectrum-wc-core/components/color-handle";
|
|
5
|
+
//#region components/color-loupe/ColorLoupe.base.ts
|
|
6
|
+
var i = .12, a = class extends n {
|
|
7
|
+
constructor(...e) {
|
|
8
|
+
super(...e), this.open = !1, this.color = "rgba(255, 0, 0, 0.5)";
|
|
9
|
+
}
|
|
10
|
+
get borderAlpha() {
|
|
11
|
+
return r(this.color, { floor: i });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
e([t({
|
|
15
|
+
type: Boolean,
|
|
16
|
+
reflect: !0
|
|
17
|
+
})], a.prototype, "open", void 0), e([t({ type: String })], a.prototype, "color", void 0);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { i as COLOR_LOUPE_ALPHA_FLOOR, a as ColorLoupeBase };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=ColorLoupe.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorLoupe.base.js","names":[],"sources":["../../../components/color-loupe/ColorLoupe.base.ts"],"sourcesContent":["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { property } from 'lit/decorators.js';\n\nimport { computeBorderAlpha } from '@adobe/spectrum-wc-core/components/color-handle';\nimport { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js';\n\n/**\n * Minimum inner-border opacity (matches the existing `transparent-black-200`\n * token) so the default look on mid/dark colors is unchanged.\n */\nexport const COLOR_LOUPE_ALPHA_FLOOR = 0.12;\n\n/**\n * A visual magnifier that shows the currently picked color, including\n * transparency over an opacity checkerboard, inside a loupe shape.\n *\n * The loupe is not an interactive control — accessibility semantics are\n * provided by the parent color picker / color field.\n *\n * @element swc-color-loupe\n */\nexport abstract class ColorLoupeBase extends SpectrumElement {\n // ─────────────────\n // SHARED API\n // ─────────────────\n\n /**\n * Whether the loupe is visible. When `false` the loupe is hidden via\n * CSS opacity and transform transitions.\n */\n @property({ type: Boolean, reflect: true })\n public open = false;\n\n /**\n * The CSS color value to display inside the loupe.\n * Supports any valid CSS color string, including those with alpha\n * transparency (which reveals the checkerboard behind).\n *\n * Default is semi-transparent red so the opacity checkerboard is visible\n * when the component is rendered without a `color` attribute.\n */\n @property({ type: String })\n public color = 'rgba(255, 0, 0, 0.5)';\n\n // ──────────────────────────\n // ADAPTIVE CONTRAST\n // ──────────────────────────\n\n /**\n * The adaptive inner-border opacity for the current `color`, derived by the\n * white-first strategy (shared with `<swc-color-handle>`) so the loupe\n * chrome meets WCAG 1.4.11 (≥3:1) across the color spectrum. The white\n * outer border is unchanged; the rendering layer applies this value to the\n * inner border only.\n *\n * @internal\n */\n protected get borderAlpha(): number {\n return computeBorderAlpha(this.color, { floor: COLOR_LOUPE_ALPHA_FLOOR });\n }\n}\n"],"mappings":";;;;;AAqBA,IAAa,IAA0B,KAWjB,IAAtB,cAA6C,EAAgB;;2BAU7C,iBAWC;;CAef,IAAc,cAAsB;AAClC,SAAO,EAAmB,KAAK,OAAO,EAAE,OAAO,GAAyB,CAAC;;;GA5B1E,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,CAAC,CAAA,EAAA,EAAA,WAAA,QAAA,KAAA,EAAA,KAW1C,EAAS,EAAE,MAAM,QAAQ,CAAC,CAAA,EAAA,EAAA,WAAA,SAAA,KAAA,EAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2026 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from './ColorLoupe.base.js';
|