@sky.ui/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +139 -0
- package/README.md +113 -0
- package/auto-import-loader.js +60 -0
- package/auto-import.js +93 -0
- package/dist/custom-elements.json +27051 -0
- package/dist/helper/controllers/animation-controller.d.ts +120 -0
- package/dist/helper/controllers/animation-controller.js +2 -0
- package/dist/helper/controllers/animation-controller.js.map +1 -0
- package/dist/helper/controllers/index.d.ts +2 -0
- package/dist/helper/controllers/popover-controller.d.ts +162 -0
- package/dist/helper/controllers/popover-controller.js +2 -0
- package/dist/helper/controllers/popover-controller.js.map +1 -0
- package/dist/helper/form-control-base.d.ts +1 -0
- package/dist/helper/iconify-offline.d.ts +73 -0
- package/dist/helper/iconify-offline.js +2 -0
- package/dist/helper/iconify-offline.js.map +1 -0
- package/dist/helper/index.d.ts +5 -0
- package/dist/helper/internals/form-control-base.d.ts +81 -0
- package/dist/helper/internals/form-control-base.js +2 -0
- package/dist/helper/internals/form-control-base.js.map +1 -0
- package/dist/helper/internals/index.d.ts +1 -0
- package/dist/helper/utils/color-resolver.d.ts +139 -0
- package/dist/helper/utils/color-resolver.js +2 -0
- package/dist/helper/utils/color-resolver.js.map +1 -0
- package/dist/helper/utils/index.d.ts +2 -0
- package/dist/helper/utils/size-resolver.d.ts +6 -0
- package/dist/helper/utils/size-resolver.js +2 -0
- package/dist/helper/utils/size-resolver.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sky-accordion/index.d.ts +1 -0
- package/dist/sky-accordion/index.js +1 -0
- package/dist/sky-accordion/sky-accordion.d.ts +201 -0
- package/dist/sky-accordion/sky-accordion.js +85 -0
- package/dist/sky-accordion/sky-accordion.js.map +1 -0
- package/dist/sky-accordion-item/index.d.ts +1 -0
- package/dist/sky-accordion-item/index.js +1 -0
- package/dist/sky-accordion-item/sky-accordion-item.d.ts +161 -0
- package/dist/sky-accordion-item/sky-accordion-item.js +191 -0
- package/dist/sky-accordion-item/sky-accordion-item.js.map +1 -0
- package/dist/sky-alert/index.d.ts +1 -0
- package/dist/sky-alert/index.js +1 -0
- package/dist/sky-alert/sky-alert.d.ts +136 -0
- package/dist/sky-alert/sky-alert.js +292 -0
- package/dist/sky-alert/sky-alert.js.map +1 -0
- package/dist/sky-appbar/index.d.ts +1 -0
- package/dist/sky-appbar/index.js +1 -0
- package/dist/sky-appbar/sky-appbar.d.ts +84 -0
- package/dist/sky-appbar/sky-appbar.js +173 -0
- package/dist/sky-appbar/sky-appbar.js.map +1 -0
- package/dist/sky-avatar/index.d.ts +1 -0
- package/dist/sky-avatar/index.js +1 -0
- package/dist/sky-avatar/sky-avatar.d.ts +104 -0
- package/dist/sky-avatar/sky-avatar.js +152 -0
- package/dist/sky-avatar/sky-avatar.js.map +1 -0
- package/dist/sky-badge/index.d.ts +1 -0
- package/dist/sky-badge/index.js +1 -0
- package/dist/sky-badge/sky-badge.d.ts +154 -0
- package/dist/sky-badge/sky-badge.js +148 -0
- package/dist/sky-badge/sky-badge.js.map +1 -0
- package/dist/sky-breadcrumb/index.d.ts +1 -0
- package/dist/sky-breadcrumb/index.js +1 -0
- package/dist/sky-breadcrumb/sky-breadcrumb.d.ts +111 -0
- package/dist/sky-breadcrumb/sky-breadcrumb.js +230 -0
- package/dist/sky-breadcrumb/sky-breadcrumb.js.map +1 -0
- package/dist/sky-button/index.d.ts +1 -0
- package/dist/sky-button/index.js +1 -0
- package/dist/sky-button/sky-button.d.ts +118 -0
- package/dist/sky-button/sky-button.js +172 -0
- package/dist/sky-button/sky-button.js.map +1 -0
- package/dist/sky-button-group/index.d.ts +1 -0
- package/dist/sky-button-group/index.js +1 -0
- package/dist/sky-button-group/sky-button-group.d.ts +93 -0
- package/dist/sky-button-group/sky-button-group.js +281 -0
- package/dist/sky-button-group/sky-button-group.js.map +1 -0
- package/dist/sky-card/index.d.ts +1 -0
- package/dist/sky-card/index.js +1 -0
- package/dist/sky-card/sky-card.d.ts +143 -0
- package/dist/sky-card/sky-card.js +186 -0
- package/dist/sky-card/sky-card.js.map +1 -0
- package/dist/sky-carousel/index.d.ts +1 -0
- package/dist/sky-carousel/index.js +1 -0
- package/dist/sky-carousel/sky-carousel.d.ts +265 -0
- package/dist/sky-carousel/sky-carousel.js +211 -0
- package/dist/sky-carousel/sky-carousel.js.map +1 -0
- package/dist/sky-checkbox/index.d.ts +1 -0
- package/dist/sky-checkbox/index.js +1 -0
- package/dist/sky-checkbox/sky-checkbox.d.ts +165 -0
- package/dist/sky-checkbox/sky-checkbox.js +276 -0
- package/dist/sky-checkbox/sky-checkbox.js.map +1 -0
- package/dist/sky-chip/index.d.ts +1 -0
- package/dist/sky-chip/index.js +1 -0
- package/dist/sky-chip/sky-chip.d.ts +95 -0
- package/dist/sky-chip/sky-chip.js +210 -0
- package/dist/sky-chip/sky-chip.js.map +1 -0
- package/dist/sky-col/index.d.ts +1 -0
- package/dist/sky-col/index.js +1 -0
- package/dist/sky-col/sky-col.d.ts +84 -0
- package/dist/sky-col/sky-col.js +46 -0
- package/dist/sky-col/sky-col.js.map +1 -0
- package/dist/sky-combobox/index.d.ts +1 -0
- package/dist/sky-combobox/index.js +1 -0
- package/dist/sky-combobox/sky-combobox.d.ts +313 -0
- package/dist/sky-combobox/sky-combobox.js +1146 -0
- package/dist/sky-combobox/sky-combobox.js.map +1 -0
- package/dist/sky-counter/index.d.ts +1 -0
- package/dist/sky-counter/index.js +1 -0
- package/dist/sky-counter/sky-counter.d.ts +130 -0
- package/dist/sky-counter/sky-counter.js +101 -0
- package/dist/sky-counter/sky-counter.js.map +1 -0
- package/dist/sky-dialog/index.d.ts +1 -0
- package/dist/sky-dialog/index.js +1 -0
- package/dist/sky-dialog/sky-dialog.d.ts +237 -0
- package/dist/sky-dialog/sky-dialog.js +265 -0
- package/dist/sky-dialog/sky-dialog.js.map +1 -0
- package/dist/sky-divider/index.d.ts +1 -0
- package/dist/sky-divider/index.js +1 -0
- package/dist/sky-divider/sky-divider.d.ts +120 -0
- package/dist/sky-divider/sky-divider.js +42 -0
- package/dist/sky-divider/sky-divider.js.map +1 -0
- package/dist/sky-drawer/index.d.ts +1 -0
- package/dist/sky-drawer/index.js +1 -0
- package/dist/sky-drawer/sky-drawer.d.ts +161 -0
- package/dist/sky-drawer/sky-drawer.js +177 -0
- package/dist/sky-drawer/sky-drawer.js.map +1 -0
- package/dist/sky-dropdown/index.d.ts +1 -0
- package/dist/sky-dropdown/index.js +1 -0
- package/dist/sky-dropdown/sky-dropdown.d.ts +252 -0
- package/dist/sky-dropdown/sky-dropdown.js +58 -0
- package/dist/sky-dropdown/sky-dropdown.js.map +1 -0
- package/dist/sky-dropdown-item/index.d.ts +1 -0
- package/dist/sky-dropdown-item/index.js +1 -0
- package/dist/sky-dropdown-item/sky-dropdown-item.d.ts +207 -0
- package/dist/sky-dropdown-item/sky-dropdown-item.js +341 -0
- package/dist/sky-dropdown-item/sky-dropdown-item.js.map +1 -0
- package/dist/sky-flexbar/index.d.ts +1 -0
- package/dist/sky-flexbar/index.js +1 -0
- package/dist/sky-flexbar/sky-flexbar.d.ts +189 -0
- package/dist/sky-flexbar/sky-flexbar.js +148 -0
- package/dist/sky-flexbar/sky-flexbar.js.map +1 -0
- package/dist/sky-flexbox/index.d.ts +1 -0
- package/dist/sky-flexbox/index.js +1 -0
- package/dist/sky-flexbox/sky-flexbox.d.ts +156 -0
- package/dist/sky-flexbox/sky-flexbox.js +40 -0
- package/dist/sky-flexbox/sky-flexbox.js.map +1 -0
- package/dist/sky-flexcol/index.d.ts +1 -0
- package/dist/sky-flexcol/index.js +1 -0
- package/dist/sky-flexcol/sky-flexcol.d.ts +154 -0
- package/dist/sky-flexcol/sky-flexcol.js +14 -0
- package/dist/sky-flexcol/sky-flexcol.js.map +1 -0
- package/dist/sky-flexitem/index.d.ts +1 -0
- package/dist/sky-flexitem/index.js +1 -0
- package/dist/sky-flexitem/sky-flexitem.d.ts +114 -0
- package/dist/sky-flexitem/sky-flexitem.js +45 -0
- package/dist/sky-flexitem/sky-flexitem.js.map +1 -0
- package/dist/sky-form/index.d.ts +1 -0
- package/dist/sky-form/index.js +1 -0
- package/dist/sky-form/sky-form.d.ts +286 -0
- package/dist/sky-form/sky-form.js +66 -0
- package/dist/sky-form/sky-form.js.map +1 -0
- package/dist/sky-grid/index.d.ts +1 -0
- package/dist/sky-grid/index.js +1 -0
- package/dist/sky-grid/sky-grid.d.ts +78 -0
- package/dist/sky-grid/sky-grid.js +40 -0
- package/dist/sky-grid/sky-grid.js.map +1 -0
- package/dist/sky-icon/index.d.ts +1 -0
- package/dist/sky-icon/index.js +1 -0
- package/dist/sky-icon/ion-local.json.js +2 -0
- package/dist/sky-icon/ion-local.json.js.map +1 -0
- package/dist/sky-icon/sky-icon.d.ts +123 -0
- package/dist/sky-icon/sky-icon.js +40 -0
- package/dist/sky-icon/sky-icon.js.map +1 -0
- package/dist/sky-image/index.d.ts +1 -0
- package/dist/sky-image/index.js +1 -0
- package/dist/sky-image/sky-image.d.ts +102 -0
- package/dist/sky-image/sky-image.js +29 -0
- package/dist/sky-image/sky-image.js.map +1 -0
- package/dist/sky-input/index.d.ts +1 -0
- package/dist/sky-input/index.js +1 -0
- package/dist/sky-input/sky-input.d.ts +345 -0
- package/dist/sky-input/sky-input.js +820 -0
- package/dist/sky-input/sky-input.js.map +1 -0
- package/dist/sky-list/index.d.ts +1 -0
- package/dist/sky-list/index.js +1 -0
- package/dist/sky-list/sky-list.d.ts +85 -0
- package/dist/sky-list/sky-list.js +41 -0
- package/dist/sky-list/sky-list.js.map +1 -0
- package/dist/sky-listitem/index.d.ts +1 -0
- package/dist/sky-listitem/index.js +1 -0
- package/dist/sky-listitem/sky-listitem.d.ts +76 -0
- package/dist/sky-listitem/sky-listitem.js +104 -0
- package/dist/sky-listitem/sky-listitem.js.map +1 -0
- package/dist/sky-navbar/index.d.ts +1 -0
- package/dist/sky-navbar/index.js +1 -0
- package/dist/sky-navbar/sky-navbar.d.ts +207 -0
- package/dist/sky-navbar/sky-navbar.js +521 -0
- package/dist/sky-navbar/sky-navbar.js.map +1 -0
- package/dist/sky-navpanel/index.d.ts +1 -0
- package/dist/sky-navpanel/index.js +1 -0
- package/dist/sky-navpanel/sky-navpanel.d.ts +186 -0
- package/dist/sky-navpanel/sky-navpanel.js +404 -0
- package/dist/sky-navpanel/sky-navpanel.js.map +1 -0
- package/dist/sky-notification/index.d.ts +1 -0
- package/dist/sky-notification/index.js +1 -0
- package/dist/sky-notification/sky-notification.d.ts +152 -0
- package/dist/sky-notification/sky-notification.js +456 -0
- package/dist/sky-notification/sky-notification.js.map +1 -0
- package/dist/sky-otp/index.d.ts +1 -0
- package/dist/sky-otp/index.js +1 -0
- package/dist/sky-otp/sky-otp.d.ts +101 -0
- package/dist/sky-otp/sky-otp.js +96 -0
- package/dist/sky-otp/sky-otp.js.map +1 -0
- package/dist/sky-overlay/index.d.ts +1 -0
- package/dist/sky-overlay/index.js +1 -0
- package/dist/sky-overlay/sky-overlay.d.ts +71 -0
- package/dist/sky-overlay/sky-overlay.js +26 -0
- package/dist/sky-overlay/sky-overlay.js.map +1 -0
- package/dist/sky-pagination/index.d.ts +1 -0
- package/dist/sky-pagination/index.js +1 -0
- package/dist/sky-pagination/sky-pagination.d.ts +167 -0
- package/dist/sky-pagination/sky-pagination.js +453 -0
- package/dist/sky-pagination/sky-pagination.js.map +1 -0
- package/dist/sky-progress/index.d.ts +1 -0
- package/dist/sky-progress/index.js +1 -0
- package/dist/sky-progress/sky-progress.d.ts +70 -0
- package/dist/sky-progress/sky-progress.js +87 -0
- package/dist/sky-progress/sky-progress.js.map +1 -0
- package/dist/sky-radio/index.d.ts +1 -0
- package/dist/sky-radio/index.js +1 -0
- package/dist/sky-radio/sky-radio.d.ts +118 -0
- package/dist/sky-radio/sky-radio.js +109 -0
- package/dist/sky-radio/sky-radio.js.map +1 -0
- package/dist/sky-radio-group/index.d.ts +1 -0
- package/dist/sky-radio-group/index.js +1 -0
- package/dist/sky-radio-group/sky-radio-group.d.ts +186 -0
- package/dist/sky-radio-group/sky-radio-group.js +239 -0
- package/dist/sky-radio-group/sky-radio-group.js.map +1 -0
- package/dist/sky-range/index.d.ts +1 -0
- package/dist/sky-range/index.js +1 -0
- package/dist/sky-range/sky-range.d.ts +110 -0
- package/dist/sky-range/sky-range.js +196 -0
- package/dist/sky-range/sky-range.js.map +1 -0
- package/dist/sky-row/index.d.ts +1 -0
- package/dist/sky-row/index.js +1 -0
- package/dist/sky-row/sky-row.d.ts +57 -0
- package/dist/sky-row/sky-row.js +6 -0
- package/dist/sky-row/sky-row.js.map +1 -0
- package/dist/sky-serial/index.d.ts +1 -0
- package/dist/sky-serial/index.js +1 -0
- package/dist/sky-serial/sky-serial.d.ts +127 -0
- package/dist/sky-serial/sky-serial.js +133 -0
- package/dist/sky-serial/sky-serial.js.map +1 -0
- package/dist/sky-sheet/index.d.ts +1 -0
- package/dist/sky-sheet/index.js +1 -0
- package/dist/sky-sheet/sky-sheet.d.ts +70 -0
- package/dist/sky-sheet/sky-sheet.js +47 -0
- package/dist/sky-sheet/sky-sheet.js.map +1 -0
- package/dist/sky-skeleton/index.d.ts +1 -0
- package/dist/sky-skeleton/index.js +1 -0
- package/dist/sky-skeleton/sky-skeleton.d.ts +80 -0
- package/dist/sky-skeleton/sky-skeleton.js +233 -0
- package/dist/sky-skeleton/sky-skeleton.js.map +1 -0
- package/dist/sky-slider/index.d.ts +1 -0
- package/dist/sky-slider/index.js +1 -0
- package/dist/sky-slider/sky-slider.d.ts +96 -0
- package/dist/sky-slider/sky-slider.js +139 -0
- package/dist/sky-slider/sky-slider.js.map +1 -0
- package/dist/sky-speeddial/index.d.ts +1 -0
- package/dist/sky-speeddial/index.js +1 -0
- package/dist/sky-speeddial/sky-speeddial.d.ts +86 -0
- package/dist/sky-speeddial/sky-speeddial.js +154 -0
- package/dist/sky-speeddial/sky-speeddial.js.map +1 -0
- package/dist/sky-spinner/index.d.ts +1 -0
- package/dist/sky-spinner/index.js +1 -0
- package/dist/sky-spinner/sky-spinner.d.ts +87 -0
- package/dist/sky-spinner/sky-spinner.js +334 -0
- package/dist/sky-spinner/sky-spinner.js.map +1 -0
- package/dist/sky-steps/index.d.ts +1 -0
- package/dist/sky-steps/index.js +1 -0
- package/dist/sky-steps/sky-steps.d.ts +170 -0
- package/dist/sky-steps/sky-steps.js +455 -0
- package/dist/sky-steps/sky-steps.js.map +1 -0
- package/dist/sky-switch/index.d.ts +1 -0
- package/dist/sky-switch/index.js +1 -0
- package/dist/sky-switch/sky-switch.d.ts +116 -0
- package/dist/sky-switch/sky-switch.js +191 -0
- package/dist/sky-switch/sky-switch.js.map +1 -0
- package/dist/sky-tab/index.d.ts +1 -0
- package/dist/sky-tab/index.js +1 -0
- package/dist/sky-tab/sky-tab.d.ts +188 -0
- package/dist/sky-tab/sky-tab.js +390 -0
- package/dist/sky-tab/sky-tab.js.map +1 -0
- package/dist/sky-tab-button/index.d.ts +1 -0
- package/dist/sky-tab-button/index.js +1 -0
- package/dist/sky-tab-button/sky-tab-button.d.ts +114 -0
- package/dist/sky-tab-button/sky-tab-button.js +167 -0
- package/dist/sky-tab-button/sky-tab-button.js.map +1 -0
- package/dist/sky-theme-provider/index.d.ts +1 -0
- package/dist/sky-theme-provider/index.js +1 -0
- package/dist/sky-theme-provider/sky-theme-provider.d.ts +169 -0
- package/dist/sky-theme-provider/sky-theme-provider.js +12 -0
- package/dist/sky-theme-provider/sky-theme-provider.js.map +1 -0
- package/dist/sky-theme-switcher/index.d.ts +1 -0
- package/dist/sky-theme-switcher/index.js +1 -0
- package/dist/sky-theme-switcher/sky-theme-switcher.d.ts +92 -0
- package/dist/sky-theme-switcher/sky-theme-switcher.js +43 -0
- package/dist/sky-theme-switcher/sky-theme-switcher.js.map +1 -0
- package/dist/sky-tooltip/index.d.ts +1 -0
- package/dist/sky-tooltip/index.js +1 -0
- package/dist/sky-tooltip/sky-tooltip.d.ts +156 -0
- package/dist/sky-tooltip/sky-tooltip.js +242 -0
- package/dist/sky-tooltip/sky-tooltip.js.map +1 -0
- package/package.json +475 -0
- package/plugins/rollup-plugin.d.ts +19 -0
- package/plugins/rollup-plugin.js +129 -0
- package/plugins/vite-plugin.d.ts +22 -0
- package/plugins/vite-plugin.js +116 -0
- package/plugins/webpack-plugin.d.ts +12 -0
- package/plugins/webpack-plugin.js +46 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export type SkySwitchValueChangedDetail = {
|
|
3
|
+
value: string | boolean | undefined;
|
|
4
|
+
};
|
|
5
|
+
export type SkySwitchValidationErrorDetail = {
|
|
6
|
+
errors: string[];
|
|
7
|
+
};
|
|
8
|
+
export type SkySwitchValueClearedDetail = {
|
|
9
|
+
value: string | boolean | undefined;
|
|
10
|
+
state: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @element sky-switch
|
|
14
|
+
*
|
|
15
|
+
* @summary Themeable toggle switch with icon/label states and validation support.
|
|
16
|
+
*
|
|
17
|
+
* @status stable
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
* @documentation https://library.sky-ui.com/components/switch
|
|
20
|
+
* @dependency sky-icon
|
|
21
|
+
*
|
|
22
|
+
* @uiVModel state value-changed
|
|
23
|
+
*
|
|
24
|
+
* @slot - Default slot for additional content (not typically used).
|
|
25
|
+
*
|
|
26
|
+
* @csspart switch - The clickable wrapper around the toggle.
|
|
27
|
+
* @csspart toggle - The rounded track/background of the switch.
|
|
28
|
+
* @csspart thumb - The circular thumb/handle that slides.
|
|
29
|
+
* @csspart content - The inner flex container holding icon/label.
|
|
30
|
+
* @csspart label - The text node used when no icon is supplied.
|
|
31
|
+
* @csspart icon - The icon node when an icon is supplied.
|
|
32
|
+
*
|
|
33
|
+
* @property {string} activeIcon - Icon name for the ON state (Iconify). Default: ""
|
|
34
|
+
* @property {string} inactiveIcon - Icon name for the OFF state (Iconify). Default: ""
|
|
35
|
+
* @property {string} activeLabel - Text label for the ON state (fallback if no icon). Default: "ON"
|
|
36
|
+
* @property {string} inactiveLabel - Text label for the OFF state (fallback if no icon). Default: "OFF"
|
|
37
|
+
* @property {boolean} state - Current boolean value of the switch (reflected). Default: false
|
|
38
|
+
* @property {string} value - Optional string payload emitted when ON (like checkbox.value). Default: ""
|
|
39
|
+
* @property {string} toggleWidth - Track width (e.g., "58px"). Auto-computed if text changes. Default: "40px"
|
|
40
|
+
* @property {string} activeColor - Icon/text color when ON. Default: "#fff"
|
|
41
|
+
* @property {string} inactiveColor - Icon/text color when OFF. Default: "dark"
|
|
42
|
+
* @property {string} activeBgColor - Track background when ON. Default: "primary"
|
|
43
|
+
* @property {string} inactiveBgColor - Track background when OFF. Default: "light"
|
|
44
|
+
* @property {boolean} disabled - Whether the switch is disabled. Default: false
|
|
45
|
+
* @property {boolean} required - Whether the switch must be ON to pass validation. Default: false
|
|
46
|
+
* @property {string} requiredMessage - Error message when required is not satisfied. Default: "This switch is required."
|
|
47
|
+
* @property {boolean} showErrors - Whether to render the error message block. Default: false
|
|
48
|
+
*
|
|
49
|
+
* @fires {CustomEvent<SkySwitchValueChangedDetail>} value-changed - Dispatched on toggle.
|
|
50
|
+
* @fires {CustomEvent<SkySwitchValidationErrorDetail>} validation-error - Dispatched when validation runs.
|
|
51
|
+
* @fires {CustomEvent<SkySwitchValueClearedDetail>} value-cleared - Dispatched when `reset()` is called.
|
|
52
|
+
* @method check Turns switch ON.
|
|
53
|
+
* @method uncheck Turns switch OFF.
|
|
54
|
+
* @method toggle Flips switch state.
|
|
55
|
+
*
|
|
56
|
+
* @Behavior
|
|
57
|
+
* - Toggles between ON/OFF states with icon or text rendering.
|
|
58
|
+
* - Emits checkbox-like value semantics for form integrations.
|
|
59
|
+
* - Supports required validation and optional error display.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```html
|
|
63
|
+
* <sky-switch active-icon="mdi:check" inactive-icon="ion:close" active-label="Enabled" inactive-label="Disabled" required show-errors></sky-switch>
|
|
64
|
+
* ```
|
|
65
|
+
* ```vue
|
|
66
|
+
* <template>
|
|
67
|
+
* <sky-switch active-icon="mdi:check" inactive-icon="ion:close" active-label="Enabled" inactive-label="Disabled" required show-errors></sky-switch>
|
|
68
|
+
* </template>
|
|
69
|
+
* ```
|
|
70
|
+
* ```jsx
|
|
71
|
+
* export default function Demo() {
|
|
72
|
+
* return <sky-switch active-icon="mdi:check" inactive-icon="ion:close" active-label="Enabled" inactive-label="Disabled" required show-errors></sky-switch>;
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare class SkySwitch extends LitElement {
|
|
77
|
+
static dependencies: Record<string, CustomElementConstructor>;
|
|
78
|
+
activeIcon: string;
|
|
79
|
+
inactiveIcon: string;
|
|
80
|
+
activeLabel: string;
|
|
81
|
+
inactiveLabel: string;
|
|
82
|
+
state: boolean;
|
|
83
|
+
/** like checkbox.value (optional string payload when ON) */
|
|
84
|
+
value: string;
|
|
85
|
+
toggleWidth: string;
|
|
86
|
+
activeColor: string;
|
|
87
|
+
inactiveColor: string;
|
|
88
|
+
activeBgColor: string;
|
|
89
|
+
inactiveBgColor: string;
|
|
90
|
+
disabled: boolean;
|
|
91
|
+
validationActive: boolean;
|
|
92
|
+
invalid: boolean;
|
|
93
|
+
/** === checkbox-style validation contract === */
|
|
94
|
+
private validationErrors;
|
|
95
|
+
showErrors: boolean;
|
|
96
|
+
required: boolean;
|
|
97
|
+
requiredMessage: string;
|
|
98
|
+
private defaultState;
|
|
99
|
+
/** lets <sky-form> aggregate without special-casing */
|
|
100
|
+
get formValue(): string | boolean | undefined;
|
|
101
|
+
static styles: import("lit").CSSResult;
|
|
102
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
103
|
+
private computeAndSetWidth;
|
|
104
|
+
private measureTextWidth;
|
|
105
|
+
private emitValueChanged;
|
|
106
|
+
private toggleState;
|
|
107
|
+
check(): void;
|
|
108
|
+
uncheck(): void;
|
|
109
|
+
toggle(): void;
|
|
110
|
+
private onKeyDown;
|
|
111
|
+
/** checkbox-like validation */
|
|
112
|
+
validateInput(): boolean;
|
|
113
|
+
/** restore to defaultState and clear validation */
|
|
114
|
+
reset(): void;
|
|
115
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
116
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import{__decorate as t,__metadata as e}from"tslib";import{LitElement as i,css as o,html as s}from"lit";import{property as a,state as n,customElement as r}from"lit/decorators.js";import{when as l}from"lit/directives/when.js";import{classMap as c}from"lit/directives/class-map.js";import{resolveColor as d}from"../helper/utils/color-resolver.js";import{SkyIcon as h}from"../sky-icon/sky-icon.js";let p=class extends i{constructor(){super(...arguments),this.activeIcon="",this.inactiveIcon="",this.activeLabel="ON",this.inactiveLabel="OFF",this.state=!1,this.value="",this.toggleWidth="40px",this.activeColor="#fff",this.inactiveColor="dark",this.activeBgColor="primary",this.inactiveBgColor="light",this.disabled=!1,this.validationActive=!1,this.invalid=!1,this.validationErrors=[],this.showErrors=!1,this.required=!1,this.requiredMessage="This switch is required.",this.defaultState=!1,this.onKeyDown=t=>{" "!==t.key&&"Enter"!==t.key||(t.preventDefault(),this.toggleState(t))}}static{this.dependencies={"sky-icon":h}}get formValue(){return"string"==typeof this.value&&""!==this.value.trim()?this.state?this.value:void 0:this.state}static{this.styles=o`
|
|
2
|
+
:host {
|
|
3
|
+
display: inline-block;
|
|
4
|
+
outline: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host([disabled]) {
|
|
8
|
+
opacity: 0.6;
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host([disabled]) .switch {
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.switch {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
position: relative;
|
|
22
|
+
user-select: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.toggle {
|
|
26
|
+
position: relative;
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
width: var(--toggle-width, 40px);
|
|
30
|
+
height: 30px;
|
|
31
|
+
background: var(--off-bg-color);
|
|
32
|
+
border-radius: var(--sky-radius-full);
|
|
33
|
+
border: var(--sky-border-primary);
|
|
34
|
+
box-shadow: var(--sky-box-shadow-inset);
|
|
35
|
+
transition: background 0.4s ease-in-out;
|
|
36
|
+
font-size: 12px;
|
|
37
|
+
color: var(--label-color);
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
}
|
|
40
|
+
.toggle.on {
|
|
41
|
+
background: var(--on-bg-color);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.content {
|
|
45
|
+
position: relative;
|
|
46
|
+
inline-size: 100%;
|
|
47
|
+
block-size: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.state-layer {
|
|
51
|
+
position: absolute;
|
|
52
|
+
inset: 0;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
padding-inline: 8px;
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
transition: opacity 0.25s ease, transform 0.25s ease,
|
|
58
|
+
color 0.4s ease-in-out;
|
|
59
|
+
will-change: opacity, transform;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.state-off {
|
|
63
|
+
justify-content: flex-end;
|
|
64
|
+
opacity: 1;
|
|
65
|
+
transform: translateY(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.state-on {
|
|
69
|
+
justify-content: flex-start;
|
|
70
|
+
opacity: 0;
|
|
71
|
+
transition: opacity 0.4s ease-in-out;
|
|
72
|
+
}
|
|
73
|
+
.state-off {
|
|
74
|
+
justify-content: flex-end;
|
|
75
|
+
opacity: 1;
|
|
76
|
+
transition: opacity 0.4s ease-in-out;
|
|
77
|
+
}
|
|
78
|
+
.toggle.on .state-on {
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
.toggle.on .state-off {
|
|
82
|
+
opacity: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.thumb {
|
|
86
|
+
position: absolute;
|
|
87
|
+
inset-block-start: 3px;
|
|
88
|
+
inset-inline-start: 4px;
|
|
89
|
+
inline-size: 24px;
|
|
90
|
+
block-size: 24px;
|
|
91
|
+
background: var(--sky-text-white);
|
|
92
|
+
box-sizing: border-box;
|
|
93
|
+
border: var(--sky-border-primary);
|
|
94
|
+
border-radius: var(--sky-radius-full);
|
|
95
|
+
transition: transform 0.4s ease-in-out, background 0.4s ease-in-out;
|
|
96
|
+
transform: translateX(0);
|
|
97
|
+
box-shadow: var(--sky-box-shadow-tertiary);
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
}
|
|
100
|
+
:host(:dir(ltr)) .toggle.on .thumb {
|
|
101
|
+
transform: translateX(calc(var(--toggle-width) - 31px));
|
|
102
|
+
}
|
|
103
|
+
:host(:dir(rtl)) .thumb {
|
|
104
|
+
inset-inline-start: auto;
|
|
105
|
+
inset-inline-end: 4px;
|
|
106
|
+
transform: translateX(0);
|
|
107
|
+
}
|
|
108
|
+
:host(:dir(rtl)) .toggle.on .thumb {
|
|
109
|
+
transform: translateX(calc(31px - var(--toggle-width)));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
sky-icon {
|
|
113
|
+
display: inline-block;
|
|
114
|
+
width: 1em;
|
|
115
|
+
height: 1em;
|
|
116
|
+
}
|
|
117
|
+
.iconify {
|
|
118
|
+
font-size: 14px;
|
|
119
|
+
transition: color 0.4s ease-in-out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.iconify-on,
|
|
123
|
+
.text-on {
|
|
124
|
+
color: var(--on-icon-color);
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
}
|
|
127
|
+
.iconify-off,
|
|
128
|
+
.text-off {
|
|
129
|
+
color: var(--off-icon-color);
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.label {
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
transition: color 0.4s ease-in-out;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.toggle:focus-visible {
|
|
140
|
+
outline: 2px solid var(--sky-focus-ring, rgba(59, 130, 246, 0.6));
|
|
141
|
+
outline-offset: 2px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@media (prefers-reduced-motion: reduce) {
|
|
145
|
+
.state-layer {
|
|
146
|
+
transition: none;
|
|
147
|
+
}
|
|
148
|
+
.thumb {
|
|
149
|
+
transition: none;
|
|
150
|
+
}
|
|
151
|
+
.toggle {
|
|
152
|
+
transition: none;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`}willUpdate(t){t.has("activeColor")&&this.style.setProperty("--on-icon-color",d(this.activeColor)),t.has("inactiveColor")&&this.style.setProperty("--off-icon-color",d(this.inactiveColor)),t.has("inactiveBgColor")&&this.style.setProperty("--off-bg-color",d(this.inactiveBgColor)),t.has("activeBgColor")&&this.style.setProperty("--on-bg-color",d(this.activeBgColor)),(t.has("activeLabel")||t.has("inactiveLabel")||t.has("activeIcon")||t.has("inactiveIcon"))&&this.computeAndSetWidth(),(t.has("state")||t.has("required"))&&this.validateInput()}computeAndSetWidth(){if(this.activeIcon&&this.inactiveIcon)return void("60px"!==this.toggleWidth&&(this.toggleWidth="60px"));const t=(this.activeLabel?.length||0)>=(this.inactiveLabel?.length||0)?this.activeLabel:this.inactiveLabel,e=this.measureTextWidth(t,"12px","var(--sky-font, sans-serif)"),i=`${Math.max(40,Math.ceil(e+46))}px`;this.toggleWidth!==i&&(this.toggleWidth=i)}measureTextWidth(t,e="12px",i="sans-serif"){const o=(this.__twc??(this.__twc=document.createElement("canvas"))).getContext("2d");return o.font=`${e} ${i}`,o.measureText(t??"").width}emitValueChanged(){const t=this.value&&""!==this.value.trim()?this.state?this.value:void 0:this.state;this.dispatchEvent(new CustomEvent("value-changed",{detail:{value:t},bubbles:!0,composed:!0}))}toggleState(t){t?.preventDefault?.(),this.disabled||(this.state=!this.state,this.emitValueChanged(),this.validateInput())}check(){this.disabled||this.state||this.toggleState()}uncheck(){!this.disabled&&this.state&&this.toggleState()}toggle(){this.disabled||this.toggleState()}validateInput(){if(!this.validationActive)return!0;this.validationErrors=[],this.required&&!this.state&&(this.validationErrors=[this.requiredMessage]),this.dispatchEvent(new CustomEvent("validation-error",{detail:{errors:[...this.validationErrors]},bubbles:!0,composed:!0}));const t=0===this.validationErrors.length;return this.invalid=!t,t}reset(){this.state=!!this.defaultState,this.validationErrors=[],this.validationActive=!1,this.invalid=!1;const t=this.value&&""!==this.value.trim()?this.state?this.value:void 0:this.state;this.dispatchEvent(new CustomEvent("value-cleared",{detail:{value:t,state:this.state},bubbles:!0,composed:!0}))}render(){const t=this.state;return s`
|
|
156
|
+
<div
|
|
157
|
+
class="switch"
|
|
158
|
+
part="switch"
|
|
159
|
+
@click=${this.toggleState}
|
|
160
|
+
role="presentation"
|
|
161
|
+
>
|
|
162
|
+
<div
|
|
163
|
+
class=${c({toggle:!0,on:t})}
|
|
164
|
+
part="toggle"
|
|
165
|
+
style="--toggle-width:${this.toggleWidth};"
|
|
166
|
+
role="switch"
|
|
167
|
+
aria-checked=${t}
|
|
168
|
+
tabindex="0"
|
|
169
|
+
@keydown=${this.onKeyDown}
|
|
170
|
+
>
|
|
171
|
+
<span class="thumb" part="thumb"></span>
|
|
172
|
+
<div class="content" part="content">
|
|
173
|
+
<div class="state-layer state-on">
|
|
174
|
+
${l(this.activeIcon,()=>s`<sky-icon
|
|
175
|
+
class="iconify iconify-on"
|
|
176
|
+
part="icon"
|
|
177
|
+
icon="${this.activeIcon}"
|
|
178
|
+
></sky-icon>`,()=>s`<span class="label text-on" part="label">${this.activeLabel}</span>`)}
|
|
179
|
+
</div>
|
|
180
|
+
<div class="state-layer state-off">
|
|
181
|
+
${l(this.inactiveIcon,()=>s`<sky-icon
|
|
182
|
+
class="iconify iconify-off"
|
|
183
|
+
part="icon"
|
|
184
|
+
icon="${this.inactiveIcon}"
|
|
185
|
+
></sky-icon>`,()=>s`<span class="label text-off" part="label">${this.inactiveLabel}</span>`)}
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
`}};t([a({type:String}),e("design:type",Object)],p.prototype,"activeIcon",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"inactiveIcon",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"activeLabel",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"inactiveLabel",void 0),t([a({type:Boolean,reflect:!0}),e("design:type",Object)],p.prototype,"state",void 0),t([a({type:String}),e("design:type",String)],p.prototype,"value",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"toggleWidth",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"activeColor",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"inactiveColor",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"activeBgColor",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"inactiveBgColor",void 0),t([a({type:Boolean,reflect:!0}),e("design:type",Object)],p.prototype,"disabled",void 0),t([a({type:Boolean,reflect:!0}),e("design:type",Boolean)],p.prototype,"validationActive",void 0),t([a({type:Boolean,reflect:!0}),e("design:type",Boolean)],p.prototype,"invalid",void 0),t([n(),e("design:type",Array)],p.prototype,"validationErrors",void 0),t([a({type:Boolean}),e("design:type",Object)],p.prototype,"showErrors",void 0),t([a({type:Boolean}),e("design:type",Object)],p.prototype,"required",void 0),t([a({type:String}),e("design:type",Object)],p.prototype,"requiredMessage",void 0),t([n(),e("design:type",Object)],p.prototype,"defaultState",void 0),p=t([r("sky-switch")],p);export{p as SkySwitch};
|
|
191
|
+
//# sourceMappingURL=sky-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sky-switch.js","sources":["../../src/sky-switch/sky-switch.ts"],"sourcesContent":[null],"names":["SkySwitch","LitElement","constructor","this","activeIcon","inactiveIcon","activeLabel","inactiveLabel","state","value","toggleWidth","activeColor","inactiveColor","activeBgColor","inactiveBgColor","disabled","validationActive","invalid","validationErrors","showErrors","required","requiredMessage","defaultState","onKeyDown","ev","key","preventDefault","toggleState","dependencies","SkyIcon","formValue","trim","undefined","styles","css","willUpdate","changed","has","style","setProperty","resolveColor","computeAndSetWidth","validateInput","text","length","px","measureTextWidth","next","Math","max","ceil","fontSize","fontFamily","ctx","__twc","document","createElement","getContext","font","measureText","width","emitValueChanged","emitted","dispatchEvent","CustomEvent","detail","bubbles","composed","e","check","uncheck","toggle","errors","isValid","reset","render","isOn","html","classMap","on","when","__decorate","property","type","String","prototype","Boolean","reflect","customElement"],"mappings":"0YA4EO,IAAMA,EAAN,cAAwBC,EAAxB,WAAAC,uBAMuBC,KAAAC,WAAa,GACbD,KAAAE,aAAe,GACfF,KAAAG,YAAc,KACdH,KAAAI,cAAgB,MACAJ,KAAAK,OAAQ,EAGxBL,KAAAM,MAAgB,GAEhBN,KAAAO,YAAc,OACdP,KAAAQ,YAAc,OACdR,KAAAS,cAAgB,OAChBT,KAAAU,cAAgB,UAChBV,KAAAW,gBAAkB,QACFX,KAAAY,UAAW,EACXZ,KAAAa,kBAA4B,EAC5Bb,KAAAc,SAAmB,EAIvDd,KAAAe,iBAA6B,GACRf,KAAAgB,YAAa,EACbhB,KAAAiB,UAAW,EACZjB,KAAAkB,gBAAkB,2BAEtClB,KAAAmB,cAAe,EA4QfnB,KAAAoB,UAAaC,IACJ,MAAXA,EAAGC,KAA0B,UAAXD,EAAGC,MACvBD,EAAGE,iBACHvB,KAAKwB,YAAYH,IAgGvB,QA5YSrB,KAAAyB,aAAyD,CAC9D,WAAYC,EACZ,CA8BF,aAAIC,GAGF,MADwB,iBAAf3B,KAAKM,OAA4C,KAAtBN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,EAAAqF,UAAA,wBAC1BJ,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,kCAAoCpF,EAAAqF,UAAA,0BACVJ,EAAA,CAA3CC,EAAS,CAAEC,KAAMG,QAASC,SAAS,6BAAyBvF,EAAAqF,UAAA,mBACjBJ,EAAA,CAA3CC,EAAS,CAAEC,KAAMG,QAASC,SAAS,8BAA0CvF,EAAAqF,UAAA,2BAClCJ,EAAA,CAA3CC,EAAS,CAAEC,KAAMG,QAASC,SAAS,8BAAiCvF,EAAAqF,UAAA,kBAI7DJ,EAAA,CADPzE,4BACuCR,EAAAqF,UAAA,2BACXJ,EAAA,CAA5BC,EAAS,CAAEC,KAAMG,mCAA8BtF,EAAAqF,UAAA,qBACnBJ,EAAA,CAA5BC,EAAS,CAAEC,KAAMG,mCAA4BtF,EAAAqF,UAAA,mBAClBJ,EAAA,CAA3BC,EAAS,CAAEC,KAAMC,kCAAuDpF,EAAAqF,UAAA,0BAEjEJ,EAAA,CADPzE,6BAC4BR,EAAAqF,UAAA,uBA/BlBrF,EAASiF,EAAA,CADrBO,EAAc,eACFxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./sky-tab";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sky-tab.js';
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
export type SkyTabBarPosition = "top" | "bottom" | "left" | "right";
|
|
3
|
+
export type SkyTabMountStrategy = "eager" | "lazy" | "unmount";
|
|
4
|
+
export type SkyTabScrollMode = "tab" | "page" | "px";
|
|
5
|
+
export type SkyTabChangeDetail = {
|
|
6
|
+
activeIndex: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @element sky-tab
|
|
10
|
+
*
|
|
11
|
+
* @summary Tab system with animated indicator, keyboard navigation, and flexible panel mounting.
|
|
12
|
+
*
|
|
13
|
+
* @status stable
|
|
14
|
+
* @since 1.0.0
|
|
15
|
+
* @documentation https://library.sky-ui.com/components/tab
|
|
16
|
+
* @dependency sky-icon
|
|
17
|
+
*
|
|
18
|
+
* @uiVModel selectedIndex tab-change detail=activeIndex
|
|
19
|
+
*
|
|
20
|
+
* @slot tab - Label/button for each tab (one per index).
|
|
21
|
+
* @slot tab-content - Panel content for each tab (one per index).
|
|
22
|
+
*
|
|
23
|
+
* @csspart wrapper - Root flex wrapper (tabs + content).
|
|
24
|
+
* @csspart rails - Rail container for overflow navigation + tray.
|
|
25
|
+
* @csspart tray - Scrollable area containing the tabs.
|
|
26
|
+
* @csspart tabs - The tabs strip (role="tablist").
|
|
27
|
+
* @csspart indicator - The animated thumb under the active tab.
|
|
28
|
+
* @csspart tab - Each individual tab button.
|
|
29
|
+
* @csspart tab--selected - The currently selected tab button.
|
|
30
|
+
* @csspart content - Container for tab panels.
|
|
31
|
+
*
|
|
32
|
+
* @property {number} selectedIndex - Index of the currently selected tab. Default: 0
|
|
33
|
+
* @property {SkyTabBarPosition} tabBarPosition - Position of the tab bar.
|
|
34
|
+
* @property {string} panelHeight - Explicit height for the tab content container (e.g., "auto", "400px", "100%"). Default: "auto"
|
|
35
|
+
* @property {string} panelWidth - Explicit width for the tab content container (e.g., "auto", "600px", "100%"). Default: "auto"
|
|
36
|
+
* @property {string} gutter - Spacing (gap) between the tab bar and the content area. Default: "0"
|
|
37
|
+
* @property {SkyTabMountStrategy} mountStrategy - Content mount strategy.
|
|
38
|
+
* @property {boolean} keepAlive - If mountStrategy="unmount", retain DOM in cache for quick re-attachment. Default: true
|
|
39
|
+
* @property {boolean} overflowButton - Show chevron nav buttons & hide native scrollbars when true. Default: false
|
|
40
|
+
* @property {SkyTabScrollMode} scrollMode - Rail scroll mode for nav buttons.
|
|
41
|
+
* @property {number} scrollPx - Pixel amount for scrollMode="px". Default: 120
|
|
42
|
+
* @property {number} edgePad - Edge padding used in internal scroll calculations. Default: 12
|
|
43
|
+
* @property {number} holdDelay - Press-and-hold delay (ms) before auto-repeat scroll starts. Default: 250
|
|
44
|
+
* @property {number} holdInterval - Press-and-hold repeat interval (ms). Default: 120
|
|
45
|
+
* @property {number} neighbors - Neighbor look-ahead used for internal scroll alignment. Default: 1
|
|
46
|
+
* @property {number} neighborPad - Minimum space to preserve around the active tab when auto-scrolling rails. Default: 8
|
|
47
|
+
* @property {number} keyNavDebounce - Min time (ms) between key-repeat navigations. Default: 140
|
|
48
|
+
* @property {boolean} navSelectOnButtons - If true, chevron buttons select next/prev tab (not just scroll). Default: false
|
|
49
|
+
* @property {string} color - Base color for the active tab indicator. Supports CSS tokens. Default: "primary"
|
|
50
|
+
*
|
|
51
|
+
* @fires {CustomEvent<SkyTabChangeDetail>} tab-change - Fired when the active tab changes.
|
|
52
|
+
* @method activate Activates the provided tab index (or current index when omitted).
|
|
53
|
+
*
|
|
54
|
+
* @Behavior
|
|
55
|
+
* - Supports horizontal and vertical tab rails with optional overflow controls.
|
|
56
|
+
* - Uses animated thumb positioning and keyboard navigation across tabs.
|
|
57
|
+
* - Supports eager, lazy, and unmount panel mounting strategies.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```html
|
|
61
|
+
* <sky-tab selected-index="1" tab-bar-position="top" overflow-button mount-strategy="lazy" color="primary">
|
|
62
|
+
* <button slot="tab">Overview</button>
|
|
63
|
+
* <button slot="tab">Activity</button>
|
|
64
|
+
* <button slot="tab">Settings</button>
|
|
65
|
+
* <section slot="tab-content">Overview content</section>
|
|
66
|
+
* <section slot="tab-content">Activity content</section>
|
|
67
|
+
* <section slot="tab-content">Settings content</section>
|
|
68
|
+
* </sky-tab>
|
|
69
|
+
* ```
|
|
70
|
+
* ```vue
|
|
71
|
+
* <template>
|
|
72
|
+
* <sky-tab :selected-index="1" tab-bar-position="top" overflow-button mount-strategy="lazy" color="primary">
|
|
73
|
+
* <button slot="tab">Overview</button>
|
|
74
|
+
* <button slot="tab">Activity</button>
|
|
75
|
+
* <button slot="tab">Settings</button>
|
|
76
|
+
* <section slot="tab-content">Overview content</section>
|
|
77
|
+
* <section slot="tab-content">Activity content</section>
|
|
78
|
+
* <section slot="tab-content">Settings content</section>
|
|
79
|
+
* </sky-tab>
|
|
80
|
+
* </template>
|
|
81
|
+
* ```
|
|
82
|
+
* ```jsx
|
|
83
|
+
* export default function Demo() {
|
|
84
|
+
* return (
|
|
85
|
+
* <sky-tab selected-index={1} tab-bar-position="top" overflow-button mount-strategy="lazy" color="primary">
|
|
86
|
+
* <button slot="tab">Overview</button>
|
|
87
|
+
* <button slot="tab">Activity</button>
|
|
88
|
+
* <button slot="tab">Settings</button>
|
|
89
|
+
* <section slot="tab-content">Overview content</section>
|
|
90
|
+
* <section slot="tab-content">Activity content</section>
|
|
91
|
+
* <section slot="tab-content">Settings content</section>
|
|
92
|
+
* </sky-tab>
|
|
93
|
+
* );
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare class SkyTab extends LitElement {
|
|
98
|
+
#private;
|
|
99
|
+
static dependencies: Record<string, CustomElementConstructor>;
|
|
100
|
+
/** Index of the currently selected tab. */
|
|
101
|
+
selectedIndex: number;
|
|
102
|
+
/** Position of the tab bar (`top` | `bottom` | `left` | `right`). */
|
|
103
|
+
tabBarPosition: SkyTabBarPosition;
|
|
104
|
+
/** Explicit height for the tab content container (e.g., `auto`, `400px`, `100%`). */
|
|
105
|
+
panelHeight: string;
|
|
106
|
+
/** Explicit width for the tab content container (e.g., `auto`, `600px`, `100%`). */
|
|
107
|
+
panelWidth: string;
|
|
108
|
+
/** Spacing (gap) between the tab bar and the content area. */
|
|
109
|
+
gutter: string;
|
|
110
|
+
/**
|
|
111
|
+
* Content mount strategy:
|
|
112
|
+
* - "eager": panels are present immediately.
|
|
113
|
+
* - "lazy": panels render but rely on `content-visibility` for perf (default).
|
|
114
|
+
* - "unmount": only the active panel stays in the DOM; others are removed (and optionally cached via `keepAlive`).
|
|
115
|
+
*/
|
|
116
|
+
mountStrategy: SkyTabMountStrategy;
|
|
117
|
+
/** If `mountStrategy="unmount"`, retain DOM in an internal cache for quick re-attachment on revisit. */
|
|
118
|
+
keepAlive: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Show chevron nav buttons & hide native scrollbars when true.
|
|
121
|
+
* When false, hide chevrons and use native scrollbars on the tray.
|
|
122
|
+
*/
|
|
123
|
+
overflowButton: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Rail scroll mode used by nav buttons:
|
|
126
|
+
* - "tab": scrolls to the next/previous tab boundary
|
|
127
|
+
* - "page": scrolls by ~80% of the visible rail
|
|
128
|
+
* - "px": scrolls by a fixed `scrollPx` amount
|
|
129
|
+
*/
|
|
130
|
+
scrollMode: SkyTabScrollMode;
|
|
131
|
+
/** Pixel amount for `scrollMode="px"`. */
|
|
132
|
+
scrollPx: number;
|
|
133
|
+
/** Reserved: Edge padding used in internal scroll calculations. */
|
|
134
|
+
edgePad: number;
|
|
135
|
+
/** Press-and-hold delay (ms) before auto-repeat scroll starts. */
|
|
136
|
+
holdDelay: number;
|
|
137
|
+
/** Press-and-hold repeat interval (ms). */
|
|
138
|
+
holdInterval: number;
|
|
139
|
+
/** Reserved: neighbor look-ahead used for internal scroll alignment. */
|
|
140
|
+
neighbors: number;
|
|
141
|
+
/** Minimum space to preserve around the active tab when auto-scrolling rails. */
|
|
142
|
+
neighborPad: number;
|
|
143
|
+
/** Min time (ms) between key-repeat navigations to let the thumb animate. */
|
|
144
|
+
keyNavDebounce: number;
|
|
145
|
+
/** If true, chevron buttons select next/prev tab (not just scroll). */
|
|
146
|
+
navSelectOnButtons: boolean;
|
|
147
|
+
/** Internal: enable thumb transitions only after first layout. */
|
|
148
|
+
private _ready;
|
|
149
|
+
color: string;
|
|
150
|
+
/** Tracks layout changes to keep the thumb and vertical widths in sync. */
|
|
151
|
+
private _resizeObs?;
|
|
152
|
+
/** Internal cache used when `mountStrategy="unmount"` and `keepAlive=true`. */
|
|
153
|
+
private _cache;
|
|
154
|
+
/** The scrollable rail container element. */
|
|
155
|
+
private _tray?;
|
|
156
|
+
/** The tabs strip element (inside the rail). */
|
|
157
|
+
private _tabsEl?;
|
|
158
|
+
/** WAAPI animation for thumb indicator. */
|
|
159
|
+
private _thumbAnimation?;
|
|
160
|
+
/** Whether a backward nav action is possible (rail overflow & left/up space). */
|
|
161
|
+
private _canBack;
|
|
162
|
+
/** Whether a forward nav action is possible (rail overflow & right/down space). */
|
|
163
|
+
private _canFwd;
|
|
164
|
+
/** Hold-to-scroll timers & state. */
|
|
165
|
+
private _holdTimer;
|
|
166
|
+
private _holdStartTimer;
|
|
167
|
+
private _held;
|
|
168
|
+
private _holdSign?;
|
|
169
|
+
private _keyNavLocked;
|
|
170
|
+
private _keyNavTimer;
|
|
171
|
+
private _keyNavDebouncing;
|
|
172
|
+
/** Last queued direction during debounce: +1 (forward) | -1 (back) | null */
|
|
173
|
+
private _keyQueuedDir;
|
|
174
|
+
private _btnPrev?;
|
|
175
|
+
private _btnNext?;
|
|
176
|
+
private _contentSlot?;
|
|
177
|
+
/** Component styles. */
|
|
178
|
+
static styles: import("lit").CSSResult;
|
|
179
|
+
firstUpdated(): void;
|
|
180
|
+
disconnectedCallback(): void;
|
|
181
|
+
updated(changed: Map<string, unknown>): void;
|
|
182
|
+
private selectTab;
|
|
183
|
+
activate(index?: number): void;
|
|
184
|
+
private _labelSlot?;
|
|
185
|
+
private renderTabs;
|
|
186
|
+
private renderContent;
|
|
187
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
188
|
+
}
|