@nectary/components 4.12.1 → 5.0.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/global/index.d.ts +1 -0
- package/accordion/global/index.js +2 -0
- package/accordion/index.d.ts +1 -22
- package/accordion/index.js +41 -39
- package/accordion/types.d.ts +21 -1
- package/accordion/types.js +1 -1
- package/accordion-item/global/index.d.ts +1 -0
- package/accordion-item/global/index.js +2 -0
- package/accordion-item/index.d.ts +2 -22
- package/accordion-item/index.js +53 -49
- package/accordion-item/types.d.ts +21 -1
- package/accordion-item/types.js +1 -1
- package/accordion-item/utils.js +4 -1
- package/action-menu/global/index.d.ts +1 -0
- package/action-menu/global/index.js +2 -0
- package/action-menu/index.d.ts +1 -22
- package/action-menu/index.js +62 -77
- package/action-menu/types.d.ts +21 -1
- package/action-menu/types.js +1 -1
- package/action-menu-option/global/index.d.ts +1 -0
- package/action-menu-option/global/index.js +2 -0
- package/action-menu-option/index.d.ts +1 -22
- package/action-menu-option/index.js +39 -41
- package/action-menu-option/types.d.ts +21 -1
- package/action-menu-option/types.js +1 -1
- package/action-menu-option/utils.js +6 -3
- package/alert/global/index.d.ts +1 -0
- package/alert/global/index.js +2 -0
- package/alert/index.d.ts +2 -22
- package/alert/index.js +24 -21
- package/alert/types.d.ts +21 -1
- package/alert/types.js +1 -1
- package/alert/utils.js +4 -1
- package/avatar/colors.js +1 -1
- package/avatar/global/index.d.ts +1 -0
- package/avatar/global/index.js +2 -0
- package/avatar/index.d.ts +2 -22
- package/avatar/index.js +42 -41
- package/avatar/types.d.ts +21 -1
- package/avatar/types.js +1 -1
- package/avatar/utils.js +9 -4
- package/badge/global/index.d.ts +1 -0
- package/badge/global/index.js +2 -0
- package/badge/index.d.ts +3 -22
- package/badge/index.js +52 -51
- package/badge/types.d.ts +21 -1
- package/badge/types.js +1 -1
- package/badge/utils.js +4 -1
- package/bundle.d.ts +78 -0
- package/bundle.js +13033 -0
- package/bundle.ts +80 -0
- package/button/global/index.d.ts +1 -0
- package/button/global/index.js +2 -0
- package/button/index.d.ts +2 -22
- package/button/index.js +101 -111
- package/button/types.d.ts +21 -1
- package/button/types.js +1 -1
- package/button/utils.js +18 -2
- package/button-group/global/index.d.ts +1 -0
- package/button-group/global/index.js +2 -0
- package/button-group/index.d.ts +1 -22
- package/button-group/index.js +20 -18
- package/button-group/types.d.ts +22 -3
- package/button-group/types.js +1 -1
- package/button-group-item/global/index.d.ts +1 -0
- package/button-group-item/global/index.js +2 -0
- package/button-group-item/index.d.ts +2 -22
- package/button-group-item/index.js +31 -42
- package/button-group-item/types.d.ts +22 -3
- package/button-group-item/types.js +1 -1
- package/card-container/global/index.d.ts +1 -0
- package/card-container/global/index.js +2 -0
- package/card-container/index.d.ts +1 -21
- package/card-container/index.js +8 -5
- package/card-container/types.d.ts +21 -1
- package/card-container/types.js +1 -1
- package/card-v2/global/index.d.ts +1 -0
- package/card-v2/global/index.js +2 -0
- package/card-v2/index.d.ts +1 -22
- package/card-v2/index.js +59 -57
- package/card-v2/types.d.ts +21 -1
- package/card-v2/types.js +1 -1
- package/card-v2-title/global/index.d.ts +1 -0
- package/card-v2-title/global/index.js +2 -0
- package/card-v2-title/index.d.ts +2 -22
- package/card-v2-title/index.js +28 -26
- package/card-v2-title/types.d.ts +21 -1
- package/card-v2-title/types.js +1 -1
- package/checkbox/global/index.d.ts +1 -0
- package/checkbox/global/index.js +2 -0
- package/checkbox/index.d.ts +1 -22
- package/checkbox/index.js +88 -81
- package/checkbox/types.d.ts +21 -1
- package/checkbox/types.js +1 -1
- package/chip/colors.js +1 -1
- package/chip/global/index.d.ts +1 -0
- package/chip/global/index.js +2 -0
- package/chip/index.d.ts +1 -22
- package/chip/index.js +62 -75
- package/chip/types.d.ts +21 -1
- package/chip/types.js +1 -1
- package/chip/utils.js +7 -3
- package/code-tag/global/index.d.ts +1 -0
- package/code-tag/global/index.js +2 -0
- package/code-tag/index.d.ts +1 -22
- package/code-tag/index.js +17 -14
- package/code-tag/types.d.ts +21 -1
- package/code-tag/types.js +1 -1
- package/color-menu/global/index.d.ts +1 -0
- package/color-menu/global/index.js +2 -0
- package/color-menu/index.d.ts +2 -22
- package/color-menu/index.js +115 -115
- package/color-menu/types.d.ts +21 -1
- package/color-menu/types.js +1 -1
- package/color-menu/utils.js +6 -3
- package/color-menu-option/global/index.d.ts +1 -0
- package/color-menu-option/global/index.js +2 -0
- package/color-menu-option/index.d.ts +1 -22
- package/color-menu-option/index.js +30 -26
- package/color-menu-option/types.d.ts +21 -1
- package/color-menu-option/types.js +1 -1
- package/color-menu-option/utils.js +6 -3
- package/color-swatch/global/index.d.ts +1 -0
- package/color-swatch/global/index.js +2 -0
- package/color-swatch/index.d.ts +1 -22
- package/color-swatch/index.js +23 -20
- package/color-swatch/types.d.ts +21 -1
- package/color-swatch/types.js +1 -1
- package/color-swatch/utils.js +7 -3
- package/date-picker/global/index.d.ts +1 -0
- package/date-picker/global/index.js +2 -0
- package/date-picker/index.d.ts +2 -22
- package/date-picker/index.js +157 -150
- package/date-picker/types.d.ts +21 -1
- package/date-picker/types.js +1 -1
- package/date-picker/utils.js +59 -42
- package/dialog/global/index.d.ts +1 -0
- package/dialog/global/index.js +2 -0
- package/dialog/index.d.ts +1 -22
- package/dialog/index.js +71 -58
- package/dialog/types.d.ts +21 -1
- package/dialog/types.js +1 -1
- package/dialog/utils.js +11 -7
- package/emoji/global/index.d.ts +1 -0
- package/emoji/global/index.js +2 -0
- package/emoji/index.d.ts +1 -22
- package/emoji/index.js +19 -16
- package/emoji/types.d.ts +21 -1
- package/emoji/types.js +1 -1
- package/emoji/utils.js +22 -17
- package/emoji-picker/global/index.d.ts +1 -0
- package/emoji-picker/global/index.js +2 -0
- package/emoji-picker/index.d.ts +2 -22
- package/emoji-picker/index.js +138 -118
- package/emoji-picker/types.d.ts +21 -1
- package/emoji-picker/types.js +1 -1
- package/field/global/index.d.ts +1 -0
- package/field/global/index.js +2 -0
- package/field/index.d.ts +1 -22
- package/field/index.js +63 -60
- package/field/types.d.ts +21 -1
- package/field/types.js +1 -1
- package/file-drop/global/index.d.ts +1 -0
- package/file-drop/global/index.js +2 -0
- package/file-drop/index.d.ts +1 -22
- package/file-drop/index.js +103 -98
- package/file-drop/types.d.ts +21 -1
- package/file-drop/types.js +1 -1
- package/file-drop/utils.js +27 -22
- package/file-picker/global/index.d.ts +1 -0
- package/file-picker/global/index.js +2 -0
- package/file-picker/index.d.ts +1 -22
- package/file-picker/index.js +53 -48
- package/file-picker/types.d.ts +21 -1
- package/file-picker/types.js +1 -1
- package/file-picker/utils.js +6 -3
- package/file-status/global/index.d.ts +1 -0
- package/file-status/global/index.js +2 -0
- package/file-status/index.d.ts +2 -22
- package/file-status/index.js +33 -22
- package/file-status/types.d.ts +21 -1
- package/file-status/types.js +1 -1
- package/file-status/utils.js +4 -1
- package/flag/global/index.d.ts +1 -0
- package/flag/global/index.js +2 -0
- package/flag/index.d.ts +1 -22
- package/flag/index.js +19 -16
- package/flag/types.d.ts +21 -1
- package/flag/types.js +1 -1
- package/flag/utils.js +11 -8
- package/grid/global/index.d.ts +1 -0
- package/grid/global/index.js +2 -0
- package/grid/index.d.ts +1 -22
- package/grid/index.js +8 -5
- package/grid/types.d.ts +21 -1
- package/grid/types.js +1 -1
- package/grid-item/global/index.d.ts +1 -0
- package/grid-item/global/index.js +2 -0
- package/grid-item/index.d.ts +1 -22
- package/grid-item/index.js +17 -13
- package/grid-item/types.d.ts +21 -1
- package/grid-item/types.js +1 -1
- package/help-tooltip/global/index.d.ts +1 -0
- package/help-tooltip/global/index.js +2 -0
- package/help-tooltip/index.d.ts +1 -22
- package/help-tooltip/index.js +29 -26
- package/help-tooltip/types.d.ts +21 -1
- package/help-tooltip/types.js +1 -1
- package/icon/generated-icon-type.js +1 -1
- package/icon/global/index.d.ts +1 -0
- package/icon/global/index.js +2 -0
- package/icon/index.d.ts +1 -22
- package/icon/index.js +30 -28
- package/icon/types.d.ts +21 -1
- package/icon/types.js +1 -1
- package/inline-alert/global/index.d.ts +1 -0
- package/inline-alert/global/index.js +2 -0
- package/inline-alert/index.d.ts +2 -22
- package/inline-alert/index.js +58 -39
- package/inline-alert/types.d.ts +21 -1
- package/inline-alert/types.js +1 -1
- package/inline-alert/utils.js +4 -1
- package/input/global/index.d.ts +1 -0
- package/input/global/index.js +2 -0
- package/input/index.d.ts +2 -22
- package/input/index.js +295 -317
- package/input/types.d.ts +21 -1
- package/input/types.js +1 -1
- package/input/utils.js +56 -46
- package/link/global/index.d.ts +1 -0
- package/link/global/index.js +2 -0
- package/link/index.d.ts +1 -22
- package/link/index.js +88 -79
- package/link/types.d.ts +21 -1
- package/link/types.js +1 -1
- package/list/global/index.d.ts +1 -0
- package/list/global/index.js +2 -0
- package/list/index.d.ts +1 -21
- package/list/index.js +9 -6
- package/list/types.d.ts +21 -1
- package/list/types.js +1 -1
- package/list-item/global/index.d.ts +1 -0
- package/list-item/global/index.js +2 -0
- package/list-item/index.d.ts +1 -22
- package/list-item/index.js +9 -6
- package/list-item/types.d.ts +21 -1
- package/list-item/types.js +1 -1
- package/package.json +12 -6
- package/pagination/global/index.d.ts +1 -0
- package/pagination/global/index.js +2 -0
- package/pagination/index.d.ts +2 -22
- package/pagination/index.js +64 -46
- package/pagination/types.d.ts +21 -1
- package/pagination/types.js +1 -1
- package/persistent-overlay/global/index.d.ts +1 -0
- package/persistent-overlay/global/index.js +2 -0
- package/persistent-overlay/index.d.ts +1 -22
- package/persistent-overlay/index.js +42 -44
- package/persistent-overlay/types.d.ts +21 -1
- package/persistent-overlay/types.js +1 -1
- package/pop/global/index.d.ts +1 -0
- package/pop/global/index.js +2 -0
- package/pop/index.d.ts +3 -22
- package/pop/index.js +149 -150
- package/pop/types.d.ts +21 -1
- package/pop/types.js +1 -1
- package/pop/utils.js +24 -8
- package/popover/global/index.d.ts +1 -0
- package/popover/global/index.js +2 -0
- package/popover/index.d.ts +2 -22
- package/popover/index.js +75 -68
- package/popover/types.d.ts +21 -1
- package/popover/types.js +1 -1
- package/popover/utils.js +18 -7
- package/progress/global/index.d.ts +1 -0
- package/progress/global/index.js +2 -0
- package/progress/index.d.ts +1 -22
- package/progress/index.js +30 -33
- package/progress/types.d.ts +21 -1
- package/progress/types.js +1 -1
- package/progress-stepper/global/index.d.ts +1 -0
- package/progress-stepper/global/index.js +2 -0
- package/progress-stepper/index.d.ts +2 -22
- package/progress-stepper/index.js +64 -66
- package/progress-stepper/types.d.ts +21 -1
- package/progress-stepper/types.js +1 -1
- package/progress-stepper-item/global/index.d.ts +1 -0
- package/progress-stepper-item/global/index.js +2 -0
- package/progress-stepper-item/index.d.ts +1 -22
- package/progress-stepper-item/index.js +58 -50
- package/progress-stepper-item/types.d.ts +21 -1
- package/progress-stepper-item/types.js +1 -1
- package/progress-stepper-item/utils.js +22 -11
- package/radio/global/index.d.ts +1 -0
- package/radio/global/index.js +2 -0
- package/radio/index.d.ts +1 -22
- package/radio/index.js +79 -83
- package/radio/types.d.ts +21 -1
- package/radio/types.js +1 -1
- package/radio-option/global/index.d.ts +1 -0
- package/radio-option/global/index.js +2 -0
- package/radio-option/index.d.ts +1 -22
- package/radio-option/index.js +47 -41
- package/radio-option/types.d.ts +21 -1
- package/radio-option/types.js +1 -1
- package/rich-text/global/index.d.ts +1 -0
- package/rich-text/global/index.js +2 -0
- package/rich-text/index.d.ts +1 -22
- package/rich-text/index.js +45 -46
- package/rich-text/types.d.ts +21 -1
- package/rich-text/types.js +1 -1
- package/rich-text/utils.js +31 -33
- package/rich-textarea/global/index.d.ts +1 -0
- package/rich-textarea/global/index.js +2 -0
- package/rich-textarea/index.d.ts +1 -22
- package/rich-textarea/index.js +201 -194
- package/rich-textarea/types.d.ts +21 -1
- package/rich-textarea/types.js +1 -1
- package/rich-textarea/utils.js +313 -340
- package/segment-collapse/global/index.d.ts +1 -0
- package/segment-collapse/global/index.js +2 -0
- package/segment-collapse/index.d.ts +1 -22
- package/segment-collapse/index.js +31 -25
- package/segment-collapse/types.d.ts +21 -1
- package/segment-collapse/types.js +1 -1
- package/segmented-control/global/index.d.ts +1 -0
- package/segmented-control/global/index.js +2 -0
- package/segmented-control/index.d.ts +1 -22
- package/segmented-control/index.js +45 -45
- package/segmented-control/types.d.ts +21 -1
- package/segmented-control/types.js +1 -1
- package/segmented-control-option/global/index.d.ts +1 -0
- package/segmented-control-option/global/index.js +2 -0
- package/segmented-control-option/index.d.ts +1 -22
- package/segmented-control-option/index.js +44 -46
- package/segmented-control-option/types.d.ts +21 -1
- package/segmented-control-option/types.js +1 -1
- package/segmented-icon-control/global/index.d.ts +1 -0
- package/segmented-icon-control/global/index.js +2 -0
- package/segmented-icon-control/index.d.ts +1 -22
- package/segmented-icon-control/index.js +51 -50
- package/segmented-icon-control/types.d.ts +21 -1
- package/segmented-icon-control/types.js +1 -1
- package/segmented-icon-control-option/global/index.d.ts +1 -0
- package/segmented-icon-control-option/global/index.js +2 -0
- package/segmented-icon-control-option/index.d.ts +1 -22
- package/segmented-icon-control-option/index.js +36 -37
- package/segmented-icon-control-option/types.d.ts +21 -1
- package/segmented-icon-control-option/types.js +1 -1
- package/select-button/global/index.d.ts +1 -0
- package/select-button/global/index.js +2 -0
- package/select-button/index.d.ts +1 -26
- package/select-button/index.js +104 -112
- package/select-button/types.d.ts +25 -1
- package/select-button/types.js +1 -1
- package/select-menu/global/index.d.ts +1 -0
- package/select-menu/global/index.js +2 -0
- package/select-menu/index.d.ts +1 -22
- package/select-menu/index.js +201 -164
- package/select-menu/types.d.ts +21 -1
- package/select-menu/types.js +1 -1
- package/select-menu-option/global/index.d.ts +1 -0
- package/select-menu-option/global/index.js +2 -0
- package/select-menu-option/index.d.ts +1 -22
- package/select-menu-option/index.js +41 -33
- package/select-menu-option/types.d.ts +21 -1
- package/select-menu-option/types.js +1 -1
- package/select-menu-option/utils.js +4 -1
- package/skeleton/global/index.d.ts +1 -0
- package/skeleton/global/index.js +2 -0
- package/skeleton/index.d.ts +1 -22
- package/skeleton/index.js +35 -38
- package/skeleton/types.d.ts +21 -1
- package/skeleton/types.js +1 -1
- package/skeleton-item/global/index.d.ts +1 -0
- package/skeleton-item/global/index.js +2 -0
- package/skeleton-item/index.d.ts +1 -22
- package/skeleton-item/index.js +8 -5
- package/skeleton-item/types.d.ts +21 -1
- package/skeleton-item/types.js +1 -1
- package/spinner/global/index.d.ts +1 -0
- package/spinner/global/index.js +2 -0
- package/spinner/index.d.ts +1 -22
- package/spinner/index.js +31 -29
- package/spinner/types.d.ts +21 -1
- package/spinner/types.js +1 -1
- package/standalone.d.ts +0 -8
- package/standalone.js +79 -87
- package/standalone.ts +0 -8
- package/stop-events/index.js +12 -12
- package/table/global/index.d.ts +1 -0
- package/table/global/index.js +2 -0
- package/table/index.d.ts +1 -21
- package/table/index.js +9 -6
- package/table/types.d.ts +21 -1
- package/table/types.js +1 -1
- package/table-body/global/index.d.ts +1 -0
- package/table-body/global/index.js +2 -0
- package/table-body/index.d.ts +1 -21
- package/table-body/index.js +9 -6
- package/table-body/types.d.ts +21 -1
- package/table-body/types.js +1 -1
- package/table-cell/global/index.d.ts +1 -0
- package/table-cell/global/index.js +2 -0
- package/table-cell/index.d.ts +2 -22
- package/table-cell/index.js +13 -9
- package/table-cell/types.d.ts +21 -1
- package/table-cell/types.js +1 -1
- package/table-cell/utils.js +4 -1
- package/table-head/global/index.d.ts +1 -0
- package/table-head/global/index.js +2 -0
- package/table-head/index.d.ts +1 -21
- package/table-head/index.js +9 -6
- package/table-head/types.d.ts +21 -1
- package/table-head/types.js +1 -1
- package/table-head-cell/global/index.d.ts +1 -0
- package/table-head-cell/global/index.js +2 -0
- package/table-head-cell/index.d.ts +1 -22
- package/table-head-cell/index.js +29 -27
- package/table-head-cell/types.d.ts +21 -1
- package/table-head-cell/types.js +1 -1
- package/table-row/global/index.d.ts +1 -0
- package/table-row/global/index.js +2 -0
- package/table-row/index.d.ts +1 -22
- package/table-row/index.js +20 -17
- package/table-row/types.d.ts +21 -1
- package/table-row/types.js +1 -1
- package/tabs/global/index.d.ts +1 -0
- package/tabs/global/index.js +2 -0
- package/tabs/index.d.ts +2 -22
- package/tabs/index.js +32 -35
- package/tabs/types.d.ts +21 -1
- package/tabs/types.js +1 -1
- package/tabs-icon-option/global/index.d.ts +1 -0
- package/tabs-icon-option/global/index.js +2 -0
- package/tabs-icon-option/index.d.ts +1 -22
- package/tabs-icon-option/index.js +38 -40
- package/tabs-icon-option/types.d.ts +21 -1
- package/tabs-icon-option/types.js +1 -1
- package/tabs-option/global/index.d.ts +1 -0
- package/tabs-option/global/index.js +2 -0
- package/tabs-option/index.d.ts +1 -22
- package/tabs-option/index.js +41 -43
- package/tabs-option/types.d.ts +21 -1
- package/tabs-option/types.js +1 -1
- package/tag/colors.js +1 -1
- package/tag/global/index.d.ts +1 -0
- package/tag/global/index.js +2 -0
- package/tag/index.d.ts +1 -22
- package/tag/index.js +45 -44
- package/tag/types.d.ts +21 -1
- package/tag/types.js +1 -1
- package/tag/utils.js +7 -3
- package/text/global/index.d.ts +1 -0
- package/text/global/index.js +2 -0
- package/text/index.d.ts +2 -22
- package/text/index.js +33 -28
- package/text/types.d.ts +21 -1
- package/text/types.js +1 -1
- package/text/utils.js +4 -1
- package/textarea/global/index.d.ts +1 -0
- package/textarea/global/index.js +2 -0
- package/textarea/index.d.ts +1 -22
- package/textarea/index.js +147 -152
- package/textarea/types.d.ts +21 -1
- package/textarea/types.js +1 -1
- package/time-picker/global/index.d.ts +1 -0
- package/time-picker/global/index.js +2 -0
- package/time-picker/index.d.ts +2 -22
- package/time-picker/index.js +119 -123
- package/time-picker/types.d.ts +21 -1
- package/time-picker/types.js +1 -1
- package/time-picker/utils.js +31 -33
- package/title/global/index.d.ts +1 -0
- package/title/global/index.js +2 -0
- package/title/index.d.ts +2 -22
- package/title/index.js +32 -31
- package/title/types.d.ts +21 -1
- package/title/types.js +1 -1
- package/title/utils.js +18 -14
- package/toast/global/index.d.ts +1 -0
- package/toast/global/index.js +2 -0
- package/toast/index.d.ts +2 -22
- package/toast/index.js +37 -34
- package/toast/types.d.ts +21 -1
- package/toast/types.js +1 -1
- package/toast/utils.js +4 -1
- package/toast-manager/global/index.d.ts +1 -0
- package/toast-manager/global/index.js +2 -0
- package/toast-manager/index.d.ts +3 -22
- package/toast-manager/index.js +77 -63
- package/toast-manager/types.d.ts +21 -1
- package/toast-manager/types.js +1 -1
- package/toast-manager/utils.js +4 -1
- package/toggle/global/index.d.ts +1 -0
- package/toggle/global/index.js +2 -0
- package/toggle/index.d.ts +1 -22
- package/toggle/index.js +81 -75
- package/toggle/types.d.ts +21 -1
- package/toggle/types.js +1 -1
- package/tooltip/global/index.d.ts +1 -0
- package/tooltip/global/index.js +2 -0
- package/tooltip/index.d.ts +3 -22
- package/tooltip/index.js +105 -93
- package/tooltip/tooltip-state.js +56 -64
- package/tooltip/types.d.ts +21 -1
- package/tooltip/types.js +1 -1
- package/tooltip/utils.js +32 -13
- package/types.d.ts +12 -29
- package/utils/adapters.js +1 -1
- package/utils/component-names.d.ts +3 -0
- package/utils/component-names.js +85 -0
- package/utils/context.js +32 -42
- package/utils/countries.js +490 -2
- package/utils/csv.js +13 -6
- package/utils/debounce.js +10 -3
- package/utils/dom.js +60 -53
- package/utils/element.d.ts +107 -15
- package/utils/element.js +100 -19
- package/utils/event-target.js +11 -5
- package/utils/form.js +17 -12
- package/utils/get-react-event-handler.js +6 -3
- package/utils/global-components-constants.d.ts +3 -0
- package/utils/global-components-constants.js +8 -0
- package/utils/global-components-manager.d.ts +71 -0
- package/utils/global-components-manager.js +24 -0
- package/utils/index.js +65 -12
- package/utils/markdown.js +56 -43
- package/utils/rect.js +13 -18
- package/utils/shared/global-elements-manager.d.js +1 -0
- package/utils/shared/global-elements-manager.d.ts +62 -0
- package/utils/shared/global-elements-manager.js +163 -0
- package/utils/shared/global-elements-store.d.js +1 -0
- package/utils/shared/global-elements-store.d.ts +12 -0
- package/utils/shared/global-elements-store.js +31 -0
- package/utils/shared/index.d.js +11 -0
- package/utils/shared/index.d.ts +3 -0
- package/utils/shared/index.js +11 -0
- package/utils/shared/nectary-element-base.d.js +1 -0
- package/utils/shared/nectary-element-base.d.ts +9 -0
- package/utils/shared/nectary-element-base.js +25 -0
- package/utils/shared/package.json +9 -0
- package/utils/shared/tsconfig.json +20 -0
- package/utils/size.js +8 -3
- package/utils/slot.js +13 -9
- package/utils/throttle.js +5 -2
- package/utils/uid.js +5 -2
- package/card/index.d.ts +0 -40
- package/card/index.js +0 -134
- package/card/types.d.ts +0 -17
- package/card/types.js +0 -1
- package/horizontal-stepper/index.d.ts +0 -33
- package/horizontal-stepper/index.js +0 -62
- package/horizontal-stepper/types.d.ts +0 -42
- package/horizontal-stepper/types.js +0 -1
- package/horizontal-stepper-item/index.d.ts +0 -38
- package/horizontal-stepper-item/index.js +0 -62
- package/horizontal-stepper-item/types.d.ts +0 -38
- 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/segment/index.d.ts +0 -40
- package/segment/index.js +0 -110
- package/segment/types.d.ts +0 -23
- package/segment/types.js +0 -1
- package/segment/utils.d.ts +0 -3
- package/segment/utils.js +0 -16
- package/tile-control/index.d.ts +0 -39
- package/tile-control/index.js +0 -111
- package/tile-control/types.d.ts +0 -29
- package/tile-control/types.js +0 -1
- package/tile-control-option/index.d.ts +0 -40
- package/tile-control-option/index.js +0 -99
- package/tile-control-option/types.d.ts +0 -52
- package/tile-control-option/types.js +0 -1
- package/vertical-stepper/index.d.ts +0 -33
- package/vertical-stepper/index.js +0 -58
- package/vertical-stepper/types.d.ts +0 -34
- package/vertical-stepper/types.js +0 -1
- package/vertical-stepper-item/index.d.ts +0 -38
- package/vertical-stepper-item/index.js +0 -62
- package/vertical-stepper-item/types.d.ts +0 -42
- 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/input/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Context,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { Context, subscribeContext } from "../utils/context.js";
|
|
2
|
+
import { getBooleanAttribute, updateAttribute, isAttrEqual, isAttrTrue, updateBooleanAttribute, updateLiteralAttribute, getAttribute, getLiteralAttribute, setClass } from "../utils/dom.js";
|
|
3
|
+
import { defineCustomElement, NectaryElement } from "../utils/element.js";
|
|
4
|
+
import { isElementFocused } from "../utils/slot.js";
|
|
5
|
+
import { getReactEventHandler } from "../utils/get-react-event-handler.js";
|
|
6
|
+
import { setFormValue, requestSubmitForm } from "../utils/form.js";
|
|
7
|
+
import { sizeValues, DEFAULT_SIZE } from "../utils/size.js";
|
|
8
|
+
import { splitValueAndMask, inputTypes, beginMaskedComposition, endMaskedComposition, deleteContentForward, deleteContentBackward, insertFromPaste, insertText, getMergedValueSliced, getMaskSymbols } from "./utils.js";
|
|
9
|
+
const templateHTML = '<style>\n:host {\n all: initial;\n display: inline-block;\n vertical-align: middle;\n}\n\n#wrapper {\n position: relative;\n display: flex;\n flex-direction: row;\n align-items: center;\n box-sizing: border-box;\n border-radius: var(--sinch-local-shape-radius);\n width: 100%;\n height: var(--sinch-local-size);\n background-color: var(--sinch-comp-input-color-default-background-initial);\n\n /* Default values */\n --sinch-local-size: var(--sinch-comp-input-size-container-m);\n --sinch-global-size-icon: var(--sinch-comp-input-size-icon-m);\n --sinch-local-shape-radius: var(--sinch-comp-input-shape-radius-size-m);\n}\n\n:host([data-size="l"]) > #wrapper {\n --sinch-local-size: var(--sinch-comp-input-size-container-l);\n --sinch-global-size-icon: var(--sinch-comp-input-size-icon-l);\n --sinch-local-shape-radius: var(--sinch-comp-input-shape-radius-size-l);\n}\n\n:host([data-size="m"]) > #wrapper {\n --sinch-local-size: var(--sinch-comp-input-size-container-m);\n --sinch-global-size-icon: var(--sinch-comp-input-size-icon-m);\n --sinch-local-shape-radius: var(--sinch-comp-input-shape-radius-size-m);\n}\n\n:host([data-size="s"]) > #wrapper {\n --sinch-local-size: var(--sinch-comp-input-size-container-s);\n --sinch-global-size-icon: var(--sinch-comp-input-size-icon-s);\n --sinch-local-shape-radius: var(--sinch-comp-input-shape-radius-size-s);\n}\n\n#input-wrapper {\n position: relative;\n flex: 1;\n flex-basis: 0;\n min-width: 0;\n align-self: stretch;\n}\n\n#input {\n all: initial;\n width: 100%;\n height: 100%;\n padding: 0 12px;\n box-sizing: border-box;\n font: var(--sinch-comp-input-font-input);\n color: var(--sinch-comp-input-color-default-text-initial);\n}\n\n#input::placeholder {\n font: var(--sinch-comp-input-font-placeholder) !important;\n color: var(--sinch-comp-input-color-default-text-placeholder);\n opacity: 1;\n}\n\n#input:disabled {\n color: var(--sinch-comp-input-color-disabled-text-initial);\n -webkit-text-fill-color: var(--sinch-comp-input-color-disabled-text-initial);\n}\n\n#input-mask {\n display: none;\n position: absolute;\n inset: 0;\n padding: 0 12px;\n pointer-events: none;\n color: var(--sinch-comp-input-color-default-text-placeholder);\n white-space: pre;\n height: fit-content;\n margin: auto 0;\n overflow: hidden;\n}\n\n#border {\n position: absolute;\n border: 1px solid var(--sinch-comp-input-color-default-border-initial);\n border-radius: var(--sinch-local-shape-radius);\n inset: 0;\n pointer-events: none;\n}\n\n:host([disabled]) #border {\n border-color: var(--sinch-comp-input-color-disabled-border-initial);\n}\n\n#input-wrapper:focus-within + #border {\n border-color: var(--sinch-comp-input-color-default-border-focus);\n border-width: 2px;\n}\n\n:host([mask]) #input,\n#input-mask {\n font: var(--sinch-sys-font-body-monospace-m);\n}\n\n:host([mask]) #input-mask {\n display: block;\n}\n\n:host([invalid]:not([disabled])) #input-wrapper:not(:focus-within) + #border {\n border-color: var(--sinch-comp-input-color-invalid-border-initial);\n}\n\n#input[type="password"]:not(:placeholder-shown) {\n font-size: 1.5em;\n letter-spacing: 0.1em;\n}\n\n#icon-wrapper {\n position: relative;\n height: 100%;\n}\n\n#icon {\n position: absolute;\n display: flex;\n align-items: center;\n left: 12px;\n top: 0;\n bottom: 0;\n pointer-events: none;\n\n --sinch-global-color-icon: var(--sinch-comp-input-color-default-icon-initial);\n}\n\n:host([disabled]) #icon {\n --sinch-global-color-icon: var(--sinch-comp-input-color-disabled-icon-initial);\n}\n\n#icon-wrapper.empty {\n display: none;\n}\n\n#icon-wrapper.empty ~ #input-wrapper > #input,\n#icon-wrapper.empty ~ #input-wrapper > #input-mask {\n padding-left: 12px;\n}\n\n#icon-wrapper:not(.empty) ~ #input-wrapper > #input,\n#icon-wrapper:not(.empty) ~ #input-wrapper > #input-mask {\n padding-left: calc(var(--sinch-global-size-icon) + 20px);\n}\n\n#right {\n display: flex;\n flex-direction: row;\n align-self: stretch;\n align-items: center;\n gap: 4px;\n padding-right: 4px;\n}\n\n#right.empty {\n display: none;\n}\n\n#left {\n display: flex;\n flex-direction: row;\n align-self: stretch;\n align-items: center;\n gap: 4px;\n padding-left: 4px;\n}\n\n#left.empty {\n display: none;\n}\n</style>\n\n<div id="wrapper">\n <div id="left">\n <slot name="left"></slot>\n </div>\n <div id="icon-wrapper">\n <div id="icon">\n <slot name="icon"></slot>\n </div>\n </div>\n <div id="input-wrapper">\n <div id="input-mask"></div>\n <input id="input" type="text"/>\n </div>\n <div id="border"></div>\n <div id="right">\n <slot name="right"></slot>\n </div>\n</div>\n';
|
|
10
|
+
const template = document.createElement("template");
|
|
7
11
|
template.innerHTML = templateHTML;
|
|
8
|
-
|
|
12
|
+
class Input extends NectaryElement {
|
|
9
13
|
#$input;
|
|
10
14
|
#$inputMask;
|
|
11
15
|
#$iconSlot;
|
|
@@ -18,7 +22,7 @@ export class Input extends NectaryElement {
|
|
|
18
22
|
#selectionStart = 0;
|
|
19
23
|
#selectionEnd = 0;
|
|
20
24
|
#isCompositionInProgress = false;
|
|
21
|
-
#compositionBeginValue =
|
|
25
|
+
#compositionBeginValue = "";
|
|
22
26
|
#wasClearedByMask = false;
|
|
23
27
|
#controller = null;
|
|
24
28
|
#sizeContext;
|
|
@@ -27,55 +31,53 @@ export class Input extends NectaryElement {
|
|
|
27
31
|
static formAssociated = true;
|
|
28
32
|
constructor() {
|
|
29
33
|
super();
|
|
30
|
-
const shadowRoot = this.attachShadow({
|
|
31
|
-
delegatesFocus: true
|
|
32
|
-
});
|
|
34
|
+
const shadowRoot = this.attachShadow({ delegatesFocus: true });
|
|
33
35
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
34
36
|
this.#internals = this.attachInternals();
|
|
35
|
-
this.#$input = shadowRoot.querySelector(
|
|
36
|
-
this.#$inputMask = shadowRoot.querySelector(
|
|
37
|
+
this.#$input = shadowRoot.querySelector("#input");
|
|
38
|
+
this.#$inputMask = shadowRoot.querySelector("#input-mask");
|
|
37
39
|
this.#$iconSlot = shadowRoot.querySelector('slot[name="icon"]');
|
|
38
|
-
this.#$iconWrapper = shadowRoot.querySelector(
|
|
40
|
+
this.#$iconWrapper = shadowRoot.querySelector("#icon-wrapper");
|
|
39
41
|
this.#$rightSlot = shadowRoot.querySelector('slot[name="right"]');
|
|
40
|
-
this.#$rightWrapper = shadowRoot.querySelector(
|
|
42
|
+
this.#$rightWrapper = shadowRoot.querySelector("#right");
|
|
41
43
|
this.#$leftSlot = shadowRoot.querySelector('slot[name="left"]');
|
|
42
|
-
this.#$leftWrapper = shadowRoot.querySelector(
|
|
43
|
-
this.#$wrapper = shadowRoot.querySelector(
|
|
44
|
-
this.#sizeContext = new Context(this.#$wrapper,
|
|
44
|
+
this.#$leftWrapper = shadowRoot.querySelector("#left");
|
|
45
|
+
this.#$wrapper = shadowRoot.querySelector("#wrapper");
|
|
46
|
+
this.#sizeContext = new Context(this.#$wrapper, "size");
|
|
45
47
|
this.#controller = new AbortController();
|
|
46
48
|
}
|
|
47
49
|
connectedCallback() {
|
|
48
50
|
super.connectedCallback();
|
|
49
|
-
this.setAttribute(
|
|
50
|
-
this.#internals.role =
|
|
51
|
+
this.setAttribute("role", "textbox");
|
|
52
|
+
this.#internals.role = "textbox";
|
|
51
53
|
if (this.#controller === null) {
|
|
52
54
|
this.#controller = new AbortController();
|
|
53
55
|
}
|
|
54
56
|
const options = {
|
|
55
57
|
signal: this.#controller.signal
|
|
56
58
|
};
|
|
57
|
-
this.#$input.addEventListener(
|
|
58
|
-
this.#$input.addEventListener(
|
|
59
|
-
this.#$input.addEventListener(
|
|
60
|
-
this.#$input.addEventListener(
|
|
61
|
-
this.#$input.addEventListener(
|
|
62
|
-
this.#$input.addEventListener(
|
|
63
|
-
this.#$input.addEventListener(
|
|
64
|
-
this.#$input.addEventListener(
|
|
65
|
-
this.#$input.addEventListener(
|
|
66
|
-
this.#$input.addEventListener(
|
|
67
|
-
this.#$iconSlot.addEventListener(
|
|
68
|
-
this.#$leftSlot.addEventListener(
|
|
69
|
-
this.#$rightSlot.addEventListener(
|
|
70
|
-
this.addEventListener(
|
|
71
|
-
this.addEventListener(
|
|
72
|
-
this.addEventListener(
|
|
73
|
-
this.addEventListener(
|
|
74
|
-
this.addEventListener(
|
|
75
|
-
this.addEventListener(
|
|
76
|
-
this.addEventListener(
|
|
59
|
+
this.#$input.addEventListener("keydown", this.#onKeyDown, options);
|
|
60
|
+
this.#$input.addEventListener("input", this.#onInput, options);
|
|
61
|
+
this.#$input.addEventListener("cut", this.#onCut, options);
|
|
62
|
+
this.#$input.addEventListener("copy", this.#onCopy, options);
|
|
63
|
+
this.#$input.addEventListener("paste", this.#onPaste, options);
|
|
64
|
+
this.#$input.addEventListener("compositionstart", this.#onCompositionStart, options);
|
|
65
|
+
this.#$input.addEventListener("compositionend", this.#onCompositionEnd, options);
|
|
66
|
+
this.#$input.addEventListener("focus", this.#onInputFocus, options);
|
|
67
|
+
this.#$input.addEventListener("blur", this.#onInputBlur, options);
|
|
68
|
+
this.#$input.addEventListener("wheel", this.#onWheel, options);
|
|
69
|
+
this.#$iconSlot.addEventListener("slotchange", this.#onIconSlotChange, options);
|
|
70
|
+
this.#$leftSlot.addEventListener("slotchange", this.#onLeftSlotChange, options);
|
|
71
|
+
this.#$rightSlot.addEventListener("slotchange", this.#onRightSlotChange, options);
|
|
72
|
+
this.addEventListener("-change", this.#onChangeReactHandler, options);
|
|
73
|
+
this.addEventListener("-focus", this.#onFocusReactHandler, options);
|
|
74
|
+
this.addEventListener("-blur", this.#onBlurReactHandler, options);
|
|
75
|
+
this.addEventListener("-copy", this.#onCopyReactHandler, options);
|
|
76
|
+
this.addEventListener("-cut", this.#onCutReactHandler, options);
|
|
77
|
+
this.addEventListener("-paste", this.#onPasteReactHandler, options);
|
|
78
|
+
this.addEventListener("-wheel", this.#onWheelReactHandler, options);
|
|
77
79
|
this.#sizeContext.listen(this.#controller.signal);
|
|
78
|
-
subscribeContext(this,
|
|
80
|
+
subscribeContext(this, "size", this.#onContextSize, this.#controller.signal);
|
|
79
81
|
this.#onIconSlotChange();
|
|
80
82
|
this.#onLeftSlotChange();
|
|
81
83
|
this.#onRightSlotChange();
|
|
@@ -90,20 +92,22 @@ export class Input extends NectaryElement {
|
|
|
90
92
|
setFormValue(this.#internals, this.#$input.value);
|
|
91
93
|
}
|
|
92
94
|
formResetCallback() {
|
|
93
|
-
this.#$input.value =
|
|
94
|
-
setFormValue(this.#internals,
|
|
95
|
+
this.#$input.value = "";
|
|
96
|
+
setFormValue(this.#internals, "");
|
|
95
97
|
}
|
|
96
98
|
formStateRestoreCallback(state) {
|
|
97
|
-
if (this.#internals.form === null || getBooleanAttribute(this.#internals.form,
|
|
99
|
+
if (this.#internals.form === null || getBooleanAttribute(this.#internals.form, "data-form-state-restore") === false) {
|
|
98
100
|
return;
|
|
99
101
|
}
|
|
100
102
|
if (state !== null) {
|
|
101
|
-
const value = typeof state ===
|
|
102
|
-
this.#$input.value = value?.toString() ??
|
|
103
|
-
setFormValue(this.#internals, value?.toString() ??
|
|
103
|
+
const value = typeof state === "string" ? state : state.get(this.name);
|
|
104
|
+
this.#$input.value = value?.toString() ?? "";
|
|
105
|
+
setFormValue(this.#internals, value?.toString() ?? "");
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
|
-
|
|
108
|
+
// This handler mimicks the behavior (with some exceptions) of the implicit form submission logic from the HTML spec:
|
|
109
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission
|
|
110
|
+
#onKeyDown = (e) => {
|
|
107
111
|
const form = this.#internals.form;
|
|
108
112
|
if (form === null) {
|
|
109
113
|
return;
|
|
@@ -111,190 +115,190 @@ export class Input extends NectaryElement {
|
|
|
111
115
|
if (form.disabled === true) {
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
|
-
if (e.key ===
|
|
115
|
-
const submitSelectors = [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
if (e.key === "Enter") {
|
|
119
|
+
const submitSelectors = [
|
|
120
|
+
'sinch-button[form-type="submit"]'
|
|
121
|
+
];
|
|
122
|
+
const formSubmitters = Array.from(form.querySelectorAll(submitSelectors.join(",")));
|
|
123
|
+
const formSubmitter = formSubmitters.find((submitter) => !submitter.disabled) ?? null;
|
|
118
124
|
if (formSubmitter !== null) {
|
|
119
125
|
requestSubmitForm(form, formSubmitter);
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
};
|
|
123
129
|
static get observedAttributes() {
|
|
124
|
-
return [
|
|
130
|
+
return [
|
|
131
|
+
"name",
|
|
132
|
+
"type",
|
|
133
|
+
"value",
|
|
134
|
+
"placeholder",
|
|
135
|
+
"mask",
|
|
136
|
+
"invalid",
|
|
137
|
+
"disabled",
|
|
138
|
+
"size",
|
|
139
|
+
"autocomplete",
|
|
140
|
+
"autofocus",
|
|
141
|
+
"data-size",
|
|
142
|
+
"aria-label"
|
|
143
|
+
];
|
|
125
144
|
}
|
|
126
145
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
127
146
|
switch (name) {
|
|
128
|
-
case
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
updateAttribute(this.#$input, 'name', newVal);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case 'type':
|
|
137
|
-
{
|
|
138
|
-
updateLiteralAttribute(this.#$input, inputTypes, 'type', newVal);
|
|
139
|
-
updateAttribute(this.#$input, 'spellcheck', newVal === 'password' ? 'false' : null);
|
|
140
|
-
break;
|
|
147
|
+
case "name": {
|
|
148
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
149
|
+
return;
|
|
141
150
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
} = splitValueAndMask(nextVal, this.#maskSymbols);
|
|
157
|
-
this.#$input.value = value;
|
|
158
|
-
setFormValue(this.#internals, value);
|
|
159
|
-
this.#$inputMask.textContent = placeholder;
|
|
160
|
-
if (isElementFocused(this.#$input)) {
|
|
161
|
-
this.#setSelectionRange(this.#selectionEnd, this.#selectionEnd);
|
|
162
|
-
}
|
|
151
|
+
updateAttribute(this.#$input, "name", newVal);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case "type": {
|
|
155
|
+
updateLiteralAttribute(this.#$input, inputTypes, "type", newVal);
|
|
156
|
+
updateAttribute(this.#$input, "spellcheck", newVal === "password" ? "false" : null);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "value": {
|
|
160
|
+
const nextVal = newVal ?? "";
|
|
161
|
+
const prevVal = this.#$input.value;
|
|
162
|
+
if (this.#wasClearedByMask) {
|
|
163
|
+
this.#wasClearedByMask = false;
|
|
164
|
+
if (nextVal.length === 0) {
|
|
163
165
|
break;
|
|
164
166
|
}
|
|
165
|
-
if (nextVal !== prevVal) {
|
|
166
|
-
this.#$input.value = nextVal;
|
|
167
|
-
setFormValue(this.#internals, nextVal);
|
|
168
|
-
if (isElementFocused(this.#$input)) {
|
|
169
|
-
this.#setSelectionRange(this.#selectionEnd, this.#selectionEnd);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
case 'placeholder':
|
|
175
|
-
{
|
|
176
|
-
this.#updatePlaceholder();
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
case 'mask':
|
|
180
|
-
{
|
|
181
|
-
this.#updateMask();
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
case 'invalid':
|
|
185
|
-
{
|
|
186
|
-
if (isAttrEqual(oldVal, newVal)) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const isInvalid = isAttrTrue(newVal);
|
|
190
|
-
this.ariaInvalid = isInvalid.toString();
|
|
191
|
-
this.#$input.ariaInvalid = this.ariaInvalid;
|
|
192
|
-
this.#internals.ariaInvalid = this.ariaInvalid;
|
|
193
|
-
updateBooleanAttribute(this, name, isInvalid);
|
|
194
|
-
break;
|
|
195
167
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
168
|
+
if (this.#maskSymbols !== null) {
|
|
169
|
+
const { value, placeholder } = splitValueAndMask(nextVal, this.#maskSymbols);
|
|
170
|
+
this.#$input.value = value;
|
|
171
|
+
setFormValue(this.#internals, value);
|
|
172
|
+
this.#$inputMask.textContent = placeholder;
|
|
173
|
+
if (isElementFocused(this.#$input)) {
|
|
174
|
+
this.#setSelectionRange(this.#selectionEnd, this.#selectionEnd);
|
|
200
175
|
}
|
|
201
|
-
const isDisabled = isAttrTrue(newVal);
|
|
202
|
-
this.#$input.disabled = isDisabled;
|
|
203
|
-
updateBooleanAttribute(this, name, isDisabled);
|
|
204
176
|
break;
|
|
205
177
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
178
|
+
if (nextVal !== prevVal) {
|
|
179
|
+
this.#$input.value = nextVal;
|
|
180
|
+
setFormValue(this.#internals, nextVal);
|
|
181
|
+
if (isElementFocused(this.#$input)) {
|
|
182
|
+
this.#setSelectionRange(this.#selectionEnd, this.#selectionEnd);
|
|
210
183
|
}
|
|
211
|
-
const isAutofocus = isAttrTrue(newVal);
|
|
212
|
-
this.#$input.autofocus = isAutofocus;
|
|
213
|
-
updateBooleanAttribute(this, name, isAutofocus);
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
case 'size':
|
|
217
|
-
{
|
|
218
|
-
updateAttribute(this, 'data-size', newVal);
|
|
219
|
-
break;
|
|
220
184
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case "placeholder": {
|
|
188
|
+
this.#updatePlaceholder();
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case "mask": {
|
|
192
|
+
this.#updateMask();
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case "invalid": {
|
|
196
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
197
|
+
return;
|
|
225
198
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
199
|
+
const isInvalid = isAttrTrue(newVal);
|
|
200
|
+
this.ariaInvalid = isInvalid.toString();
|
|
201
|
+
this.#$input.ariaInvalid = this.ariaInvalid;
|
|
202
|
+
this.#internals.ariaInvalid = this.ariaInvalid;
|
|
203
|
+
updateBooleanAttribute(this, name, isInvalid);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
case "disabled": {
|
|
207
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
208
|
+
return;
|
|
230
209
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
210
|
+
const isDisabled = isAttrTrue(newVal);
|
|
211
|
+
this.#$input.disabled = isDisabled;
|
|
212
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case "autofocus": {
|
|
216
|
+
if (isAttrEqual(oldVal, newVal)) {
|
|
217
|
+
return;
|
|
236
218
|
}
|
|
219
|
+
const isAutofocus = isAttrTrue(newVal);
|
|
220
|
+
this.#$input.autofocus = isAutofocus;
|
|
221
|
+
updateBooleanAttribute(this, name, isAutofocus);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case "size": {
|
|
225
|
+
updateAttribute(this, "data-size", newVal);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case "data-size": {
|
|
229
|
+
this.#onSizeUpdate();
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
case "autocomplete": {
|
|
233
|
+
updateAttribute(this.#$input, name, newVal);
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case "aria-label": {
|
|
237
|
+
this.#$input.ariaLabel = newVal;
|
|
238
|
+
this.#internals.ariaLabel = newVal;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
set name(value) {
|
|
240
|
-
updateAttribute(this,
|
|
244
|
+
updateAttribute(this, "name", value);
|
|
241
245
|
}
|
|
242
246
|
get name() {
|
|
243
|
-
return getAttribute(this,
|
|
247
|
+
return getAttribute(this, "name", "");
|
|
244
248
|
}
|
|
245
249
|
set type(value) {
|
|
246
|
-
updateAttribute(this,
|
|
250
|
+
updateAttribute(this, "type", value);
|
|
247
251
|
}
|
|
248
252
|
get type() {
|
|
249
|
-
return getLiteralAttribute(this, inputTypes,
|
|
253
|
+
return getLiteralAttribute(this, inputTypes, "type", "text");
|
|
250
254
|
}
|
|
251
255
|
set value(value) {
|
|
252
|
-
updateAttribute(this,
|
|
256
|
+
updateAttribute(this, "value", value);
|
|
253
257
|
}
|
|
254
258
|
get value() {
|
|
255
|
-
return getAttribute(this,
|
|
259
|
+
return getAttribute(this, "value", "");
|
|
256
260
|
}
|
|
257
261
|
set mask(value) {
|
|
258
|
-
updateAttribute(this,
|
|
262
|
+
updateAttribute(this, "mask", value);
|
|
259
263
|
}
|
|
260
264
|
get mask() {
|
|
261
|
-
return getAttribute(this,
|
|
265
|
+
return getAttribute(this, "mask");
|
|
262
266
|
}
|
|
263
267
|
set placeholder(value) {
|
|
264
|
-
updateAttribute(this,
|
|
268
|
+
updateAttribute(this, "placeholder", value);
|
|
265
269
|
}
|
|
266
270
|
get placeholder() {
|
|
267
|
-
return getAttribute(this,
|
|
271
|
+
return getAttribute(this, "placeholder");
|
|
268
272
|
}
|
|
269
273
|
set invalid(isInvalid) {
|
|
270
|
-
updateBooleanAttribute(this,
|
|
274
|
+
updateBooleanAttribute(this, "invalid", isInvalid);
|
|
271
275
|
}
|
|
272
276
|
get invalid() {
|
|
273
|
-
return getBooleanAttribute(this,
|
|
277
|
+
return getBooleanAttribute(this, "invalid");
|
|
274
278
|
}
|
|
275
279
|
set disabled(isDisabled) {
|
|
276
|
-
updateBooleanAttribute(this,
|
|
280
|
+
updateBooleanAttribute(this, "disabled", isDisabled);
|
|
277
281
|
}
|
|
278
282
|
get disabled() {
|
|
279
|
-
return getBooleanAttribute(this,
|
|
283
|
+
return getBooleanAttribute(this, "disabled");
|
|
280
284
|
}
|
|
281
285
|
set autofocus(isAutofocus) {
|
|
282
|
-
updateBooleanAttribute(this,
|
|
286
|
+
updateBooleanAttribute(this, "autofocus", isAutofocus);
|
|
283
287
|
}
|
|
284
288
|
get autofocus() {
|
|
285
|
-
return getBooleanAttribute(this,
|
|
289
|
+
return getBooleanAttribute(this, "autofocus");
|
|
286
290
|
}
|
|
287
291
|
set size(size) {
|
|
288
|
-
updateLiteralAttribute(this, sizeValues,
|
|
292
|
+
updateLiteralAttribute(this, sizeValues, "size", size);
|
|
289
293
|
}
|
|
290
294
|
get size() {
|
|
291
|
-
return getLiteralAttribute(this, sizeValues,
|
|
295
|
+
return getLiteralAttribute(this, sizeValues, "size", DEFAULT_SIZE);
|
|
292
296
|
}
|
|
293
297
|
set autocomplete(value) {
|
|
294
|
-
updateAttribute(this,
|
|
298
|
+
updateAttribute(this, "autocomplete", value);
|
|
295
299
|
}
|
|
296
300
|
get autocomplete() {
|
|
297
|
-
return getAttribute(this,
|
|
301
|
+
return getAttribute(this, "autocomplete", "");
|
|
298
302
|
}
|
|
299
303
|
get selectionStart() {
|
|
300
304
|
return this.#$input.selectionStart;
|
|
@@ -327,7 +331,7 @@ export class Input extends NectaryElement {
|
|
|
327
331
|
this.#$input.blur();
|
|
328
332
|
}
|
|
329
333
|
#setSelectionRange = (start, end, direction) => {
|
|
330
|
-
if (this.type !==
|
|
334
|
+
if (this.type !== "number") {
|
|
331
335
|
this.#$input.setSelectionRange(start, end, direction);
|
|
332
336
|
}
|
|
333
337
|
};
|
|
@@ -339,31 +343,23 @@ export class Input extends NectaryElement {
|
|
|
339
343
|
if (selectionStart === this.#$input.value.length) {
|
|
340
344
|
return;
|
|
341
345
|
}
|
|
342
|
-
const {
|
|
343
|
-
value,
|
|
344
|
-
placeholder
|
|
345
|
-
} = beginMaskedComposition(this.#$input.value, this.#maskSymbols, selectionStart);
|
|
346
|
+
const { value, placeholder } = beginMaskedComposition(this.#$input.value, this.#maskSymbols, selectionStart);
|
|
346
347
|
this.#$input.value = value;
|
|
347
348
|
this.#setSelectionRange(selectionStart, selectionStart);
|
|
348
349
|
this.#$inputMask.textContent = placeholder;
|
|
349
350
|
this.#compositionBeginValue = value;
|
|
350
351
|
}
|
|
351
352
|
};
|
|
352
|
-
#onCompositionEnd = e => {
|
|
353
|
+
#onCompositionEnd = (e) => {
|
|
353
354
|
this.#isCompositionInProgress = false;
|
|
354
355
|
if (this.#maskSymbols !== null) {
|
|
355
356
|
const value = this.#$input.value;
|
|
356
357
|
const wasValueInserted = value.length !== this.#compositionBeginValue.length;
|
|
357
358
|
const res = endMaskedComposition(value, e.data, this.#maskSymbols, this.#$input.selectionStart, wasValueInserted);
|
|
358
|
-
this.#compositionBeginValue =
|
|
359
|
+
this.#compositionBeginValue = "";
|
|
359
360
|
if (res !== null) {
|
|
360
|
-
const {
|
|
361
|
-
|
|
362
|
-
placeholder,
|
|
363
|
-
mergedValue,
|
|
364
|
-
cursorPos
|
|
365
|
-
} = res;
|
|
366
|
-
this.#$input.value = value;
|
|
361
|
+
const { value: value2, placeholder, mergedValue, cursorPos } = res;
|
|
362
|
+
this.#$input.value = value2;
|
|
367
363
|
this.#setSelectionRange(cursorPos, cursorPos);
|
|
368
364
|
this.#$inputMask.textContent = placeholder;
|
|
369
365
|
if (mergedValue.length > 0) {
|
|
@@ -379,7 +375,7 @@ export class Input extends NectaryElement {
|
|
|
379
375
|
this.#onInput();
|
|
380
376
|
}
|
|
381
377
|
};
|
|
382
|
-
#onMaskBeforeInput = e => {
|
|
378
|
+
#onMaskBeforeInput = (e) => {
|
|
383
379
|
this.#handleMaskBeforeInput(e.inputType, e.data);
|
|
384
380
|
e.preventDefault();
|
|
385
381
|
};
|
|
@@ -388,36 +384,27 @@ export class Input extends NectaryElement {
|
|
|
388
384
|
const selectionEnd = this.#$input.selectionEnd ?? 0;
|
|
389
385
|
let res = null;
|
|
390
386
|
switch (inputType) {
|
|
391
|
-
case
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
case
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
{
|
|
410
|
-
res = deleteContentForward(this.#$input.value, this.#maskSymbols, selectionStart, selectionEnd);
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
387
|
+
case "insertText": {
|
|
388
|
+
res = insertText(this.#$input.value, data, this.#maskSymbols, selectionStart, selectionEnd);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
case "insertFromPaste": {
|
|
392
|
+
res = insertFromPaste(this.#$input.value, data, this.#maskSymbols, selectionStart, selectionEnd);
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
case "deleteByCut":
|
|
396
|
+
case "deleteContent":
|
|
397
|
+
case "deleteContentBackward": {
|
|
398
|
+
res = deleteContentBackward(this.#$input.value, this.#maskSymbols, selectionStart, selectionEnd);
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
case "deleteContentForward": {
|
|
402
|
+
res = deleteContentForward(this.#$input.value, this.#maskSymbols, selectionStart, selectionEnd);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
413
405
|
}
|
|
414
406
|
if (res !== null) {
|
|
415
|
-
const {
|
|
416
|
-
value,
|
|
417
|
-
placeholder,
|
|
418
|
-
mergedValue,
|
|
419
|
-
cursorPos
|
|
420
|
-
} = res;
|
|
407
|
+
const { value, placeholder, mergedValue, cursorPos } = res;
|
|
421
408
|
this.#$input.value = value;
|
|
422
409
|
this.#setSelectionRange(cursorPos, cursorPos);
|
|
423
410
|
this.#$inputMask.textContent = placeholder;
|
|
@@ -435,29 +422,27 @@ export class Input extends NectaryElement {
|
|
|
435
422
|
const selectionStart = this.#$input.selectionStart ?? 0;
|
|
436
423
|
const selectionEnd = this.#$input.selectionEnd ?? 0;
|
|
437
424
|
switch (inputType) {
|
|
438
|
-
case
|
|
439
|
-
{
|
|
440
|
-
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
const value = this.value;
|
|
444
|
-
const cursorPos = selectionStart + data.length;
|
|
445
|
-
const nextValue = value.substring(0, selectionStart) + data + value.substring(selectionEnd);
|
|
446
|
-
this.#selectionStart = cursorPos;
|
|
447
|
-
this.#selectionEnd = cursorPos;
|
|
448
|
-
this.#dispatchChangeEvent(nextValue);
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
case 'deleteByCut':
|
|
452
|
-
{
|
|
453
|
-
const value = this.value;
|
|
454
|
-
const cursorPos = selectionStart;
|
|
455
|
-
const nextValue = value.substring(0, selectionStart) + value.substring(selectionEnd);
|
|
456
|
-
this.#selectionStart = cursorPos;
|
|
457
|
-
this.#selectionEnd = cursorPos;
|
|
458
|
-
this.#dispatchChangeEvent(nextValue);
|
|
459
|
-
break;
|
|
425
|
+
case "insertFromPaste": {
|
|
426
|
+
if (data === null) {
|
|
427
|
+
return;
|
|
460
428
|
}
|
|
429
|
+
const value = this.value;
|
|
430
|
+
const cursorPos = selectionStart + data.length;
|
|
431
|
+
const nextValue = value.substring(0, selectionStart) + data + value.substring(selectionEnd);
|
|
432
|
+
this.#selectionStart = cursorPos;
|
|
433
|
+
this.#selectionEnd = cursorPos;
|
|
434
|
+
this.#dispatchChangeEvent(nextValue);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
case "deleteByCut": {
|
|
438
|
+
const value = this.value;
|
|
439
|
+
const cursorPos = selectionStart;
|
|
440
|
+
const nextValue = value.substring(0, selectionStart) + value.substring(selectionEnd);
|
|
441
|
+
this.#selectionStart = cursorPos;
|
|
442
|
+
this.#selectionEnd = cursorPos;
|
|
443
|
+
this.#dispatchChangeEvent(nextValue);
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
461
446
|
}
|
|
462
447
|
}
|
|
463
448
|
#onInput = () => {
|
|
@@ -473,7 +458,7 @@ export class Input extends NectaryElement {
|
|
|
473
458
|
if (prevValue !== nextValue) {
|
|
474
459
|
const nextSelectionStart = this.#$input.selectionStart;
|
|
475
460
|
const nextSelectionEnd = this.#$input.selectionEnd;
|
|
476
|
-
if (this.hasAttribute(
|
|
461
|
+
if (this.hasAttribute("value") === true) {
|
|
477
462
|
this.#$input.value = prevValue;
|
|
478
463
|
this.#setSelectionRange(this.#selectionStart, this.#selectionEnd);
|
|
479
464
|
}
|
|
@@ -483,17 +468,14 @@ export class Input extends NectaryElement {
|
|
|
483
468
|
}
|
|
484
469
|
};
|
|
485
470
|
#onWheel = () => {
|
|
486
|
-
this.dispatchEvent(
|
|
471
|
+
this.dispatchEvent(
|
|
472
|
+
new CustomEvent("-wheel")
|
|
473
|
+
);
|
|
487
474
|
};
|
|
488
475
|
#onMaskInputAutofillChange = () => {
|
|
489
476
|
const nextVal = this.#$input.value;
|
|
490
477
|
if (this.#maskSymbols !== null) {
|
|
491
|
-
const {
|
|
492
|
-
value,
|
|
493
|
-
placeholder,
|
|
494
|
-
mergedValue,
|
|
495
|
-
cursorPos
|
|
496
|
-
} = splitValueAndMask(nextVal, this.#maskSymbols);
|
|
478
|
+
const { value, placeholder, mergedValue, cursorPos } = splitValueAndMask(nextVal, this.#maskSymbols);
|
|
497
479
|
this.#$input.value = value;
|
|
498
480
|
this.#setSelectionRange(cursorPos, cursorPos);
|
|
499
481
|
this.#$inputMask.textContent = placeholder;
|
|
@@ -506,7 +488,7 @@ export class Input extends NectaryElement {
|
|
|
506
488
|
}
|
|
507
489
|
}
|
|
508
490
|
};
|
|
509
|
-
#onCopy = e => {
|
|
491
|
+
#onCopy = (e) => {
|
|
510
492
|
const value = this.#$input.value;
|
|
511
493
|
const selectionStart = this.#$input.selectionStart ?? 0;
|
|
512
494
|
const selectionEnd = this.#$input.selectionEnd ?? 0;
|
|
@@ -515,14 +497,14 @@ export class Input extends NectaryElement {
|
|
|
515
497
|
}
|
|
516
498
|
const copiedValue = this.#maskSymbols === null ? value.substring(selectionStart, selectionEnd) : getMergedValueSliced(value, this.#maskSymbols, selectionStart, selectionEnd);
|
|
517
499
|
let replacedValue = null;
|
|
518
|
-
const replaceWith =
|
|
519
|
-
replacedValue =
|
|
500
|
+
const replaceWith = (value2) => {
|
|
501
|
+
replacedValue = value2 ?? null;
|
|
520
502
|
};
|
|
521
503
|
if (this.#maskSymbols !== null) {
|
|
522
504
|
e.preventDefault();
|
|
523
|
-
e.clipboardData.setData(
|
|
505
|
+
e.clipboardData.setData("text/plain", copiedValue);
|
|
524
506
|
}
|
|
525
|
-
const event = new CustomEvent(
|
|
507
|
+
const event = new CustomEvent("-copy", {
|
|
526
508
|
detail: {
|
|
527
509
|
value: copiedValue,
|
|
528
510
|
replaceWith
|
|
@@ -534,10 +516,10 @@ export class Input extends NectaryElement {
|
|
|
534
516
|
e.preventDefault();
|
|
535
517
|
}
|
|
536
518
|
if (replacedValue !== null) {
|
|
537
|
-
e.clipboardData.setData(
|
|
519
|
+
e.clipboardData.setData("text/plain", replacedValue);
|
|
538
520
|
}
|
|
539
521
|
};
|
|
540
|
-
#onCut = e => {
|
|
522
|
+
#onCut = (e) => {
|
|
541
523
|
const value = this.#$input.value;
|
|
542
524
|
const selectionStart = this.#$input.selectionStart ?? 0;
|
|
543
525
|
const selectionEnd = this.#$input.selectionEnd ?? 0;
|
|
@@ -546,14 +528,14 @@ export class Input extends NectaryElement {
|
|
|
546
528
|
}
|
|
547
529
|
const copiedValue = this.#maskSymbols === null ? value.substring(selectionStart, selectionEnd) : getMergedValueSliced(value, this.#maskSymbols, selectionStart, selectionEnd);
|
|
548
530
|
let replacedValue = null;
|
|
549
|
-
const replaceWith =
|
|
550
|
-
replacedValue =
|
|
531
|
+
const replaceWith = (value2) => {
|
|
532
|
+
replacedValue = value2 ?? null;
|
|
551
533
|
};
|
|
552
534
|
if (this.#maskSymbols !== null) {
|
|
553
535
|
e.preventDefault();
|
|
554
|
-
e.clipboardData.setData(
|
|
536
|
+
e.clipboardData.setData("text/plain", copiedValue);
|
|
555
537
|
}
|
|
556
|
-
const event = new CustomEvent(
|
|
538
|
+
const event = new CustomEvent("-cut", {
|
|
557
539
|
detail: {
|
|
558
540
|
value: copiedValue,
|
|
559
541
|
replaceWith
|
|
@@ -565,21 +547,21 @@ export class Input extends NectaryElement {
|
|
|
565
547
|
e.preventDefault();
|
|
566
548
|
}
|
|
567
549
|
if (replacedValue !== null) {
|
|
568
|
-
e.clipboardData.setData(
|
|
550
|
+
e.clipboardData.setData("text/plain", replacedValue);
|
|
569
551
|
if (this.#maskSymbols !== null) {
|
|
570
|
-
this.#handleMaskBeforeInput(
|
|
552
|
+
this.#handleMaskBeforeInput("deleteByCut", null);
|
|
571
553
|
} else {
|
|
572
|
-
this.#handleBeforeInput(
|
|
554
|
+
this.#handleBeforeInput("deleteByCut", null);
|
|
573
555
|
}
|
|
574
556
|
}
|
|
575
557
|
};
|
|
576
|
-
#onPaste = e => {
|
|
577
|
-
const pasteValue = e.clipboardData?.getData(
|
|
578
|
-
let replacedValue =
|
|
579
|
-
const replaceWith = value => {
|
|
580
|
-
replacedValue = value ??
|
|
558
|
+
#onPaste = (e) => {
|
|
559
|
+
const pasteValue = e.clipboardData?.getData("text/plain") ?? "";
|
|
560
|
+
let replacedValue = "";
|
|
561
|
+
const replaceWith = (value) => {
|
|
562
|
+
replacedValue = value ?? "";
|
|
581
563
|
};
|
|
582
|
-
const event = new CustomEvent(
|
|
564
|
+
const event = new CustomEvent("-paste", {
|
|
583
565
|
detail: {
|
|
584
566
|
value: pasteValue,
|
|
585
567
|
replaceWith
|
|
@@ -595,120 +577,116 @@ export class Input extends NectaryElement {
|
|
|
595
577
|
}
|
|
596
578
|
e.preventDefault();
|
|
597
579
|
if (this.#maskSymbols !== null) {
|
|
598
|
-
this.#handleMaskBeforeInput(
|
|
580
|
+
this.#handleMaskBeforeInput("insertFromPaste", replacedValue);
|
|
599
581
|
} else {
|
|
600
|
-
this.#handleBeforeInput(
|
|
582
|
+
this.#handleBeforeInput("insertFromPaste", replacedValue);
|
|
601
583
|
}
|
|
602
584
|
};
|
|
603
585
|
#dispatchMaskClearChangeEvent() {
|
|
604
586
|
this.#wasClearedByMask = true;
|
|
605
|
-
this.#dispatchChangeEvent(
|
|
587
|
+
this.#dispatchChangeEvent("");
|
|
606
588
|
}
|
|
607
589
|
#dispatchChangeEvent(value) {
|
|
608
590
|
if (value === this.value) {
|
|
609
591
|
return;
|
|
610
592
|
}
|
|
611
|
-
this.dispatchEvent(
|
|
612
|
-
|
|
613
|
-
|
|
593
|
+
this.dispatchEvent(
|
|
594
|
+
new CustomEvent("-change", {
|
|
595
|
+
detail: value
|
|
596
|
+
})
|
|
597
|
+
);
|
|
614
598
|
}
|
|
615
|
-
#onContextSize = e => {
|
|
616
|
-
if (this.hasAttribute(
|
|
599
|
+
#onContextSize = (e) => {
|
|
600
|
+
if (this.hasAttribute("size") === true) {
|
|
617
601
|
return;
|
|
618
602
|
}
|
|
619
603
|
switch (e.detail) {
|
|
620
|
-
case
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
this.setAttribute('data-size', 's');
|
|
628
|
-
}
|
|
604
|
+
case "l": {
|
|
605
|
+
this.setAttribute("data-size", "m");
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
default: {
|
|
609
|
+
this.setAttribute("data-size", "s");
|
|
610
|
+
}
|
|
629
611
|
}
|
|
630
612
|
};
|
|
631
613
|
#updateMask() {
|
|
632
614
|
if (this.mask !== null) {
|
|
633
615
|
if (this.#maskSymbols === null) {
|
|
634
|
-
this.#$input.addEventListener(
|
|
635
|
-
|
|
636
|
-
});
|
|
637
|
-
this.#$input.addEventListener('change', this.#onMaskInputAutofillChange, {
|
|
638
|
-
signal: this.#controller.signal
|
|
639
|
-
});
|
|
616
|
+
this.#$input.addEventListener("beforeinput", this.#onMaskBeforeInput, { signal: this.#controller.signal });
|
|
617
|
+
this.#$input.addEventListener("change", this.#onMaskInputAutofillChange, { signal: this.#controller.signal });
|
|
640
618
|
}
|
|
641
619
|
this.#maskSymbols = getMaskSymbols(this.mask);
|
|
642
|
-
const {
|
|
643
|
-
value,
|
|
644
|
-
placeholder
|
|
645
|
-
} = splitValueAndMask(this.#$input.value, this.#maskSymbols);
|
|
620
|
+
const { value, placeholder } = splitValueAndMask(this.#$input.value, this.#maskSymbols);
|
|
646
621
|
this.#$input.value = value;
|
|
647
622
|
this.#$inputMask.textContent = placeholder;
|
|
648
623
|
} else {
|
|
649
624
|
this.#maskSymbols = null;
|
|
650
|
-
this.#$input.removeEventListener(
|
|
651
|
-
this.#$input.removeEventListener(
|
|
625
|
+
this.#$input.removeEventListener("beforeinput", this.#onMaskBeforeInput);
|
|
626
|
+
this.#$input.removeEventListener("change", this.#onMaskInputAutofillChange);
|
|
652
627
|
}
|
|
653
628
|
this.#updatePlaceholder();
|
|
654
629
|
}
|
|
655
630
|
#updatePlaceholder() {
|
|
656
631
|
if (this.#maskSymbols === null) {
|
|
657
632
|
const value = this.placeholder;
|
|
658
|
-
this.#$input.placeholder = value ??
|
|
659
|
-
this.#internals.ariaPlaceholder = value ??
|
|
660
|
-
updateAttribute(this,
|
|
633
|
+
this.#$input.placeholder = value ?? "";
|
|
634
|
+
this.#internals.ariaPlaceholder = value ?? "";
|
|
635
|
+
updateAttribute(this, "aria-placeholder", value);
|
|
661
636
|
} else {
|
|
662
|
-
updateAttribute(this,
|
|
663
|
-
this.#$input.placeholder =
|
|
664
|
-
this.#internals.ariaPlaceholder =
|
|
637
|
+
updateAttribute(this, "aria-placeholder", null);
|
|
638
|
+
this.#$input.placeholder = "";
|
|
639
|
+
this.#internals.ariaPlaceholder = "";
|
|
665
640
|
}
|
|
666
641
|
}
|
|
667
642
|
#onIconSlotChange = () => {
|
|
668
643
|
const isEmpty = this.#$iconSlot.assignedElements().length === 0;
|
|
669
|
-
setClass(this.#$iconWrapper,
|
|
644
|
+
setClass(this.#$iconWrapper, "empty", isEmpty);
|
|
670
645
|
};
|
|
671
646
|
#onLeftSlotChange = () => {
|
|
672
647
|
const isEmpty = this.#$leftSlot.assignedElements().length === 0;
|
|
673
|
-
setClass(this.#$leftWrapper,
|
|
648
|
+
setClass(this.#$leftWrapper, "empty", isEmpty);
|
|
674
649
|
};
|
|
675
650
|
#onRightSlotChange = () => {
|
|
676
651
|
const isEmpty = this.#$rightSlot.assignedElements().length === 0;
|
|
677
|
-
setClass(this.#$rightWrapper,
|
|
652
|
+
setClass(this.#$rightWrapper, "empty", isEmpty);
|
|
678
653
|
};
|
|
679
654
|
#onInputFocus = () => {
|
|
680
|
-
this.dispatchEvent(new CustomEvent(
|
|
655
|
+
this.dispatchEvent(new CustomEvent("-focus"));
|
|
681
656
|
};
|
|
682
657
|
#onInputBlur = () => {
|
|
683
|
-
this.dispatchEvent(new CustomEvent(
|
|
658
|
+
this.dispatchEvent(new CustomEvent("-blur"));
|
|
684
659
|
};
|
|
685
660
|
#onSizeUpdate() {
|
|
686
661
|
if (!this.isDomConnected) {
|
|
687
662
|
return;
|
|
688
663
|
}
|
|
689
|
-
const size = this.getAttribute(
|
|
664
|
+
const size = this.getAttribute("data-size") ?? DEFAULT_SIZE;
|
|
690
665
|
this.#sizeContext.dispatch(size);
|
|
691
666
|
}
|
|
692
|
-
#onChangeReactHandler = e => {
|
|
693
|
-
getReactEventHandler(this,
|
|
667
|
+
#onChangeReactHandler = (e) => {
|
|
668
|
+
getReactEventHandler(this, "on-change")?.(e);
|
|
694
669
|
};
|
|
695
670
|
#onFocusReactHandler = () => {
|
|
696
|
-
getReactEventHandler(this,
|
|
671
|
+
getReactEventHandler(this, "on-focus")?.();
|
|
697
672
|
};
|
|
698
673
|
#onBlurReactHandler = () => {
|
|
699
|
-
getReactEventHandler(this,
|
|
674
|
+
getReactEventHandler(this, "on-blur")?.();
|
|
700
675
|
};
|
|
701
|
-
#onCopyReactHandler = e => {
|
|
702
|
-
getReactEventHandler(this,
|
|
676
|
+
#onCopyReactHandler = (e) => {
|
|
677
|
+
getReactEventHandler(this, "on-copy")?.(e);
|
|
703
678
|
};
|
|
704
|
-
#onCutReactHandler = e => {
|
|
705
|
-
getReactEventHandler(this,
|
|
679
|
+
#onCutReactHandler = (e) => {
|
|
680
|
+
getReactEventHandler(this, "on-cut")?.(e);
|
|
706
681
|
};
|
|
707
|
-
#onPasteReactHandler = e => {
|
|
708
|
-
getReactEventHandler(this,
|
|
682
|
+
#onPasteReactHandler = (e) => {
|
|
683
|
+
getReactEventHandler(this, "on-paste")?.(e);
|
|
709
684
|
};
|
|
710
|
-
#onWheelReactHandler = e => {
|
|
711
|
-
getReactEventHandler(this,
|
|
685
|
+
#onWheelReactHandler = (e) => {
|
|
686
|
+
getReactEventHandler(this, "on-wheel")?.(e);
|
|
712
687
|
};
|
|
713
688
|
}
|
|
714
|
-
defineCustomElement(
|
|
689
|
+
defineCustomElement("sinch-input", Input);
|
|
690
|
+
export {
|
|
691
|
+
Input
|
|
692
|
+
};
|