@nectary/components 2.9.0 → 2.11.0
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/accordion/index.d.ts +11 -0
- package/accordion/index.js +86 -0
- package/accordion/types.d.ts +21 -0
- package/accordion/types.js +1 -0
- package/accordion-item/index.d.ts +14 -0
- package/accordion-item/index.js +95 -0
- package/accordion-item/types.d.ts +36 -0
- package/accordion-item/types.js +1 -0
- package/accordion-item/utils.d.ts +2 -0
- package/accordion-item/utils.js +1 -0
- package/action-menu/index.d.ts +11 -0
- package/action-menu/index.js +195 -0
- package/action-menu/types.d.ts +13 -0
- package/action-menu/types.js +1 -0
- package/action-menu-option/index.d.ts +12 -0
- package/action-menu-option/index.js +82 -0
- package/action-menu-option/types.d.ts +23 -0
- package/action-menu-option/types.js +1 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.d.ts +14 -0
- package/alert/index.js +48 -0
- package/alert/types.d.ts +18 -0
- package/alert/types.js +1 -0
- package/alert/utils.d.ts +2 -0
- package/alert/utils.js +1 -0
- package/avatar/index.d.ts +11 -0
- package/avatar/index.js +94 -0
- package/avatar/types.d.ts +37 -0
- package/avatar/types.js +1 -0
- package/avatar/utils.d.ts +4 -0
- package/avatar/utils.js +7 -0
- package/badge/index.d.ts +11 -0
- package/badge/index.js +114 -0
- package/badge/types.d.ts +34 -0
- package/badge/types.js +1 -0
- package/badge/utils.d.ts +2 -0
- package/badge/utils.js +1 -0
- package/button/index.d.ts +11 -0
- package/button/index.js +182 -0
- package/button/types.d.ts +53 -0
- package/button/types.js +1 -0
- package/button/utils.d.ts +2 -0
- package/button/utils.js +1 -0
- package/card/index.d.ts +13 -0
- package/card/index.js +133 -0
- package/card/types.d.ts +28 -0
- package/card/types.js +1 -0
- package/card-container/index.d.ts +11 -0
- package/card-container/index.js +11 -0
- package/card-container/types.d.ts +3 -0
- package/card-container/types.js +1 -0
- package/chat/index.d.ts +11 -0
- package/chat/index.js +11 -0
- package/chat/types.d.ts +3 -0
- package/chat/types.js +1 -0
- package/chat-block/index.d.ts +11 -0
- package/chat-block/index.js +86 -0
- package/chat-block/types.d.ts +30 -0
- package/chat-block/types.js +1 -0
- package/chat-bubble/index.d.ts +11 -0
- package/chat-bubble/index.js +41 -0
- package/chat-bubble/types.d.ts +20 -0
- package/chat-bubble/types.js +1 -0
- package/chat-bubble/utils.d.ts +3 -0
- package/chat-bubble/utils.js +2 -0
- package/checkbox/index.d.ts +11 -0
- package/checkbox/index.js +126 -0
- package/checkbox/types.d.ts +49 -0
- package/checkbox/types.js +1 -0
- package/chip/index.d.ts +13 -0
- package/chip/index.js +144 -0
- package/chip/types.d.ts +37 -0
- package/chip/types.js +1 -0
- package/chip/utils.d.ts +2 -0
- package/chip/utils.js +6 -0
- package/code-tag/index.d.ts +11 -0
- package/code-tag/index.js +31 -0
- package/code-tag/types.d.ts +11 -0
- package/code-tag/types.js +1 -0
- package/color-menu/index.d.ts +11 -0
- package/color-menu/index.js +308 -0
- package/color-menu/types.d.ts +32 -0
- package/color-menu/types.js +1 -0
- package/color-menu/utils.d.ts +1 -0
- package/color-menu/utils.js +11 -0
- package/color-menu-option/index.d.ts +13 -0
- package/color-menu-option/index.js +48 -0
- package/color-menu-option/types.d.ts +11 -0
- package/color-menu-option/types.js +1 -0
- package/color-menu-option/utils.d.ts +1 -0
- package/color-menu-option/utils.js +11 -0
- package/color-swatch/index.d.ts +12 -0
- package/color-swatch/index.js +54 -0
- package/color-swatch/types.d.ts +11 -0
- package/color-swatch/types.js +1 -0
- package/color-swatch/utils.d.ts +2 -0
- package/color-swatch/utils.js +6 -0
- package/date-picker/index.d.ts +14 -0
- package/date-picker/index.js +381 -0
- package/date-picker/types.d.ts +70 -0
- package/date-picker/types.js +1 -0
- package/date-picker/utils.d.ts +28 -0
- package/date-picker/utils.js +142 -0
- package/dialog/index.d.ts +15 -0
- package/dialog/index.js +144 -0
- package/dialog/types.d.ts +28 -0
- package/dialog/types.js +1 -0
- package/dialog/utils.d.ts +2 -0
- package/dialog/utils.js +18 -0
- package/emoji/index.d.ts +11 -0
- package/emoji/index.js +46 -0
- package/emoji/types.d.ts +11 -0
- package/emoji/types.js +1 -0
- package/emoji/utils.d.ts +3 -0
- package/emoji/utils.js +47 -0
- package/emoji-picker/index.d.ts +22 -0
- package/emoji-picker/index.js +308 -0
- package/emoji-picker/types.d.ts +26 -0
- package/emoji-picker/types.js +1 -0
- package/field/index.d.ts +11 -0
- package/field/index.js +120 -0
- package/field/types.d.ts +35 -0
- package/field/types.js +1 -0
- package/file-drop/index.d.ts +13 -0
- package/file-drop/index.js +205 -0
- package/file-drop/types.d.ts +50 -0
- package/file-drop/types.js +1 -0
- package/file-drop/utils.d.ts +2 -0
- package/file-drop/utils.js +31 -0
- package/file-picker/index.d.ts +11 -0
- package/file-picker/index.js +103 -0
- package/file-picker/types.d.ts +32 -0
- package/file-picker/types.js +1 -0
- package/file-picker/utils.d.ts +1 -0
- package/file-picker/utils.js +8 -0
- package/file-status/index.d.ts +14 -0
- package/file-status/index.js +61 -0
- package/file-status/types.d.ts +18 -0
- package/file-status/types.js +1 -0
- package/file-status/utils.d.ts +2 -0
- package/file-status/utils.js +1 -0
- package/flag/index.d.ts +11 -0
- package/flag/index.js +46 -0
- package/flag/types.d.ts +11 -0
- package/flag/types.js +1 -0
- package/flag/utils.d.ts +1 -0
- package/flag/utils.js +17 -0
- package/grid/index.d.ts +11 -0
- package/grid/index.js +11 -0
- package/grid/types.d.ts +3 -0
- package/grid/types.js +1 -0
- package/grid-item/index.d.ts +11 -0
- package/grid-item/index.js +35 -0
- package/grid-item/types.d.ts +17 -0
- package/grid-item/types.js +1 -0
- package/help-tooltip/index.d.ts +13 -0
- package/help-tooltip/index.js +74 -0
- package/help-tooltip/types.d.ts +3 -0
- package/help-tooltip/types.js +1 -0
- package/horizontal-stepper/index.d.ts +11 -0
- package/horizontal-stepper/index.js +61 -0
- package/horizontal-stepper/types.d.ts +13 -0
- package/horizontal-stepper/types.js +1 -0
- package/horizontal-stepper-item/index.d.ts +14 -0
- package/horizontal-stepper-item/index.js +61 -0
- package/horizontal-stepper-item/types.d.ts +24 -0
- package/horizontal-stepper-item/types.js +1 -0
- package/horizontal-stepper-item/utils.d.ts +2 -0
- package/horizontal-stepper-item/utils.js +1 -0
- package/icon/index.d.ts +11 -0
- package/icon/index.js +32 -0
- package/icon/types.d.ts +11 -0
- package/icon/types.js +1 -0
- package/icon-button/index.d.ts +12 -0
- package/icon-button/index.js +175 -0
- package/icon-button/types.d.ts +44 -0
- package/icon-button/types.js +1 -0
- package/icon-button/utils.d.ts +2 -0
- package/icon-button/utils.js +1 -0
- package/inline-alert/index.d.ts +15 -0
- package/inline-alert/index.js +83 -0
- package/inline-alert/types.d.ts +15 -0
- package/inline-alert/types.js +1 -0
- package/inline-alert/utils.d.ts +2 -0
- package/inline-alert/utils.js +1 -0
- package/input/index.d.ts +11 -0
- package/input/index.js +642 -0
- package/input/types.d.ts +86 -0
- package/input/types.js +1 -0
- package/input/utils.d.ts +26 -0
- package/input/utils.js +302 -0
- package/link/index.d.ts +12 -0
- package/link/index.js +150 -0
- package/link/types.d.ts +59 -0
- package/link/types.js +1 -0
- package/list/index.d.ts +11 -0
- package/list/index.js +14 -0
- package/list/types.d.ts +3 -0
- package/list/types.js +1 -0
- package/list-item/index.d.ts +11 -0
- package/list-item/index.js +14 -0
- package/list-item/types.d.ts +3 -0
- package/list-item/types.js +1 -0
- package/package.json +1 -1
- package/pagination/index.d.ts +12 -0
- package/pagination/index.js +147 -0
- package/pagination/types.d.ts +16 -0
- package/pagination/types.js +1 -0
- package/pop/index.d.ts +11 -0
- package/pop/index.js +425 -0
- package/pop/types.d.ts +35 -0
- package/pop/types.js +1 -0
- package/pop/utils.d.ts +4 -0
- package/pop/utils.js +16 -0
- package/popover/index.d.ts +12 -0
- package/popover/index.js +146 -0
- package/popover/types.d.ts +38 -0
- package/popover/types.js +1 -0
- package/popover/utils.d.ts +4 -0
- package/popover/utils.js +10 -0
- package/progress/index.d.ts +12 -0
- package/progress/index.js +58 -0
- package/progress/types.d.ts +12 -0
- package/progress/types.js +1 -0
- package/progress-stepper/index.d.ts +11 -0
- package/progress-stepper/index.js +206 -0
- package/progress-stepper/types.d.ts +22 -0
- package/progress-stepper/types.js +1 -0
- package/progress-stepper-item/index.d.ts +12 -0
- package/progress-stepper-item/index.js +82 -0
- package/progress-stepper-item/types.d.ts +23 -0
- package/progress-stepper-item/types.js +1 -0
- package/progress-stepper-item/utils.d.ts +11 -0
- package/progress-stepper-item/utils.js +13 -0
- package/radio/index.d.ts +11 -0
- package/radio/index.js +154 -0
- package/radio/types.d.ts +14 -0
- package/radio/types.js +1 -0
- package/radio-option/index.d.ts +11 -0
- package/radio-option/index.js +79 -0
- package/radio-option/types.d.ts +18 -0
- package/radio-option/types.js +1 -0
- package/rich-text/index.d.ts +14 -0
- package/rich-text/index.js +75 -0
- package/rich-text/types.d.ts +12 -0
- package/rich-text/types.js +1 -0
- package/rich-text/utils.d.ts +7 -0
- package/rich-text/utils.js +107 -0
- package/rich-textarea/index.d.ts +11 -0
- package/rich-textarea/index.js +464 -0
- package/rich-textarea/types.d.ts +48 -0
- package/rich-textarea/types.js +1 -0
- package/rich-textarea/utils.d.ts +39 -0
- package/rich-textarea/utils.js +1730 -0
- package/segment/index.d.ts +12 -0
- package/segment/index.js +109 -0
- package/segment/types.d.ts +16 -0
- package/segment/types.js +1 -0
- package/segment/utils.d.ts +3 -0
- package/segment/utils.js +16 -0
- package/segment-collapse/index.d.ts +13 -0
- package/segment-collapse/index.js +60 -0
- package/segment-collapse/types.d.ts +11 -0
- package/segment-collapse/types.js +1 -0
- package/segmented-control/index.d.ts +11 -0
- package/segmented-control/index.js +85 -0
- package/segmented-control/types.d.ts +11 -0
- package/segmented-control/types.js +1 -0
- package/segmented-control-option/index.d.ts +11 -0
- package/segmented-control-option/index.js +95 -0
- package/segmented-control-option/types.d.ts +19 -0
- package/segmented-control-option/types.js +1 -0
- package/segmented-icon-control/index.d.ts +11 -0
- package/segmented-icon-control/index.js +101 -0
- package/segmented-icon-control/types.d.ts +14 -0
- package/segmented-icon-control/types.js +1 -0
- package/segmented-icon-control-option/index.d.ts +11 -0
- package/segmented-icon-control-option/index.js +82 -0
- package/segmented-icon-control-option/types.d.ts +16 -0
- package/segmented-icon-control-option/types.js +1 -0
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +202 -0
- package/select-button/types.d.ts +50 -0
- package/select-button/types.js +1 -0
- package/select-menu/index.d.ts +15 -0
- package/select-menu/index.js +339 -0
- package/select-menu/types.d.ts +41 -0
- package/select-menu/types.js +1 -0
- package/select-menu-option/index.d.ts +28 -0
- package/select-menu-option/index.js +65 -0
- package/select-menu-option/types.d.ts +26 -0
- package/select-menu-option/types.js +1 -0
- package/skeleton/index.d.ts +11 -0
- package/skeleton/index.js +108 -0
- package/skeleton/types.d.ts +9 -0
- package/skeleton/types.js +1 -0
- package/skeleton-item/index.d.ts +11 -0
- package/skeleton-item/index.js +11 -0
- package/skeleton-item/types.d.ts +13 -0
- package/skeleton-item/types.js +1 -0
- package/spinner/index.d.ts +11 -0
- package/spinner/index.js +58 -0
- package/spinner/types.d.ts +12 -0
- package/spinner/types.js +1 -0
- package/standalone.d.ts +85 -0
- package/standalone.js +87 -0
- package/stop-events/index.d.ts +1 -0
- package/stop-events/index.js +27 -0
- package/table/index.d.ts +11 -0
- package/table/index.js +14 -0
- package/table/types.d.ts +3 -0
- package/table/types.js +1 -0
- package/table-body/index.d.ts +11 -0
- package/table-body/index.js +14 -0
- package/table-body/types.d.ts +3 -0
- package/table-body/types.js +1 -0
- package/table-cell/index.d.ts +11 -0
- package/table-cell/index.js +21 -0
- package/table-cell/types.d.ts +9 -0
- package/table-cell/types.js +1 -0
- package/table-cell/utils.d.ts +2 -0
- package/table-cell/utils.js +1 -0
- package/table-head/index.d.ts +11 -0
- package/table-head/index.js +14 -0
- package/table-head/types.d.ts +3 -0
- package/table-head/types.js +1 -0
- package/table-head-cell/index.d.ts +12 -0
- package/table-head-cell/index.js +57 -0
- package/table-head-cell/types.d.ts +15 -0
- package/table-head-cell/types.js +1 -0
- package/table-row/index.d.ts +11 -0
- package/table-row/index.js +42 -0
- package/table-row/types.d.ts +11 -0
- package/table-row/types.js +1 -0
- package/tabs/index.d.ts +11 -0
- package/tabs/index.js +80 -0
- package/tabs/types.d.ts +18 -0
- package/tabs/types.js +1 -0
- package/tabs-icon-option/index.d.ts +11 -0
- package/tabs-icon-option/index.js +79 -0
- package/tabs-icon-option/types.d.ts +19 -0
- package/tabs-icon-option/types.js +1 -0
- package/tabs-option/index.d.ts +12 -0
- package/tabs-option/index.js +86 -0
- package/tabs-option/types.d.ts +25 -0
- package/tabs-option/types.js +1 -0
- package/tag/index.d.ts +12 -0
- package/tag/index.js +84 -0
- package/tag/types.d.ts +23 -0
- package/tag/types.js +1 -0
- package/tag/utils.d.ts +2 -0
- package/tag/utils.js +6 -0
- package/text/index.d.ts +11 -0
- package/text/index.js +64 -0
- package/text/types.d.ts +30 -0
- package/text/types.js +1 -0
- package/text/utils.d.ts +2 -0
- package/text/utils.js +1 -0
- package/textarea/index.d.ts +11 -0
- package/textarea/index.js +322 -0
- package/textarea/types.d.ts +60 -0
- package/textarea/types.js +1 -0
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +110 -0
- package/tile-control/types.d.ts +37 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +98 -0
- package/tile-control-option/types.d.ts +37 -0
- package/tile-control-option/types.js +1 -0
- package/time-picker/index.d.ts +15 -0
- package/time-picker/index.js +337 -0
- package/time-picker/types.d.ts +34 -0
- package/time-picker/types.js +1 -0
- package/time-picker/utils.d.ts +11 -0
- package/time-picker/utils.js +75 -0
- package/title/index.d.ts +11 -0
- package/title/index.js +60 -0
- package/title/types.d.ts +31 -0
- package/title/types.js +1 -0
- package/title/utils.d.ts +3 -0
- package/title/utils.js +17 -0
- package/toast/index.d.ts +13 -0
- package/toast/index.js +86 -0
- package/toast/types.d.ts +28 -0
- package/toast/types.js +1 -0
- package/toast/utils.d.ts +2 -0
- package/toast/utils.js +1 -0
- package/toast-manager/index.d.ts +13 -0
- package/toast-manager/index.js +170 -0
- package/toast-manager/types.d.ts +13 -0
- package/toast-manager/types.js +1 -0
- package/toast-manager/utils.d.ts +2 -0
- package/toast-manager/utils.js +1 -0
- package/toggle/index.d.ts +11 -0
- package/toggle/index.js +141 -0
- package/toggle/types.d.ts +23 -0
- package/toggle/types.js +1 -0
- package/tooltip/index.d.ts +13 -0
- package/tooltip/index.js +275 -0
- package/tooltip/tooltip-state.d.ts +19 -0
- package/tooltip/tooltip-state.js +126 -0
- package/tooltip/types.d.ts +42 -0
- package/tooltip/types.js +1 -0
- package/tooltip/utils.d.ts +6 -0
- package/tooltip/utils.js +18 -0
- package/utils/context.d.ts +20 -0
- package/utils/context.js +84 -0
- package/utils/countries.d.ts +6 -0
- package/utils/countries.js +2 -0
- package/utils/csv.d.ts +5 -0
- package/utils/csv.js +22 -0
- package/utils/debounce.d.ts +8 -0
- package/utils/debounce.js +22 -0
- package/utils/dom.d.ts +34 -0
- package/utils/dom.js +154 -0
- package/utils/element.d.ts +16 -0
- package/utils/element.js +48 -0
- package/utils/event-target.d.ts +4 -0
- package/utils/event-target.js +26 -0
- package/utils/get-react-event-handler.d.ts +1 -0
- package/utils/get-react-event-handler.js +8 -0
- package/utils/index.d.ts +12 -0
- package/utils/index.js +12 -0
- package/utils/markdown.d.ts +19 -0
- package/utils/markdown.js +143 -0
- package/utils/rect.d.ts +4 -0
- package/utils/rect.js +28 -0
- package/utils/size.d.ts +5 -0
- package/utils/size.js +3 -0
- package/utils/slot.d.ts +4 -0
- package/utils/slot.js +38 -0
- package/utils/throttle.d.ts +4 -0
- package/utils/throttle.js +20 -0
- package/utils/uid.d.ts +1 -0
- package/utils/uid.js +13 -0
- package/vertical-stepper/index.d.ts +11 -0
- package/vertical-stepper/index.js +57 -0
- package/vertical-stepper/types.d.ts +13 -0
- package/vertical-stepper/types.js +1 -0
- package/vertical-stepper-item/index.d.ts +14 -0
- package/vertical-stepper-item/index.js +61 -0
- package/vertical-stepper-item/types.d.ts +24 -0
- package/vertical-stepper-item/types.js +1 -0
- package/vertical-stepper-item/utils.d.ts +2 -0
- package/vertical-stepper-item/utils.js +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;background-color:var(--sinch-local-color-background);cursor:pointer;--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon);--sinch-local-shape-radius:var(--sinch-comp-segmented-control-shape-radius);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-default-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-initial)}:host(:hover){--sinch-local-color-background:var(--sinch-comp-segmented-control-color-default-background-hover)}:host(:first-child) #wrapper{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #wrapper{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host([data-checked]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-checked-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-checked-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-checked-background-initial)}:host([disabled]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-disabled-icon-initial);--sinch-local-color-border:var(--sinch-comp-segmented-control-color-disabled-border-initial);--sinch-local-color-background:var(--sinch-comp-segmented-control-color-disabled-background-initial);cursor:initial}#border{position:absolute;inset:0;border:1px solid var(--sinch-local-color-border);pointer-events:none;box-sizing:border-box}:host(:first-child) #border{border-top-left-radius:var(--sinch-local-shape-radius);border-bottom-left-radius:var(--sinch-local-shape-radius)}:host(:last-child) #border{border-top-right-radius:var(--sinch-local-shape-radius);border-bottom-right-radius:var(--sinch-local-shape-radius)}:host(:not(:first-child)) #border{border-left-width:0}:host([data-checked]) #border{border-width:2px}:host([data-checked]:not(:first-child)) #border{left:-1px}#outline{display:none;position:absolute;inset:-3px;border:2px solid var(--sinch-comp-segmented-control-color-default-outline-focus);pointer-events:none;box-sizing:border-box;z-index:1}:host(:focus-visible) #outline{display:block}:host(:first-child) #outline{border-top-left-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-left-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:last-child) #outline{border-top-right-radius:calc(var(--sinch-local-shape-radius) + 3px);border-bottom-right-radius:calc(var(--sinch-local-shape-radius) + 3px)}:host(:not(:first-child)) #outline{left:-4px}::slotted(*){display:block;pointer-events:none}</style><div id="wrapper"><slot name="icon"></slot><div id="border"></div><div id="outline"></div></div>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-segmented-icon-control-option', class extends NectaryElement {
|
|
6
|
+
#controller = null;
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
const shadowRoot = this.attachShadow();
|
|
10
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
11
|
+
}
|
|
12
|
+
connectedCallback() {
|
|
13
|
+
this.#controller = new AbortController();
|
|
14
|
+
const {
|
|
15
|
+
signal
|
|
16
|
+
} = this.#controller;
|
|
17
|
+
const options = {
|
|
18
|
+
signal
|
|
19
|
+
};
|
|
20
|
+
this.role = 'tab';
|
|
21
|
+
this.addEventListener('focus', this.#onButtonFocus, options);
|
|
22
|
+
this.addEventListener('blur', this.#onButtonBlur, options);
|
|
23
|
+
this.addEventListener('-focus', this.#onFocusReactHandler, options);
|
|
24
|
+
this.addEventListener('-blur', this.#onBlurReactHandler, options);
|
|
25
|
+
this.#updateTabIndex();
|
|
26
|
+
}
|
|
27
|
+
disconnectedCallback() {
|
|
28
|
+
this.#controller.abort();
|
|
29
|
+
this.#controller = null;
|
|
30
|
+
}
|
|
31
|
+
static get observedAttributes() {
|
|
32
|
+
return ['data-checked', 'disabled'];
|
|
33
|
+
}
|
|
34
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
35
|
+
switch (name) {
|
|
36
|
+
case 'data-checked':
|
|
37
|
+
{
|
|
38
|
+
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 'disabled':
|
|
42
|
+
{
|
|
43
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
this.#updateTabIndex();
|
|
47
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
set value(value) {
|
|
53
|
+
updateAttribute(this, 'value', value);
|
|
54
|
+
}
|
|
55
|
+
get value() {
|
|
56
|
+
return getAttribute(this, 'value', '');
|
|
57
|
+
}
|
|
58
|
+
set disabled(isDisabled) {
|
|
59
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
60
|
+
}
|
|
61
|
+
get disabled() {
|
|
62
|
+
return getBooleanAttribute(this, 'disabled');
|
|
63
|
+
}
|
|
64
|
+
get focusable() {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
#updateTabIndex() {
|
|
68
|
+
this.tabIndex = this.disabled ? -1 : 0;
|
|
69
|
+
}
|
|
70
|
+
#onButtonFocus = () => {
|
|
71
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
72
|
+
};
|
|
73
|
+
#onButtonBlur = () => {
|
|
74
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
75
|
+
};
|
|
76
|
+
#onFocusReactHandler = () => {
|
|
77
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
78
|
+
};
|
|
79
|
+
#onBlurReactHandler = () => {
|
|
80
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
81
|
+
};
|
|
82
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export type TSinchSegmentedIconControlOptionElement = HTMLElement & {
|
|
3
|
+
value: string;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
6
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
7
|
+
setAttribute(name: 'value', value: string): void;
|
|
8
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
9
|
+
};
|
|
10
|
+
export type TSinchSegmentedIconControlOptionReact = TSinchElementReact<TSinchSegmentedIconControlOptionElement> & {
|
|
11
|
+
value: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
'aria-label': string;
|
|
14
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
15
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../text';
|
|
2
|
+
import '../icon';
|
|
3
|
+
import type { TSinchSelectButtonElement, TSinchSelectButtonReact } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'sinch-select-button': TSinchSelectButtonReact;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'sinch-select-button': TSinchSelectButtonElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import '../text';
|
|
2
|
+
import '../icon';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateLiteralAttribute, Context, isAttrEqual } from '../utils';
|
|
4
|
+
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;cursor:pointer}:host([disabled]){cursor:initial}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:var(--sinch-local-size);padding:0 8px 0 12px;background-color:var(--sinch-comp-select-button-color-default-background-initial);border-radius:var(--sinch-local-shape-radius);--sinch-local-size:var(--sinch-comp-select-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-m);--sinch-global-color-icon:var(--sinch-comp-select-button-color-default-icon-initial)}:host([data-size="l"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-l)}:host([data-size="m"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-m)}:host([data-size="s"])>#wrapper{--sinch-local-size:var(--sinch-comp-select-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-select-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-select-button-shape-radius-size-s)}:host([data-size="l"]) #wrapper{padding:0 12px}:host([data-size="m"]) #wrapper{padding:0 8px 0 12px}:host([data-size="s"]) #wrapper{padding:0 4px 0 12px}:host([disabled]) #wrapper{--sinch-global-color-icon:var(--sinch-comp-select-button-color-disabled-icon-initial)}#text{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-select-button-font-input);--sinch-global-color-text:var(--sinch-comp-select-button-color-default-text-initial)}#text:empty{display:none}#placeholder{display:none;flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-select-button-font-placeholder);--sinch-global-color-text:var(--sinch-comp-select-button-color-default-placeholder-initial)}#text:empty+#placeholder{display:block}#border{position:absolute;border:1px solid var(--sinch-comp-select-button-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}:host(:focus-visible) #border{border-color:var(--sinch-comp-select-button-color-default-border-focus);border-width:2px}:host([invalid]) #border{border-color:var(--sinch-comp-select-button-color-invalid-border-initial)}:host([disabled]) #border{border-color:var(--sinch-comp-select-button-color-disabled-border-initial)}:host([disabled]) #text{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-text-initial)}:host([disabled]) #placeholder{--sinch-global-color-text:var(--sinch-comp-select-button-color-disabled-placeholder-initial)}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;margin-left:-4px}#left.empty{display:none}#dropdown-icon{margin-left:-4px}</style><div id="wrapper" inert><div id="border"></div><div id="left"><slot name="left"></slot></div><slot name="icon"></slot><sinch-text id="text" type="m" ellipsis></sinch-text><sinch-text id="placeholder" type="m" ellipsis></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></div>';
|
|
6
|
+
const template = document.createElement('template');
|
|
7
|
+
template.innerHTML = templateHTML;
|
|
8
|
+
defineCustomElement('sinch-select-button', class extends NectaryElement {
|
|
9
|
+
#$text;
|
|
10
|
+
#$placeholder;
|
|
11
|
+
#$leftSlot;
|
|
12
|
+
#$leftWrapper;
|
|
13
|
+
#$wrapper;
|
|
14
|
+
#controller = null;
|
|
15
|
+
#sizeContext;
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
const shadowRoot = this.attachShadow();
|
|
19
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
20
|
+
this.#$text = shadowRoot.querySelector('#text');
|
|
21
|
+
this.#$placeholder = shadowRoot.querySelector('#placeholder');
|
|
22
|
+
this.#$leftSlot = shadowRoot.querySelector('slot[name="left"]');
|
|
23
|
+
this.#$leftWrapper = shadowRoot.querySelector('#left');
|
|
24
|
+
this.#$wrapper = shadowRoot.querySelector('#wrapper');
|
|
25
|
+
this.#sizeContext = new Context(this.#$wrapper, 'size');
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
super.connectedCallback();
|
|
29
|
+
this.#controller = new AbortController();
|
|
30
|
+
const {
|
|
31
|
+
signal
|
|
32
|
+
} = this.#controller;
|
|
33
|
+
this.role = 'button';
|
|
34
|
+
this.tabIndex = 0;
|
|
35
|
+
this.addEventListener('click', this.#onButtonClick, {
|
|
36
|
+
signal
|
|
37
|
+
});
|
|
38
|
+
this.addEventListener('focus', this.#onButtonFocus, {
|
|
39
|
+
signal
|
|
40
|
+
});
|
|
41
|
+
this.addEventListener('blur', this.#onButtonBlur, {
|
|
42
|
+
signal
|
|
43
|
+
});
|
|
44
|
+
this.addEventListener('keydown', this.#onButtonKeydown, {
|
|
45
|
+
signal
|
|
46
|
+
});
|
|
47
|
+
this.addEventListener('-click', this.#onClickReactHandler, {
|
|
48
|
+
signal
|
|
49
|
+
});
|
|
50
|
+
this.addEventListener('-focus', this.#onFocusReactHandler, {
|
|
51
|
+
signal
|
|
52
|
+
});
|
|
53
|
+
this.addEventListener('-blur', this.#onBlurReactHandler, {
|
|
54
|
+
signal
|
|
55
|
+
});
|
|
56
|
+
this.#$leftSlot.addEventListener('slotchange', this.#onLeftSlotChange, {
|
|
57
|
+
signal
|
|
58
|
+
});
|
|
59
|
+
this.#sizeContext.listen(this.#controller.signal);
|
|
60
|
+
subscribeContext(this, 'size', this.#onContextSize, signal);
|
|
61
|
+
this.#onLeftSlotChange();
|
|
62
|
+
this.#onSizeUpdate();
|
|
63
|
+
}
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
super.disconnectedCallback();
|
|
66
|
+
this.#controller.abort();
|
|
67
|
+
this.#controller = null;
|
|
68
|
+
}
|
|
69
|
+
static get observedAttributes() {
|
|
70
|
+
return ['text', 'placeholder', 'invalid', 'disabled', 'size', 'data-size'];
|
|
71
|
+
}
|
|
72
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
73
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
switch (name) {
|
|
77
|
+
case 'text':
|
|
78
|
+
{
|
|
79
|
+
this.#$text.textContent = newVal;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'placeholder':
|
|
83
|
+
{
|
|
84
|
+
this.#$placeholder.textContent = newVal;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'invalid':
|
|
88
|
+
{
|
|
89
|
+
const isInvalid = isAttrTrue(newVal);
|
|
90
|
+
this.ariaInvalid = isInvalid.toString();
|
|
91
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'disabled':
|
|
95
|
+
{
|
|
96
|
+
const isDisabled = isAttrTrue(newVal);
|
|
97
|
+
this.ariaDisabled = isDisabled.toString();
|
|
98
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'size':
|
|
102
|
+
{
|
|
103
|
+
updateAttribute(this, 'data-size', newVal);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case 'data-size':
|
|
107
|
+
{
|
|
108
|
+
this.#onSizeUpdate();
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
set text(value) {
|
|
114
|
+
updateAttribute(this, 'text', value);
|
|
115
|
+
}
|
|
116
|
+
get text() {
|
|
117
|
+
return getAttribute(this, 'text', '');
|
|
118
|
+
}
|
|
119
|
+
set placeholder(value) {
|
|
120
|
+
updateAttribute(this, 'placeholder', value);
|
|
121
|
+
}
|
|
122
|
+
get placeholder() {
|
|
123
|
+
return getAttribute(this, 'placeholder');
|
|
124
|
+
}
|
|
125
|
+
set invalid(isInvalid) {
|
|
126
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
127
|
+
}
|
|
128
|
+
get invalid() {
|
|
129
|
+
return getBooleanAttribute(this, 'invalid');
|
|
130
|
+
}
|
|
131
|
+
set disabled(isDisabled) {
|
|
132
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
133
|
+
}
|
|
134
|
+
get disabled() {
|
|
135
|
+
return getBooleanAttribute(this, 'disabled');
|
|
136
|
+
}
|
|
137
|
+
set size(size) {
|
|
138
|
+
updateLiteralAttribute(this, sizeValues, 'size', size);
|
|
139
|
+
}
|
|
140
|
+
get size() {
|
|
141
|
+
return getLiteralAttribute(this, sizeValues, 'size', DEFAULT_SIZE);
|
|
142
|
+
}
|
|
143
|
+
get focusable() {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
#onContextSize = e => {
|
|
147
|
+
if (this.hasAttribute('size')) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
switch (e.detail) {
|
|
151
|
+
case 'l':
|
|
152
|
+
{
|
|
153
|
+
this.setAttribute('data-size', 'm');
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
default:
|
|
157
|
+
{
|
|
158
|
+
this.setAttribute('data-size', 's');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
#onSizeUpdate() {
|
|
163
|
+
if (!this.isDomConnected) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
|
|
167
|
+
this.#sizeContext.dispatch(size);
|
|
168
|
+
}
|
|
169
|
+
#onLeftSlotChange = () => {
|
|
170
|
+
setClass(this.#$leftWrapper, 'empty', this.#$leftSlot.assignedElements().length === 0);
|
|
171
|
+
};
|
|
172
|
+
#onButtonFocus = () => {
|
|
173
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
174
|
+
};
|
|
175
|
+
#onButtonBlur = () => {
|
|
176
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
177
|
+
};
|
|
178
|
+
#onButtonKeydown = e => {
|
|
179
|
+
switch (e.code) {
|
|
180
|
+
case 'Space':
|
|
181
|
+
case 'Enter':
|
|
182
|
+
{
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
this.click();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
#onButtonClick = () => {
|
|
189
|
+
if (!this.disabled) {
|
|
190
|
+
this.dispatchEvent(new CustomEvent('-click'));
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
#onClickReactHandler = e => {
|
|
194
|
+
getReactEventHandler(this, 'on-click')?.(e);
|
|
195
|
+
};
|
|
196
|
+
#onFocusReactHandler = () => {
|
|
197
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
198
|
+
};
|
|
199
|
+
#onBlurReactHandler = () => {
|
|
200
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
201
|
+
};
|
|
202
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { TSinchSize } from '../utils/size';
|
|
3
|
+
export type TSinchSelectButtonElement = HTMLElement & {
|
|
4
|
+
/** Text */
|
|
5
|
+
text: string;
|
|
6
|
+
/** Text that appears in the text field when it has no text set */
|
|
7
|
+
placeholder: string;
|
|
8
|
+
/** Invalid state */
|
|
9
|
+
invalid: boolean;
|
|
10
|
+
/** Disabled */
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
/** Size, `m` by default */
|
|
13
|
+
size: TSinchSize;
|
|
14
|
+
/** Click event */
|
|
15
|
+
addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
|
|
16
|
+
/** Focus event */
|
|
17
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
18
|
+
/** Blur event */
|
|
19
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
20
|
+
/** Text */
|
|
21
|
+
setAttribute(name: 'text', value: string): void;
|
|
22
|
+
/** Text that appears in the text field when it has no value set */
|
|
23
|
+
setAttribute(name: 'placeholder', value: string): void;
|
|
24
|
+
/** Invalid state */
|
|
25
|
+
setAttribute(name: 'invalid', value: ''): void;
|
|
26
|
+
/** Disabled */
|
|
27
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
28
|
+
/** Size, `m` by default */
|
|
29
|
+
setAttribute(name: 'size', value: TSinchSize): void;
|
|
30
|
+
};
|
|
31
|
+
export type TSinchSelectButtonReact = TSinchElementReact<TSinchSelectButtonElement> & {
|
|
32
|
+
/** Text */
|
|
33
|
+
text: string;
|
|
34
|
+
/** Label that is used for a11y` */
|
|
35
|
+
'aria-label': string;
|
|
36
|
+
/** Text that appears in the text field when it has no text set */
|
|
37
|
+
placeholder: string;
|
|
38
|
+
/** Invalid state */
|
|
39
|
+
invalid?: boolean;
|
|
40
|
+
/** Disabled */
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** Size, `m` by default */
|
|
43
|
+
size?: TSinchSize;
|
|
44
|
+
/** Click handler */
|
|
45
|
+
'on-click': (e: CustomEvent<void>) => void;
|
|
46
|
+
/** Focus handler */
|
|
47
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
48
|
+
/** Blur handler */
|
|
49
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../input';
|
|
2
|
+
import '../icon-button';
|
|
3
|
+
import '../icon';
|
|
4
|
+
import '../text';
|
|
5
|
+
import type { TSinchSelectMenuElement, TSinchSelectMenuReact } from './types';
|
|
6
|
+
declare global {
|
|
7
|
+
namespace JSX {
|
|
8
|
+
interface IntrinsicElements {
|
|
9
|
+
'sinch-select-menu': TSinchSelectMenuReact;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'sinch-select-menu': TSinchSelectMenuElement;
|
|
14
|
+
}
|
|
15
|
+
}
|