@nectary/components 2.8.7 → 2.9.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/package.json +1 -1
- package/types.d.ts +1 -1
- package/accordion/index.d.ts +0 -11
- package/accordion/index.js +0 -86
- package/accordion/types.d.ts +0 -21
- package/accordion/types.js +0 -1
- package/accordion-item/index.d.ts +0 -14
- package/accordion-item/index.js +0 -95
- package/accordion-item/types.d.ts +0 -36
- package/accordion-item/types.js +0 -1
- package/accordion-item/utils.d.ts +0 -2
- package/accordion-item/utils.js +0 -1
- package/action-menu/index.d.ts +0 -11
- package/action-menu/index.js +0 -195
- package/action-menu/types.d.ts +0 -13
- package/action-menu/types.js +0 -1
- package/action-menu-option/index.d.ts +0 -12
- package/action-menu-option/index.js +0 -82
- package/action-menu-option/types.d.ts +0 -23
- package/action-menu-option/types.js +0 -1
- package/action-menu-option/utils.d.ts +0 -2
- package/action-menu-option/utils.js +0 -3
- package/alert/index.d.ts +0 -14
- package/alert/index.js +0 -48
- package/alert/types.d.ts +0 -18
- package/alert/types.js +0 -1
- package/alert/utils.d.ts +0 -2
- package/alert/utils.js +0 -1
- package/avatar/index.d.ts +0 -11
- package/avatar/index.js +0 -94
- package/avatar/types.d.ts +0 -37
- package/avatar/types.js +0 -1
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +0 -7
- package/badge/index.d.ts +0 -11
- package/badge/index.js +0 -114
- package/badge/types.d.ts +0 -34
- package/badge/types.js +0 -1
- package/badge/utils.d.ts +0 -2
- package/badge/utils.js +0 -1
- package/button/index.d.ts +0 -11
- package/button/index.js +0 -182
- package/button/types.d.ts +0 -53
- package/button/types.js +0 -1
- package/button/utils.d.ts +0 -2
- package/button/utils.js +0 -1
- package/card/index.d.ts +0 -13
- package/card/index.js +0 -133
- package/card/types.d.ts +0 -28
- package/card/types.js +0 -1
- package/card-container/index.d.ts +0 -11
- package/card-container/index.js +0 -11
- package/card-container/types.d.ts +0 -3
- package/card-container/types.js +0 -1
- package/chat/index.d.ts +0 -11
- package/chat/index.js +0 -11
- package/chat/types.d.ts +0 -3
- package/chat/types.js +0 -1
- package/chat-block/index.d.ts +0 -11
- package/chat-block/index.js +0 -86
- package/chat-block/types.d.ts +0 -30
- package/chat-block/types.js +0 -1
- package/chat-bubble/index.d.ts +0 -11
- package/chat-bubble/index.js +0 -41
- package/chat-bubble/types.d.ts +0 -20
- package/chat-bubble/types.js +0 -1
- package/chat-bubble/utils.d.ts +0 -3
- package/chat-bubble/utils.js +0 -2
- package/checkbox/index.d.ts +0 -11
- package/checkbox/index.js +0 -126
- package/checkbox/types.d.ts +0 -49
- package/checkbox/types.js +0 -1
- package/chip/index.d.ts +0 -13
- package/chip/index.js +0 -144
- package/chip/types.d.ts +0 -37
- package/chip/types.js +0 -1
- package/chip/utils.d.ts +0 -2
- package/chip/utils.js +0 -6
- package/code-tag/index.d.ts +0 -11
- package/code-tag/index.js +0 -31
- package/code-tag/types.d.ts +0 -11
- package/code-tag/types.js +0 -1
- package/color-menu/index.d.ts +0 -11
- package/color-menu/index.js +0 -308
- package/color-menu/types.d.ts +0 -32
- package/color-menu/types.js +0 -1
- package/color-menu/utils.d.ts +0 -1
- package/color-menu/utils.js +0 -11
- package/color-menu-option/index.d.ts +0 -13
- package/color-menu-option/index.js +0 -48
- package/color-menu-option/types.d.ts +0 -11
- package/color-menu-option/types.js +0 -1
- package/color-menu-option/utils.d.ts +0 -1
- package/color-menu-option/utils.js +0 -11
- package/color-swatch/index.d.ts +0 -12
- package/color-swatch/index.js +0 -54
- package/color-swatch/types.d.ts +0 -11
- package/color-swatch/types.js +0 -1
- package/color-swatch/utils.d.ts +0 -2
- package/color-swatch/utils.js +0 -6
- package/date-picker/index.d.ts +0 -14
- package/date-picker/index.js +0 -381
- package/date-picker/types.d.ts +0 -70
- package/date-picker/types.js +0 -1
- package/date-picker/utils.d.ts +0 -28
- package/date-picker/utils.js +0 -142
- package/dialog/index.d.ts +0 -15
- package/dialog/index.js +0 -144
- package/dialog/types.d.ts +0 -28
- package/dialog/types.js +0 -1
- package/dialog/utils.d.ts +0 -2
- package/dialog/utils.js +0 -18
- package/emoji/index.d.ts +0 -11
- package/emoji/index.js +0 -46
- package/emoji/types.d.ts +0 -11
- package/emoji/types.js +0 -1
- package/emoji/utils.d.ts +0 -3
- package/emoji/utils.js +0 -47
- package/emoji-picker/index.d.ts +0 -22
- package/emoji-picker/index.js +0 -308
- package/emoji-picker/types.d.ts +0 -26
- package/emoji-picker/types.js +0 -1
- package/field/index.d.ts +0 -11
- package/field/index.js +0 -120
- package/field/types.d.ts +0 -35
- package/field/types.js +0 -1
- package/file-drop/index.d.ts +0 -13
- package/file-drop/index.js +0 -205
- package/file-drop/types.d.ts +0 -50
- package/file-drop/types.js +0 -1
- package/file-drop/utils.d.ts +0 -2
- package/file-drop/utils.js +0 -31
- package/file-picker/index.d.ts +0 -11
- package/file-picker/index.js +0 -103
- package/file-picker/types.d.ts +0 -32
- package/file-picker/types.js +0 -1
- package/file-picker/utils.d.ts +0 -1
- package/file-picker/utils.js +0 -8
- package/file-status/index.d.ts +0 -14
- package/file-status/index.js +0 -61
- package/file-status/types.d.ts +0 -18
- package/file-status/types.js +0 -1
- package/file-status/utils.d.ts +0 -2
- package/file-status/utils.js +0 -1
- package/flag/index.d.ts +0 -11
- package/flag/index.js +0 -46
- package/flag/types.d.ts +0 -11
- package/flag/types.js +0 -1
- package/flag/utils.d.ts +0 -1
- package/flag/utils.js +0 -17
- package/grid/index.d.ts +0 -11
- package/grid/index.js +0 -11
- package/grid/types.d.ts +0 -3
- package/grid/types.js +0 -1
- package/grid-item/index.d.ts +0 -11
- package/grid-item/index.js +0 -35
- package/grid-item/types.d.ts +0 -17
- package/grid-item/types.js +0 -1
- package/help-tooltip/index.d.ts +0 -13
- package/help-tooltip/index.js +0 -74
- package/help-tooltip/types.d.ts +0 -3
- package/help-tooltip/types.js +0 -1
- package/horizontal-stepper/index.d.ts +0 -11
- package/horizontal-stepper/index.js +0 -61
- package/horizontal-stepper/types.d.ts +0 -13
- package/horizontal-stepper/types.js +0 -1
- package/horizontal-stepper-item/index.d.ts +0 -14
- package/horizontal-stepper-item/index.js +0 -61
- package/horizontal-stepper-item/types.d.ts +0 -24
- package/horizontal-stepper-item/types.js +0 -1
- package/horizontal-stepper-item/utils.d.ts +0 -2
- package/horizontal-stepper-item/utils.js +0 -1
- package/icon/index.d.ts +0 -11
- package/icon/index.js +0 -32
- package/icon/types.d.ts +0 -11
- package/icon/types.js +0 -1
- package/icon-button/index.d.ts +0 -12
- package/icon-button/index.js +0 -175
- package/icon-button/types.d.ts +0 -44
- package/icon-button/types.js +0 -1
- package/icon-button/utils.d.ts +0 -2
- package/icon-button/utils.js +0 -1
- package/inline-alert/index.d.ts +0 -15
- package/inline-alert/index.js +0 -83
- package/inline-alert/types.d.ts +0 -15
- package/inline-alert/types.js +0 -1
- package/inline-alert/utils.d.ts +0 -2
- package/inline-alert/utils.js +0 -1
- package/input/index.d.ts +0 -11
- package/input/index.js +0 -637
- package/input/types.d.ts +0 -86
- package/input/types.js +0 -1
- package/input/utils.d.ts +0 -26
- package/input/utils.js +0 -302
- package/link/index.d.ts +0 -12
- package/link/index.js +0 -150
- package/link/types.d.ts +0 -59
- package/link/types.js +0 -1
- package/list/index.d.ts +0 -11
- package/list/index.js +0 -14
- package/list/types.d.ts +0 -3
- package/list/types.js +0 -1
- package/list-item/index.d.ts +0 -11
- package/list-item/index.js +0 -14
- package/list-item/types.d.ts +0 -3
- package/list-item/types.js +0 -1
- package/pagination/index.d.ts +0 -12
- package/pagination/index.js +0 -147
- package/pagination/types.d.ts +0 -16
- package/pagination/types.js +0 -1
- package/pop/index.d.ts +0 -11
- package/pop/index.js +0 -425
- package/pop/types.d.ts +0 -35
- package/pop/types.js +0 -1
- package/pop/utils.d.ts +0 -4
- package/pop/utils.js +0 -16
- package/popover/index.d.ts +0 -12
- package/popover/index.js +0 -146
- package/popover/types.d.ts +0 -40
- package/popover/types.js +0 -1
- package/popover/utils.d.ts +0 -4
- package/popover/utils.js +0 -10
- package/progress/index.d.ts +0 -12
- package/progress/index.js +0 -58
- package/progress/types.d.ts +0 -12
- package/progress/types.js +0 -1
- package/progress-stepper/index.d.ts +0 -11
- package/progress-stepper/index.js +0 -206
- package/progress-stepper/types.d.ts +0 -22
- package/progress-stepper/types.js +0 -1
- package/progress-stepper-item/index.d.ts +0 -12
- package/progress-stepper-item/index.js +0 -82
- package/progress-stepper-item/types.d.ts +0 -23
- package/progress-stepper-item/types.js +0 -1
- package/progress-stepper-item/utils.d.ts +0 -11
- package/progress-stepper-item/utils.js +0 -13
- package/radio/index.d.ts +0 -11
- package/radio/index.js +0 -154
- package/radio/types.d.ts +0 -14
- package/radio/types.js +0 -1
- package/radio-option/index.d.ts +0 -11
- package/radio-option/index.js +0 -79
- package/radio-option/types.d.ts +0 -18
- package/radio-option/types.js +0 -1
- package/rich-text/index.d.ts +0 -14
- package/rich-text/index.js +0 -75
- package/rich-text/types.d.ts +0 -12
- package/rich-text/types.js +0 -1
- package/rich-text/utils.d.ts +0 -7
- package/rich-text/utils.js +0 -107
- package/rich-textarea/index.d.ts +0 -11
- package/rich-textarea/index.js +0 -464
- package/rich-textarea/types.d.ts +0 -48
- package/rich-textarea/types.js +0 -1
- package/rich-textarea/utils.d.ts +0 -39
- package/rich-textarea/utils.js +0 -1730
- package/segment/index.d.ts +0 -12
- package/segment/index.js +0 -109
- package/segment/types.d.ts +0 -16
- package/segment/types.js +0 -1
- package/segment/utils.d.ts +0 -3
- package/segment/utils.js +0 -16
- package/segment-collapse/index.d.ts +0 -13
- package/segment-collapse/index.js +0 -60
- package/segment-collapse/types.d.ts +0 -11
- package/segment-collapse/types.js +0 -1
- package/segmented-control/index.d.ts +0 -11
- package/segmented-control/index.js +0 -85
- package/segmented-control/types.d.ts +0 -11
- package/segmented-control/types.js +0 -1
- package/segmented-control-option/index.d.ts +0 -11
- package/segmented-control-option/index.js +0 -95
- package/segmented-control-option/types.d.ts +0 -19
- package/segmented-control-option/types.js +0 -1
- package/segmented-icon-control/index.d.ts +0 -11
- package/segmented-icon-control/index.js +0 -101
- package/segmented-icon-control/types.d.ts +0 -14
- package/segmented-icon-control/types.js +0 -1
- package/segmented-icon-control-option/index.d.ts +0 -11
- package/segmented-icon-control-option/index.js +0 -82
- package/segmented-icon-control-option/types.d.ts +0 -16
- package/segmented-icon-control-option/types.js +0 -1
- package/select-button/index.d.ts +0 -13
- package/select-button/index.js +0 -202
- package/select-button/types.d.ts +0 -50
- package/select-button/types.js +0 -1
- package/select-menu/index.d.ts +0 -15
- package/select-menu/index.js +0 -332
- package/select-menu/types.d.ts +0 -41
- package/select-menu/types.js +0 -1
- package/select-menu-option/index.d.ts +0 -28
- package/select-menu-option/index.js +0 -65
- package/select-menu-option/types.d.ts +0 -26
- package/select-menu-option/types.js +0 -1
- package/skeleton/index.d.ts +0 -11
- package/skeleton/index.js +0 -108
- package/skeleton/types.d.ts +0 -9
- package/skeleton/types.js +0 -1
- package/skeleton-item/index.d.ts +0 -11
- package/skeleton-item/index.js +0 -11
- package/skeleton-item/types.d.ts +0 -13
- package/skeleton-item/types.js +0 -1
- package/spinner/index.d.ts +0 -11
- package/spinner/index.js +0 -58
- package/spinner/types.d.ts +0 -12
- package/spinner/types.js +0 -1
- package/standalone.d.ts +0 -85
- package/standalone.js +0 -87
- package/stop-events/index.d.ts +0 -1
- package/stop-events/index.js +0 -27
- package/table/index.d.ts +0 -11
- package/table/index.js +0 -14
- package/table/types.d.ts +0 -3
- package/table/types.js +0 -1
- package/table-body/index.d.ts +0 -11
- package/table-body/index.js +0 -14
- package/table-body/types.d.ts +0 -3
- package/table-body/types.js +0 -1
- package/table-cell/index.d.ts +0 -11
- package/table-cell/index.js +0 -21
- package/table-cell/types.d.ts +0 -9
- package/table-cell/types.js +0 -1
- package/table-cell/utils.d.ts +0 -2
- package/table-cell/utils.js +0 -1
- package/table-head/index.d.ts +0 -11
- package/table-head/index.js +0 -14
- package/table-head/types.d.ts +0 -3
- package/table-head/types.js +0 -1
- package/table-head-cell/index.d.ts +0 -12
- package/table-head-cell/index.js +0 -57
- package/table-head-cell/types.d.ts +0 -15
- package/table-head-cell/types.js +0 -1
- package/table-row/index.d.ts +0 -11
- package/table-row/index.js +0 -42
- package/table-row/types.d.ts +0 -11
- package/table-row/types.js +0 -1
- package/tabs/index.d.ts +0 -11
- package/tabs/index.js +0 -80
- package/tabs/types.d.ts +0 -18
- package/tabs/types.js +0 -1
- package/tabs-icon-option/index.d.ts +0 -11
- package/tabs-icon-option/index.js +0 -79
- package/tabs-icon-option/types.d.ts +0 -19
- package/tabs-icon-option/types.js +0 -1
- package/tabs-option/index.d.ts +0 -12
- package/tabs-option/index.js +0 -86
- package/tabs-option/types.d.ts +0 -25
- package/tabs-option/types.js +0 -1
- package/tag/index.d.ts +0 -12
- package/tag/index.js +0 -84
- package/tag/types.d.ts +0 -23
- package/tag/types.js +0 -1
- package/tag/utils.d.ts +0 -2
- package/tag/utils.js +0 -6
- package/text/index.d.ts +0 -11
- package/text/index.js +0 -64
- package/text/types.d.ts +0 -30
- package/text/types.js +0 -1
- package/text/utils.d.ts +0 -2
- package/text/utils.js +0 -1
- package/textarea/index.d.ts +0 -11
- package/textarea/index.js +0 -322
- package/textarea/types.d.ts +0 -60
- package/textarea/types.js +0 -1
- package/tile-control/index.d.ts +0 -11
- package/tile-control/index.js +0 -110
- package/tile-control/types.d.ts +0 -37
- package/tile-control/types.js +0 -1
- package/tile-control-option/index.d.ts +0 -11
- package/tile-control-option/index.js +0 -98
- package/tile-control-option/types.d.ts +0 -37
- package/tile-control-option/types.js +0 -1
- package/time-picker/index.d.ts +0 -15
- package/time-picker/index.js +0 -337
- package/time-picker/types.d.ts +0 -34
- package/time-picker/types.js +0 -1
- package/time-picker/utils.d.ts +0 -11
- package/time-picker/utils.js +0 -75
- package/title/index.d.ts +0 -11
- package/title/index.js +0 -60
- package/title/types.d.ts +0 -31
- package/title/types.js +0 -1
- package/title/utils.d.ts +0 -3
- package/title/utils.js +0 -17
- package/toast/index.d.ts +0 -13
- package/toast/index.js +0 -86
- package/toast/types.d.ts +0 -28
- package/toast/types.js +0 -1
- package/toast/utils.d.ts +0 -2
- package/toast/utils.js +0 -1
- package/toast-manager/index.d.ts +0 -13
- package/toast-manager/index.js +0 -170
- package/toast-manager/types.d.ts +0 -13
- package/toast-manager/types.js +0 -1
- package/toast-manager/utils.d.ts +0 -2
- package/toast-manager/utils.js +0 -1
- package/toggle/index.d.ts +0 -11
- package/toggle/index.js +0 -141
- package/toggle/types.d.ts +0 -23
- package/toggle/types.js +0 -1
- package/tooltip/index.d.ts +0 -13
- package/tooltip/index.js +0 -264
- package/tooltip/tooltip-state.d.ts +0 -19
- package/tooltip/tooltip-state.js +0 -126
- package/tooltip/types.d.ts +0 -35
- package/tooltip/types.js +0 -1
- package/tooltip/utils.d.ts +0 -5
- package/tooltip/utils.js +0 -17
- package/utils/context.d.ts +0 -20
- package/utils/context.js +0 -84
- package/utils/countries.d.ts +0 -6
- package/utils/countries.js +0 -2
- package/utils/csv.d.ts +0 -5
- package/utils/csv.js +0 -22
- package/utils/debounce.d.ts +0 -8
- package/utils/debounce.js +0 -22
- package/utils/dom.d.ts +0 -34
- package/utils/dom.js +0 -154
- package/utils/element.d.ts +0 -16
- package/utils/element.js +0 -48
- package/utils/event-target.d.ts +0 -4
- package/utils/event-target.js +0 -26
- package/utils/get-react-event-handler.d.ts +0 -1
- package/utils/get-react-event-handler.js +0 -8
- package/utils/index.d.ts +0 -12
- package/utils/index.js +0 -12
- package/utils/markdown.d.ts +0 -19
- package/utils/markdown.js +0 -143
- package/utils/rect.d.ts +0 -4
- package/utils/rect.js +0 -28
- package/utils/size.d.ts +0 -5
- package/utils/size.js +0 -3
- package/utils/slot.d.ts +0 -4
- package/utils/slot.js +0 -38
- package/utils/throttle.d.ts +0 -4
- package/utils/throttle.js +0 -20
- package/utils/uid.d.ts +0 -1
- package/utils/uid.js +0 -13
- package/vertical-stepper/index.d.ts +0 -11
- package/vertical-stepper/index.js +0 -57
- package/vertical-stepper/types.d.ts +0 -13
- package/vertical-stepper/types.js +0 -1
- package/vertical-stepper-item/index.d.ts +0 -14
- package/vertical-stepper-item/index.js +0 -61
- package/vertical-stepper-item/types.d.ts +0 -24
- package/vertical-stepper-item/types.js +0 -1
- package/vertical-stepper-item/utils.d.ts +0 -2
- package/vertical-stepper-item/utils.js +0 -1
package/segment/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '../title';
|
|
2
|
-
import type { TSinchSegmentElement, TSinchSegmentReact } from './types';
|
|
3
|
-
declare global {
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface IntrinsicElements {
|
|
6
|
-
'sinch-segment': TSinchSegmentReact;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
interface HTMLElementTagNameMap {
|
|
10
|
-
'sinch-segment': TSinchSegmentElement;
|
|
11
|
-
}
|
|
12
|
-
}
|
package/segment/index.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import '../title';
|
|
2
|
-
import { getTitleLevelFromType } from '../title/utils';
|
|
3
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
4
|
-
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:12px;width:100%;height:100%;border:1px solid var(--sinch-comp-segment-color-default-border-initial);border-radius:var(--sinch-comp-segment-shape-radius);box-sizing:border-box;background-color:var(--sinch-comp-segment-color-default-background-initial);padding:8px 0 16px}#header{display:flex;flex-direction:row;align-items:center;height:48px;gap:8px;padding:0 24px}#icon{--sinch-global-size-icon:32px}#caption{min-width:1em;--sinch-comp-title-font:var(--sinch-comp-segment-font-size-m-title)}:host([size="l"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-l-title)}:host([size="s"]) #caption{--sinch-comp-title-font:var(--sinch-comp-segment-font-size-s-title)}#info{display:flex;flex-direction:row;align-items:center;gap:8px;margin-left:auto;align-self:stretch}#info.empty{display:none}#preview{flex:1;flex-basis:auto;height:48px;min-width:0;overflow:hidden;margin-left:24px}#preview.empty{display:none}#info.empty+#collapse{margin-left:auto}#collapse.empty{display:none}#preview:not(.empty)+#info.empty+#collapse:not(.empty),#preview:not(.empty)+#info:not(.empty){margin-left:24px}#content-wrapper{flex:1;min-height:0;overflow-y:auto;padding:4px 24px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:0 24px}#action.empty{display:none}:host([collapsed]) :is(#content-wrapper,#action){display:none}:host([collapsed]) #wrapper{padding-bottom:8px}::slotted([slot=icon]){margin-right:8px}</style><div id="wrapper"><div id="header"><slot id="icon" name="icon"></slot><sinch-title id="caption" level="3" type="m" ellipsis></sinch-title><div id="preview"><slot name="preview"></slot></div><div id="info"><slot name="info"></slot></div><div id="collapse"><slot name="collapse"></slot></div></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
6
|
-
import { getTitleTypeFromSize } from './utils';
|
|
7
|
-
const template = document.createElement('template');
|
|
8
|
-
template.innerHTML = templateHTML;
|
|
9
|
-
defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
10
|
-
#$caption;
|
|
11
|
-
#$previewSlot;
|
|
12
|
-
#$previewWrapper;
|
|
13
|
-
#$infoSlot;
|
|
14
|
-
#$infoWrapper;
|
|
15
|
-
#$collapseSlot;
|
|
16
|
-
#$collapseWrapper;
|
|
17
|
-
#$actionSlot;
|
|
18
|
-
#$actionWrapper;
|
|
19
|
-
constructor() {
|
|
20
|
-
super();
|
|
21
|
-
const shadowRoot = this.attachShadow();
|
|
22
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
23
|
-
this.#$caption = shadowRoot.querySelector('#caption');
|
|
24
|
-
this.#$previewSlot = shadowRoot.querySelector('slot[name="preview"]');
|
|
25
|
-
this.#$infoSlot = shadowRoot.querySelector('slot[name="info"]');
|
|
26
|
-
this.#$collapseSlot = shadowRoot.querySelector('slot[name="collapse"]');
|
|
27
|
-
this.#$actionSlot = shadowRoot.querySelector('slot[name="action"]');
|
|
28
|
-
this.#$previewWrapper = shadowRoot.querySelector('#preview');
|
|
29
|
-
this.#$infoWrapper = shadowRoot.querySelector('#info');
|
|
30
|
-
this.#$collapseWrapper = shadowRoot.querySelector('#collapse');
|
|
31
|
-
this.#$actionWrapper = shadowRoot.querySelector('#action');
|
|
32
|
-
}
|
|
33
|
-
connectedCallback() {
|
|
34
|
-
this.#$previewSlot.addEventListener('slotchange', this.#onPreviewSlotChange);
|
|
35
|
-
this.#$infoSlot.addEventListener('slotchange', this.#onInfoSlotChange);
|
|
36
|
-
this.#$collapseSlot.addEventListener('slotchange', this.#onCollapseSlotChange);
|
|
37
|
-
this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
|
|
38
|
-
this.#onPreviewSlotChange();
|
|
39
|
-
this.#onInfoSlotChange();
|
|
40
|
-
this.#onCollapseSlotChange();
|
|
41
|
-
this.#onActionSlotChange();
|
|
42
|
-
}
|
|
43
|
-
disconnectedCallback() {
|
|
44
|
-
this.#$previewSlot.removeEventListener('slotchange', this.#onPreviewSlotChange);
|
|
45
|
-
this.#$infoSlot.removeEventListener('slotchange', this.#onInfoSlotChange);
|
|
46
|
-
this.#$collapseSlot.removeEventListener('slotchange', this.#onCollapseSlotChange);
|
|
47
|
-
this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
|
|
48
|
-
}
|
|
49
|
-
static get observedAttributes() {
|
|
50
|
-
return ['caption', 'collapsed', 'size'];
|
|
51
|
-
}
|
|
52
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
53
|
-
switch (name) {
|
|
54
|
-
case 'caption':
|
|
55
|
-
{
|
|
56
|
-
updateAttribute(this.#$caption, 'text', newVal);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
case 'collapsed':
|
|
60
|
-
{
|
|
61
|
-
if (isAttrEqual(oldVal, newVal)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
case 'size':
|
|
68
|
-
{
|
|
69
|
-
const titleType = getTitleTypeFromSize(this.size);
|
|
70
|
-
updateAttribute(this.#$caption, 'level', getTitleLevelFromType(titleType));
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
set caption(caption) {
|
|
76
|
-
updateAttribute(this, 'caption', caption);
|
|
77
|
-
}
|
|
78
|
-
get caption() {
|
|
79
|
-
return getAttribute(this, 'caption', '');
|
|
80
|
-
}
|
|
81
|
-
set collapsed(isChecked) {
|
|
82
|
-
updateBooleanAttribute(this, 'collapsed', isChecked);
|
|
83
|
-
}
|
|
84
|
-
get collapsed() {
|
|
85
|
-
return getBooleanAttribute(this, 'collapsed');
|
|
86
|
-
}
|
|
87
|
-
get size() {
|
|
88
|
-
return getLiteralAttribute(this, sizeValues, 'size', DEFAULT_SIZE);
|
|
89
|
-
}
|
|
90
|
-
set size(value) {
|
|
91
|
-
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
92
|
-
}
|
|
93
|
-
get collapseButtonRect() {
|
|
94
|
-
const $collapseButton = this.#$collapseSlot.assignedElements()[0];
|
|
95
|
-
return $collapseButton != null ? getRect($collapseButton) : null;
|
|
96
|
-
}
|
|
97
|
-
#onPreviewSlotChange = () => {
|
|
98
|
-
setClass(this.#$previewWrapper, 'empty', this.#$previewSlot.assignedElements().length === 0);
|
|
99
|
-
};
|
|
100
|
-
#onInfoSlotChange = () => {
|
|
101
|
-
setClass(this.#$infoWrapper, 'empty', this.#$infoSlot.assignedElements().length === 0);
|
|
102
|
-
};
|
|
103
|
-
#onCollapseSlotChange = () => {
|
|
104
|
-
setClass(this.#$collapseWrapper, 'empty', this.#$collapseSlot.assignedElements().length === 0);
|
|
105
|
-
};
|
|
106
|
-
#onActionSlotChange = () => {
|
|
107
|
-
setClass(this.#$actionWrapper, 'empty', this.#$actionSlot.assignedElements().length === 0);
|
|
108
|
-
};
|
|
109
|
-
});
|
package/segment/types.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
-
import type { TSinchSize } from '../utils/size';
|
|
3
|
-
export type TSinchSegmentElement = HTMLElement & {
|
|
4
|
-
caption: string;
|
|
5
|
-
collapsed: boolean;
|
|
6
|
-
size: TSinchSize;
|
|
7
|
-
readonly collapseButtonRect: TRect | null;
|
|
8
|
-
setAttribute(name: 'caption', value: string): void;
|
|
9
|
-
setAttribute(name: 'collapsed', value: ''): void;
|
|
10
|
-
setAttribute(name: 'size', value: TSinchSize): void;
|
|
11
|
-
};
|
|
12
|
-
export type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
|
|
13
|
-
caption: string;
|
|
14
|
-
collapsed?: boolean;
|
|
15
|
-
size?: TSinchSize;
|
|
16
|
-
};
|
package/segment/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/segment/utils.d.ts
DELETED
package/segment/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import '../icon';
|
|
2
|
-
import '../icon-button';
|
|
3
|
-
import type { TSinchSegmentExpandElement, TSinchSegmentExpandReact } from './types';
|
|
4
|
-
declare global {
|
|
5
|
-
namespace JSX {
|
|
6
|
-
interface IntrinsicElements {
|
|
7
|
-
'sinch-segment-collapse': TSinchSegmentExpandReact;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
interface HTMLElementTagNameMap {
|
|
11
|
-
'sinch-segment-collapse': TSinchSegmentExpandElement;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import '../icon';
|
|
2
|
-
import '../icon-button';
|
|
3
|
-
import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
4
|
-
const templateHTML = '<style>:host{display:block;--sinch-global-size-icon:32px}#icon-dropdown{display:block;will-change:transform;transform:rotate(180deg)}:host([value]:not([value=false])) #icon-dropdown{transform:rotate(0)}</style><sinch-icon-button id="button" size="s"><sinch-icon id="icon-dropdown" slot="icon" name="keyboard_arrow_down"></sinch-icon></sinch-icon-button>';
|
|
5
|
-
const template = document.createElement('template');
|
|
6
|
-
template.innerHTML = templateHTML;
|
|
7
|
-
defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
8
|
-
#$button;
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
const shadowRoot = this.attachShadow();
|
|
12
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
|
-
this.#$button = shadowRoot.querySelector('#button');
|
|
14
|
-
}
|
|
15
|
-
connectedCallback() {
|
|
16
|
-
this.setAttribute('role', 'checkbox');
|
|
17
|
-
this.#$button.addEventListener('click', this.#onClick);
|
|
18
|
-
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
19
|
-
}
|
|
20
|
-
disconnectedCallback() {
|
|
21
|
-
this.#$button.removeEventListener('click', this.#onClick);
|
|
22
|
-
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
23
|
-
}
|
|
24
|
-
static get observedAttributes() {
|
|
25
|
-
return ['value'];
|
|
26
|
-
}
|
|
27
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
28
|
-
switch (name) {
|
|
29
|
-
case 'value':
|
|
30
|
-
{
|
|
31
|
-
updateExplicitBooleanAttribute(this, 'aria-checked', isAttrTrue(newVal));
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
set value(isChecked) {
|
|
37
|
-
updateBooleanAttribute(this, 'value', isChecked);
|
|
38
|
-
}
|
|
39
|
-
get value() {
|
|
40
|
-
return getBooleanAttribute(this, 'value');
|
|
41
|
-
}
|
|
42
|
-
get focusable() {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
focus() {
|
|
46
|
-
this.#$button.focus();
|
|
47
|
-
}
|
|
48
|
-
blur() {
|
|
49
|
-
this.#$button.blur();
|
|
50
|
-
}
|
|
51
|
-
#onClick = () => {
|
|
52
|
-
const detail = !this.value;
|
|
53
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
54
|
-
detail
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
|
-
#onChangeReactHandler = e => {
|
|
58
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
59
|
-
};
|
|
60
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchSegmentExpandElement = HTMLElement & {
|
|
3
|
-
value: boolean;
|
|
4
|
-
addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
5
|
-
setAttribute(name: 'value', value: string): void;
|
|
6
|
-
};
|
|
7
|
-
export type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
|
|
8
|
-
value: boolean;
|
|
9
|
-
'aria-label': string;
|
|
10
|
-
'on-change'?: (e: CustomEvent<boolean>) => void;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchSegmentedControlElement, TSinchSegmentedControlReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-segmented-control': TSinchSegmentedControlReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-segmented-control': TSinchSegmentedControlElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, getTargetByAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box;position:relative;z-index:0}</style><div id="wrapper"><slot></slot></div>';
|
|
3
|
-
const template = document.createElement('template');
|
|
4
|
-
template.innerHTML = templateHTML;
|
|
5
|
-
defineCustomElement('sinch-segmented-control', class extends NectaryElement {
|
|
6
|
-
#$slot;
|
|
7
|
-
#controller = null;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$slot = shadowRoot.querySelector('slot');
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
this.#controller = new AbortController();
|
|
16
|
-
const {
|
|
17
|
-
signal
|
|
18
|
-
} = this.#controller;
|
|
19
|
-
const options = {
|
|
20
|
-
signal
|
|
21
|
-
};
|
|
22
|
-
this.role = 'tablist';
|
|
23
|
-
this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
|
|
24
|
-
this.#$slot.addEventListener('click', this.#onOptionClick, options);
|
|
25
|
-
this.#$slot.addEventListener('keydown', this.#onOptionKeydown, options);
|
|
26
|
-
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
27
|
-
}
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
this.#controller.abort();
|
|
30
|
-
this.#controller = null;
|
|
31
|
-
}
|
|
32
|
-
static get observedAttributes() {
|
|
33
|
-
return ['value'];
|
|
34
|
-
}
|
|
35
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
36
|
-
switch (name) {
|
|
37
|
-
case 'value':
|
|
38
|
-
{
|
|
39
|
-
this.#onValueChange(newVal);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
set value(value) {
|
|
45
|
-
updateAttribute(this, 'value', value);
|
|
46
|
-
}
|
|
47
|
-
get value() {
|
|
48
|
-
return getAttribute(this, 'value', '');
|
|
49
|
-
}
|
|
50
|
-
#onSlotChange = () => {
|
|
51
|
-
this.#onValueChange(this.value);
|
|
52
|
-
};
|
|
53
|
-
#onOptionClick = e => {
|
|
54
|
-
const target = getTargetByAttribute(e, 'value');
|
|
55
|
-
if (target === null || getBooleanAttribute(target, 'disabled')) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const value = getAttribute(target, 'value', '');
|
|
59
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
60
|
-
detail: value
|
|
61
|
-
}));
|
|
62
|
-
};
|
|
63
|
-
#onOptionKeydown = e => {
|
|
64
|
-
switch (e.code) {
|
|
65
|
-
case 'Space':
|
|
66
|
-
case 'Enter':
|
|
67
|
-
{
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
const target = getTargetByAttribute(e, 'value');
|
|
70
|
-
if (target !== null) {
|
|
71
|
-
target.click();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
#onValueChange(value) {
|
|
77
|
-
for (const $option of this.#$slot.assignedElements()) {
|
|
78
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
79
|
-
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
#onChangeReactHandler = e => {
|
|
83
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
84
|
-
};
|
|
85
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchSegmentedControlElement = HTMLElement & {
|
|
3
|
-
value: string;
|
|
4
|
-
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
5
|
-
setAttribute(name: 'value', value: string): void;
|
|
6
|
-
};
|
|
7
|
-
export type TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
|
|
8
|
-
value: string;
|
|
9
|
-
'aria-label': string;
|
|
10
|
-
'on-change'?: (e: CustomEvent<string>) => void;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchSegmentedControlOptionElement, TSinchSegmentedControlOptionReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-segmented-control-option': TSinchSegmentedControlOptionReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-segmented-control-option': TSinchSegmentedControlOptionElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
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;display:flex;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 16px;box-sizing:border-box;color:var(--sinch-local-color-text);background-color:var(--sinch-local-color-background);cursor:pointer;--sinch-local-color-text:var(--sinch-comp-segmented-control-color-default-text-initial);--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);--sinch-global-color-icon:var(--sinch-comp-segmented-control-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-segmented-control-size-icon)}: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-local-color-text:var(--sinch-comp-segmented-control-color-checked-text-initial);--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-local-color-text:var(--sinch-comp-segmented-control-color-disabled-text-initial);--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)}#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}#content{font:var(--sinch-comp-segmented-control-font-label);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;pointer-events:none}::slotted(*){display:block;pointer-events:none}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span><div id="border"></div><div id="outline"></div></div>';
|
|
3
|
-
const template = document.createElement('template');
|
|
4
|
-
template.innerHTML = templateHTML;
|
|
5
|
-
defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
|
|
6
|
-
#$label;
|
|
7
|
-
#controller = null;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$label = shadowRoot.querySelector('#content');
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
this.#controller = new AbortController();
|
|
16
|
-
const {
|
|
17
|
-
signal
|
|
18
|
-
} = this.#controller;
|
|
19
|
-
const options = {
|
|
20
|
-
signal
|
|
21
|
-
};
|
|
22
|
-
this.role = 'tab';
|
|
23
|
-
this.addEventListener('focus', this.#onButtonFocus, options);
|
|
24
|
-
this.addEventListener('blur', this.#onButtonBlur, options);
|
|
25
|
-
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
26
|
-
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
27
|
-
this.#updateTabIndex();
|
|
28
|
-
}
|
|
29
|
-
disconnectedCallback() {
|
|
30
|
-
this.#controller.abort();
|
|
31
|
-
this.#controller = null;
|
|
32
|
-
}
|
|
33
|
-
static get observedAttributes() {
|
|
34
|
-
return ['data-checked', 'disabled', 'text'];
|
|
35
|
-
}
|
|
36
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
37
|
-
switch (name) {
|
|
38
|
-
case 'text':
|
|
39
|
-
{
|
|
40
|
-
this.#$label.textContent = newVal;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
case 'data-checked':
|
|
44
|
-
{
|
|
45
|
-
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
case 'disabled':
|
|
49
|
-
{
|
|
50
|
-
if (isAttrEqual(oldVal, newVal)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this.#updateTabIndex();
|
|
54
|
-
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
set value(value) {
|
|
60
|
-
updateAttribute(this, 'value', value);
|
|
61
|
-
}
|
|
62
|
-
get value() {
|
|
63
|
-
return getAttribute(this, 'value', '');
|
|
64
|
-
}
|
|
65
|
-
set disabled(isDisabled) {
|
|
66
|
-
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
67
|
-
}
|
|
68
|
-
get disabled() {
|
|
69
|
-
return getBooleanAttribute(this, 'disabled');
|
|
70
|
-
}
|
|
71
|
-
set text(value) {
|
|
72
|
-
updateAttribute(this, 'text', value);
|
|
73
|
-
}
|
|
74
|
-
get text() {
|
|
75
|
-
return getAttribute(this, 'text', '');
|
|
76
|
-
}
|
|
77
|
-
get focusable() {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
#updateTabIndex() {
|
|
81
|
-
this.tabIndex = this.disabled ? -1 : 0;
|
|
82
|
-
}
|
|
83
|
-
#onButtonFocus = () => {
|
|
84
|
-
this.dispatchEvent(new CustomEvent('-focus'));
|
|
85
|
-
};
|
|
86
|
-
#onButtonBlur = () => {
|
|
87
|
-
this.dispatchEvent(new CustomEvent('-blur'));
|
|
88
|
-
};
|
|
89
|
-
#onFocusReactHandler = () => {
|
|
90
|
-
getReactEventHandler(this, 'on-focus')?.();
|
|
91
|
-
};
|
|
92
|
-
#onBlurReactHandler = () => {
|
|
93
|
-
getReactEventHandler(this, 'on-blur')?.();
|
|
94
|
-
};
|
|
95
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchSegmentedControlOptionElement = HTMLElement & {
|
|
3
|
-
value: string;
|
|
4
|
-
disabled: boolean;
|
|
5
|
-
text: string;
|
|
6
|
-
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
7
|
-
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
8
|
-
setAttribute(name: 'value', value: string): void;
|
|
9
|
-
setAttribute(name: 'text', value: string): void;
|
|
10
|
-
setAttribute(name: 'disabled', value: ''): void;
|
|
11
|
-
};
|
|
12
|
-
export type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinchSegmentedControlOptionElement> & {
|
|
13
|
-
value: string;
|
|
14
|
-
text: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
'aria-label': string;
|
|
17
|
-
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
18
|
-
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
19
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchSegmentedIconControlElement, TSinchSegmentedIconControlReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-segmented-icon-control': TSinchSegmentedIconControlReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-segmented-icon-control': TSinchSegmentedIconControlElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, getTargetByAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;width:100%;box-sizing:border-box;position:relative;z-index:0}</style><div id="wrapper"><slot></slot></div>';
|
|
3
|
-
const template = document.createElement('template');
|
|
4
|
-
template.innerHTML = templateHTML;
|
|
5
|
-
defineCustomElement('sinch-segmented-icon-control', class extends NectaryElement {
|
|
6
|
-
#$slot;
|
|
7
|
-
#controller = null;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$slot = shadowRoot.querySelector('slot');
|
|
13
|
-
}
|
|
14
|
-
connectedCallback() {
|
|
15
|
-
this.#controller = new AbortController();
|
|
16
|
-
const {
|
|
17
|
-
signal
|
|
18
|
-
} = this.#controller;
|
|
19
|
-
const options = {
|
|
20
|
-
signal
|
|
21
|
-
};
|
|
22
|
-
this.role = 'tablist';
|
|
23
|
-
this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
|
|
24
|
-
this.#$slot.addEventListener('click', this.#onOptionClick, options);
|
|
25
|
-
this.#$slot.addEventListener('keydown', this.#onOptionKeydown, options);
|
|
26
|
-
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
27
|
-
}
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
this.#controller.abort();
|
|
30
|
-
this.#controller = null;
|
|
31
|
-
}
|
|
32
|
-
static get observedAttributes() {
|
|
33
|
-
return ['value'];
|
|
34
|
-
}
|
|
35
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
36
|
-
switch (name) {
|
|
37
|
-
case 'value':
|
|
38
|
-
{
|
|
39
|
-
this.#onValueChange(newVal ?? '');
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
set value(value) {
|
|
45
|
-
updateAttribute(this, 'value', value);
|
|
46
|
-
}
|
|
47
|
-
get value() {
|
|
48
|
-
return getAttribute(this, 'value', '');
|
|
49
|
-
}
|
|
50
|
-
set multiple(isMultiple) {
|
|
51
|
-
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
52
|
-
}
|
|
53
|
-
get multiple() {
|
|
54
|
-
return getBooleanAttribute(this, 'multiple');
|
|
55
|
-
}
|
|
56
|
-
#onSlotChange = () => {
|
|
57
|
-
this.#onValueChange(this.value);
|
|
58
|
-
};
|
|
59
|
-
#onOptionClick = e => {
|
|
60
|
-
const target = getTargetByAttribute(e, 'value');
|
|
61
|
-
if (target === null || getBooleanAttribute(target, 'disabled')) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const value = getAttribute(target, 'value', '');
|
|
65
|
-
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute(target, 'data-checked')) : value;
|
|
66
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
67
|
-
detail
|
|
68
|
-
}));
|
|
69
|
-
};
|
|
70
|
-
#onOptionKeydown = e => {
|
|
71
|
-
switch (e.code) {
|
|
72
|
-
case 'Space':
|
|
73
|
-
case 'Enter':
|
|
74
|
-
{
|
|
75
|
-
e.preventDefault();
|
|
76
|
-
const target = getTargetByAttribute(e, 'value');
|
|
77
|
-
if (target !== null) {
|
|
78
|
-
target.click();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
#onValueChange(csv) {
|
|
84
|
-
if (this.multiple) {
|
|
85
|
-
const values = unpackCsv(csv);
|
|
86
|
-
for (const $option of this.#$slot.assignedElements()) {
|
|
87
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && values.includes(getAttribute($option, 'value', ''));
|
|
88
|
-
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
const value = getFirstCsvValue(csv);
|
|
92
|
-
for (const $option of this.#$slot.assignedElements()) {
|
|
93
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
94
|
-
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
#onChangeReactHandler = e => {
|
|
99
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
100
|
-
};
|
|
101
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export type TSinchSegmentedIconControlElement = HTMLElement & {
|
|
3
|
-
value: string;
|
|
4
|
-
multiple: boolean;
|
|
5
|
-
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
6
|
-
setAttribute(name: 'value', value: string): void;
|
|
7
|
-
setAttribute(name: 'multiple', value: ''): void;
|
|
8
|
-
};
|
|
9
|
-
export type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
|
|
10
|
-
value: string;
|
|
11
|
-
multiple?: boolean;
|
|
12
|
-
'aria-label': string;
|
|
13
|
-
'on-change'?: (e: CustomEvent<string>) => void;
|
|
14
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchSegmentedIconControlOptionElement, TSinchSegmentedIconControlOptionReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-segmented-icon-control-option': TSinchSegmentedIconControlOptionReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-segmented-icon-control-option': TSinchSegmentedIconControlOptionElement;
|
|
10
|
-
}
|
|
11
|
-
}
|