@tcn/ui 0.0.3 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/button/base_button/base_button.d.ts.map +1 -1
- package/dist/actions/button/base_button/base_button.js +20 -15
- package/dist/actions/button/base_button/base_button.js.map +1 -1
- package/dist/actions/button/button/button.d.ts.map +1 -1
- package/dist/actions/button/button/button.js +7 -7
- package/dist/actions/button/button/button.js.map +1 -1
- package/dist/actions/button/button_group/button_group.d.ts.map +1 -1
- package/dist/actions/button/button_group/button_group.js +2 -5
- package/dist/actions/button/button_group/button_group.js.map +1 -1
- package/dist/actions/button/select_group/select_group.js +7 -7
- package/dist/actions/button/select_group/select_group.js.map +1 -1
- package/dist/actions/button/slim_button/slim_button.d.ts.map +1 -1
- package/dist/actions/button/slim_button/slim_button.js +5 -5
- package/dist/actions/button/slim_button/slim_button.js.map +1 -1
- package/dist/button.css +1 -1
- package/dist/feedback/progress/progress_bar.js +1 -1
- package/dist/footer.css +1 -1
- package/dist/form/field/common/field_control/field_control.js +6 -6
- package/dist/form/field/common/field_control/field_control.js.map +1 -1
- package/dist/form/field/common/field_description.js +1 -1
- package/dist/form/field/common/field_error.js +2 -2
- package/dist/form/field/common/field_header.js +8 -8
- package/dist/form/field/common/field_header.js.map +1 -1
- package/dist/form/field/common/field_label.js +1 -1
- package/dist/form/field/common/status_input/status_input.d.ts.map +1 -1
- package/dist/form/field/common/status_input/status_input.js +9 -15
- package/dist/form/field/common/status_input/status_input.js.map +1 -1
- package/dist/form/field/h_field/h_field.js +9 -9
- package/dist/form/field/h_field/h_field.js.map +1 -1
- package/dist/form/field/v_field/v_field.js +8 -8
- package/dist/form/field/v_field/v_field.js.map +1 -1
- package/dist/form/field_set/field_set.d.ts.map +1 -1
- package/dist/form/field_set/field_set.js +12 -19
- package/dist/form/field_set/field_set.js.map +1 -1
- package/dist/inputs/checkbox/checkbox.js +12 -12
- package/dist/inputs/checkbox/checkbox.js.map +1 -1
- package/dist/inputs/color_input/color_input.d.ts.map +1 -1
- package/dist/inputs/color_input/color_input.js +13 -17
- package/dist/inputs/color_input/color_input.js.map +1 -1
- package/dist/inputs/color_input/color_picker.js +6 -6
- package/dist/inputs/color_input/color_picker.js.map +1 -1
- package/dist/inputs/combo_box/combo_box.js +15 -15
- package/dist/inputs/combo_box/combo_box.js.map +1 -1
- package/dist/inputs/date_picker/date_picker.js +6 -6
- package/dist/inputs/date_picker/date_picker.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_date.js +13 -13
- package/dist/inputs/date_picker/date_picker_date.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_day.js +1 -1
- package/dist/inputs/date_picker/date_picker_header.js +24 -24
- package/dist/inputs/date_picker/date_picker_header.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_input.js +19 -19
- package/dist/inputs/date_picker/date_picker_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_time_selector.d.ts.map +1 -1
- package/dist/inputs/date_picker/date_picker_time_selector.js +6 -9
- package/dist/inputs/date_picker/date_picker_time_selector.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_input.js +3 -3
- package/dist/inputs/date_picker/date_picker_year_input.js.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_selector.d.ts.map +1 -1
- package/dist/inputs/date_picker/date_picker_year_selector.js +18 -24
- package/dist/inputs/date_picker/date_picker_year_selector.js.map +1 -1
- package/dist/inputs/input/input.d.ts +2 -2
- package/dist/inputs/input/input.d.ts.map +1 -1
- package/dist/inputs/input/input.js +4 -4
- package/dist/inputs/input/input.js.map +1 -1
- package/dist/inputs/multi_combo_box/multi_combo_box.js +1 -1
- package/dist/inputs/multi_combo_box/multi_combo_box.js.map +1 -1
- package/dist/inputs/multiselect/multiselect_values.js +8 -8
- package/dist/inputs/multiselect/multiselect_values.js.map +1 -1
- package/dist/inputs/options/option.d.ts +1 -0
- package/dist/inputs/options/option.d.ts.map +1 -1
- package/dist/inputs/options/option.js.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +6 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +169 -128
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/radio/radio.js +14 -14
- package/dist/inputs/radio/radio.js.map +1 -1
- package/dist/inputs/select/select.js +16 -16
- package/dist/inputs/select/select.js.map +1 -1
- package/dist/inputs/slider/slider.js +7 -7
- package/dist/inputs/slider/slider.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_item.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_item.js +23 -18
- package/dist/inputs/suggestions/suggestion_item.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts +1 -1
- package/dist/inputs/suggestions/suggestion_list.d.ts.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +105 -95
- package/dist/inputs/suggestions/suggestion_list.js.map +1 -1
- package/dist/inputs/switch/switch.js +14 -14
- package/dist/inputs/switch/switch.js.map +1 -1
- package/dist/inputs/textarea/textarea.js +6 -6
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/inputs/unit_input/unit_input.js +5 -5
- package/dist/inputs/unit_input/unit_input.js.map +1 -1
- package/dist/layouts/body/h_body.js +10 -10
- package/dist/layouts/body/h_body.js.map +1 -1
- package/dist/layouts/body/v_body.js +8 -8
- package/dist/layouts/body/v_body.js.map +1 -1
- package/dist/layouts/column/column.js +16 -16
- package/dist/layouts/column/column.js.map +1 -1
- package/dist/layouts/divider/divider.js +9 -9
- package/dist/layouts/divider/divider.js.map +1 -1
- package/dist/layouts/footer/footer.js +6 -6
- package/dist/layouts/footer/footer.js.map +1 -1
- package/dist/layouts/grid/grid.d.ts.map +1 -1
- package/dist/layouts/grid/grid.js +22 -31
- package/dist/layouts/grid/grid.js.map +1 -1
- package/dist/layouts/header/header.js +11 -11
- package/dist/layouts/header/header.js.map +1 -1
- package/dist/layouts/index.d.ts +3 -2
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +26 -24
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/list/item.d.ts +1 -0
- package/dist/layouts/list/item.d.ts.map +1 -1
- package/dist/layouts/list/item.js +18 -7
- package/dist/layouts/list/item.js.map +1 -1
- package/dist/layouts/list/list.js +12 -12
- package/dist/layouts/list/list.js.map +1 -1
- package/dist/layouts/sidebar_end/sidebar_end.js +15 -15
- package/dist/layouts/sidebar_end/sidebar_end.js.map +1 -1
- package/dist/layouts/sidebar_start/sidebar_start.js +16 -16
- package/dist/layouts/sidebar_start/sidebar_start.js.map +1 -1
- package/dist/layouts/utility_bar/utility_bar.js +14 -14
- package/dist/layouts/utility_bar/utility_bar.js.map +1 -1
- package/dist/modal.css +1 -1
- package/dist/overlay/context_menu/context_menu.js +4 -4
- package/dist/overlay/index.js +3 -3
- package/dist/overlay/menu/menu.js +8 -8
- package/dist/overlay/menu/menu.js.map +1 -1
- package/dist/overlay/popper/popper.js +12 -12
- package/dist/{portal-qqIp4SIl.js → overlay/portal/portal.js} +3 -3
- package/dist/overlay/portal/portal.js.map +1 -0
- package/dist/overlay/portal/portal_platform.js +3 -4
- package/dist/overlay/portal/portal_platform.js.map +1 -1
- package/dist/overlay/tooltip/tooltip.js +10 -10
- package/dist/overlay/tooltip/tooltip.js.map +1 -1
- package/dist/phone_number_input.css +1 -1
- package/dist/slim_button.css +1 -1
- package/dist/stacks/box/bottom_resize_handle.js +9 -9
- package/dist/stacks/box/bottom_resize_handle.js.map +1 -1
- package/dist/stacks/box/box.js +42 -42
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/stacks/box/end_resize_handle.js +6 -6
- package/dist/stacks/box/end_resize_handle.js.map +1 -1
- package/dist/stacks/box/left_resize_handle.js +3 -3
- package/dist/stacks/box/left_resize_handle.js.map +1 -1
- package/dist/stacks/box/right_resize_handle.js +8 -8
- package/dist/stacks/box/right_resize_handle.js.map +1 -1
- package/dist/stacks/box/start_resize_handle.js +7 -7
- package/dist/stacks/box/start_resize_handle.js.map +1 -1
- package/dist/stacks/box/top_resize_handle.js +8 -8
- package/dist/stacks/box/top_resize_handle.js.map +1 -1
- package/dist/stacks/h_collapsible_box.js +5 -5
- package/dist/stacks/h_collapsible_box.js.map +1 -1
- package/dist/stacks/h_stack.js +26 -26
- package/dist/stacks/h_stack.js.map +1 -1
- package/dist/stacks/spacer.js +5 -5
- package/dist/stacks/spacer.js.map +1 -1
- package/dist/stacks/story_components/circle.js +6 -6
- package/dist/stacks/story_components/circle.js.map +1 -1
- package/dist/stacks/story_components/picture_placeholder.js +8 -8
- package/dist/stacks/story_components/picture_placeholder.js.map +1 -1
- package/dist/stacks/story_components/rect.js +11 -11
- package/dist/stacks/story_components/rect.js.map +1 -1
- package/dist/stacks/v_collapsible_box.js +8 -8
- package/dist/stacks/v_collapsible_box.js.map +1 -1
- package/dist/stacks/v_stack.js +35 -35
- package/dist/stacks/v_stack.js.map +1 -1
- package/dist/stacks/z_stack.js +34 -34
- package/dist/stacks/z_stack.js.map +1 -1
- package/dist/surfaces/alert/alert.js +8 -8
- package/dist/surfaces/alert/alert.js.map +1 -1
- package/dist/surfaces/card/card.d.ts.map +1 -1
- package/dist/surfaces/card/card.js +6 -15
- package/dist/surfaces/card/card.js.map +1 -1
- package/dist/surfaces/confirm/confirm.d.ts.map +1 -1
- package/dist/surfaces/confirm/confirm.js +17 -24
- package/dist/surfaces/confirm/confirm.js.map +1 -1
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.js +5 -5
- package/dist/surfaces/drawers/drawer_bottom/drawer_bottom.js.map +1 -1
- package/dist/surfaces/drawers/drawer_end/drawer_end.js +8 -8
- package/dist/surfaces/drawers/drawer_end/drawer_end.js.map +1 -1
- package/dist/surfaces/drawers/drawer_start/drawer_start.js +4 -4
- package/dist/surfaces/drawers/drawer_start/drawer_start.js.map +1 -1
- package/dist/surfaces/drawers/drawer_top/drawer_top.js +4 -4
- package/dist/surfaces/drawers/drawer_top/drawer_top.js.map +1 -1
- package/dist/surfaces/modal/modal.d.ts +2 -4
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +16 -7
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/page/h_page.js +6 -6
- package/dist/surfaces/page/h_page.js.map +1 -1
- package/dist/surfaces/page/v_page.js +9 -9
- package/dist/surfaces/page/v_page.js.map +1 -1
- package/dist/surfaces/panel/h_panel.d.ts.map +1 -1
- package/dist/surfaces/panel/h_panel.js +18 -24
- package/dist/surfaces/panel/h_panel.js.map +1 -1
- package/dist/surfaces/panel/v_panel.js +9 -9
- package/dist/surfaces/panel/v_panel.js.map +1 -1
- package/dist/surfaces/popover/popover.js +34 -34
- package/dist/surfaces/popover/popover.js.map +1 -1
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +6 -14
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/index.d.ts +0 -2
- package/dist/themes/index.d.ts.map +1 -1
- package/dist/themes/index.js +6 -402
- package/dist/themes/index.js.map +1 -1
- package/dist/themes/stylesheets/reset.js +140 -0
- package/dist/themes/stylesheets/reset.js.map +1 -0
- package/dist/themes/themes/ergo/ergo_theme.js +595 -0
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -0
- package/dist/tokens/badge/badge.js +13 -13
- package/dist/tokens/badge/badge.js.map +1 -1
- package/dist/tokens/bubble/bubble.js +11 -11
- package/dist/tokens/bubble/bubble.js.map +1 -1
- package/dist/tokens/chip/chip.js +11 -11
- package/dist/tokens/chip/chip.js.map +1 -1
- package/dist/typography/body_text/body_text.js +21 -21
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/typography/callout/callout.js +16 -16
- package/dist/typography/callout/callout.js.map +1 -1
- package/dist/typography/caption/caption.js +13 -13
- package/dist/typography/caption/caption.js.map +1 -1
- package/dist/typography/footnote/footnote.js +14 -14
- package/dist/typography/footnote/footnote.js.map +1 -1
- package/dist/typography/headline/headline.js +12 -12
- package/dist/typography/headline/headline.js.map +1 -1
- package/dist/typography/subheadline/subheadline.js +13 -13
- package/dist/typography/subheadline/subheadline.js.map +1 -1
- package/dist/typography/title/title.js +17 -17
- package/dist/typography/title/title.js.map +1 -1
- package/package.json +23 -4
- package/src/actions/button/__stories__/button.stories.tsx +1 -1
- package/src/actions/button/__stories__/button_group.stories.tsx +1 -1
- package/src/actions/button/__stories__/select_group.stories.tsx +1 -1
- package/src/actions/button/__stories__/slim_button.stories.tsx +1 -1
- package/src/actions/button/base_button/base_button.tsx +8 -3
- package/src/actions/button/button/button.module.css +0 -78
- package/src/actions/button/button/button.tsx +3 -5
- package/src/actions/button/button_group/button_group.tsx +4 -7
- package/src/actions/button/select_group/select_group.tsx +3 -3
- package/src/actions/button/slim_button/slim_button.module.css +0 -26
- package/src/actions/button/slim_button/slim_button.tsx +3 -2
- package/src/feedback/lazy/lazy.stories.tsx +1 -1
- package/src/feedback/loading/__storybook__/loading.stories.tsx +1 -1
- package/src/feedback/progress/progress_bar.stories.tsx +1 -1
- package/src/form/field/common/field_control/field_control.tsx +2 -2
- package/src/form/field/common/field_header.tsx +2 -2
- package/src/form/field/common/status_input/status_input.tsx +3 -6
- package/src/form/field/field.stories.tsx +2 -1
- package/src/form/field/h_field/h_field.stories.tsx +10 -1
- package/src/form/field/h_field/h_field.tsx +2 -2
- package/src/form/field/v_field/v_field.stories.tsx +10 -1
- package/src/form/field/v_field/v_field.tsx +2 -2
- package/src/form/field_set/field_set.stories.tsx +9 -1
- package/src/form/field_set/field_set.tsx +4 -7
- package/src/inputs/checkbox/checkbox.stories.tsx +9 -1
- package/src/inputs/checkbox/checkbox.tsx +2 -2
- package/src/inputs/color_input/color_input.stories.tsx +9 -1
- package/src/inputs/color_input/color_input.tsx +2 -6
- package/src/inputs/color_input/color_picker.tsx +2 -2
- package/src/inputs/combo_box/combo_box.stories.tsx +14 -5
- package/src/inputs/combo_box/combo_box.tsx +2 -2
- package/src/inputs/date_picker/date_picker.stories.tsx +18 -10
- package/src/inputs/date_picker/date_picker.tsx +3 -3
- package/src/inputs/date_picker/date_picker_date.tsx +3 -3
- package/src/inputs/date_picker/date_picker_header.tsx +2 -2
- package/src/inputs/date_picker/date_picker_input.stories.tsx +15 -7
- package/src/inputs/date_picker/date_picker_input.tsx +3 -3
- package/src/inputs/date_picker/date_picker_time_selector.tsx +5 -8
- package/src/inputs/date_picker/date_picker_year_input.tsx +2 -2
- package/src/inputs/date_picker/date_picker_year_selector.tsx +3 -9
- package/src/inputs/input/input.stories.tsx +9 -1
- package/src/inputs/input/input.tsx +5 -4
- package/src/inputs/mask_input/key_capture_input.stories.tsx +9 -1
- package/src/inputs/mask_input/mask_input.stories.tsx +10 -1
- package/src/inputs/multi_combo_box/multi_combo_box.stories.tsx +10 -1
- package/src/inputs/multi_combo_box/multi_combo_box.tsx +2 -2
- package/src/inputs/multiselect/multiselect_values.tsx +2 -2
- package/src/inputs/multiselect/mutliselect.stories.tsx +10 -1
- package/src/inputs/options/option.tsx +1 -0
- package/src/inputs/phone_number_input/phone_number_input.module.css +12 -0
- package/src/inputs/phone_number_input/phone_number_input.stories.tsx +18 -1
- package/src/inputs/phone_number_input/phone_number_input.tsx +104 -29
- package/src/inputs/radio/radio.stories.tsx +14 -6
- package/src/inputs/radio/radio.tsx +2 -2
- package/src/inputs/select/select.stories.tsx +18 -9
- package/src/inputs/select/select.tsx +2 -2
- package/src/inputs/slider/slider.stories.tsx +9 -1
- package/src/inputs/slider/slider.tsx +2 -2
- package/src/inputs/suggestions/suggestion_item.tsx +14 -4
- package/src/inputs/suggestions/suggestion_list.stories.tsx +21 -12
- package/src/inputs/suggestions/suggestion_list.tsx +25 -6
- package/src/inputs/switch/switch.stories.tsx +9 -1
- package/src/inputs/switch/switch.tsx +4 -4
- package/src/inputs/textarea/textarea.stories.tsx +9 -1
- package/src/inputs/textarea/textarea.tsx +2 -2
- package/src/inputs/unit_input/unit_input.stories.tsx +9 -1
- package/src/inputs/unit_input/unit_input.tsx +4 -4
- package/src/layouts/body/h_body.tsx +2 -2
- package/src/layouts/body/v_body.tsx +2 -2
- package/src/layouts/column/column.tsx +3 -3
- package/src/layouts/divider/__stories__/divider.stories.tsx +59 -19
- package/src/layouts/divider/divider.tsx +3 -3
- package/src/layouts/footer/footer.module.css +0 -1
- package/src/layouts/footer/footer.tsx +2 -2
- package/src/layouts/grid/grid.stories.tsx +42 -34
- package/src/layouts/grid/grid.tsx +2 -7
- package/src/layouts/header/header.tsx +2 -2
- package/src/layouts/index.ts +3 -2
- package/src/layouts/list/item.tsx +11 -3
- package/src/layouts/list/list.tsx +3 -3
- package/src/layouts/sidebar_end/sidebar_end.tsx +2 -2
- package/src/layouts/sidebar_start/sidebar_start.tsx +2 -2
- package/src/layouts/utility_bar/utility_bar.tsx +2 -2
- package/src/overlay/context_menu/context_menu.stories.tsx +13 -5
- package/src/overlay/menu/menu.stories.tsx +22 -14
- package/src/overlay/menu/menu.tsx +3 -3
- package/src/overlay/popper/popper.stories.tsx +43 -22
- package/src/overlay/portal/portal.stories.tsx +10 -1
- package/src/overlay/tooltip/tooltip.stories.tsx +9 -2
- package/src/overlay/tooltip/tooltip.tsx +2 -2
- package/src/stacks/box/bottom_resize_handle.tsx +2 -2
- package/src/stacks/box/box.tsx +2 -2
- package/src/stacks/box/end_resize_handle.tsx +2 -2
- package/src/stacks/box/left_resize_handle.tsx +2 -2
- package/src/stacks/box/right_resize_handle.tsx +2 -2
- package/src/stacks/box/start_resize_handle.tsx +2 -2
- package/src/stacks/box/top_resize_handle.tsx +2 -2
- package/src/stacks/collapsible_box.stories.tsx +10 -1
- package/src/stacks/h_collapsible_box.tsx +2 -2
- package/src/stacks/h_stack.stories.tsx +104 -59
- package/src/stacks/h_stack.tsx +2 -2
- package/src/stacks/spacer.tsx +2 -2
- package/src/stacks/story_components/circle.tsx +2 -2
- package/src/stacks/story_components/picture_placeholder.tsx +2 -2
- package/src/stacks/story_components/rect.tsx +2 -2
- package/src/stacks/v_collapsible_box.tsx +2 -2
- package/src/stacks/v_stack.stories.tsx +91 -10
- package/src/stacks/v_stack.tsx +2 -2
- package/src/stacks/z_stack.stories.tsx +9 -1
- package/src/stacks/z_stack.tsx +2 -2
- package/src/surfaces/alert/alert.stories.tsx +4 -4
- package/src/surfaces/alert/alert.tsx +2 -2
- package/src/surfaces/card/card.tsx +3 -9
- package/src/surfaces/confirm/confirm.stories.tsx +4 -4
- package/src/surfaces/confirm/confirm.tsx +3 -6
- package/src/surfaces/drawers/__stories__/drawers.stories.tsx +1 -1
- package/src/surfaces/drawers/drawer_bottom/drawer_bottom.tsx +2 -2
- package/src/surfaces/drawers/drawer_end/drawer_end.tsx +2 -2
- package/src/surfaces/drawers/drawer_start/drawer_start.tsx +2 -2
- package/src/surfaces/drawers/drawer_top/drawer_top.tsx +2 -2
- package/src/surfaces/modal/__stories__/modal.stories.tsx +54 -0
- package/src/surfaces/modal/modal.module.css +2 -1
- package/src/surfaces/modal/modal.tsx +9 -6
- package/src/surfaces/page/h_page.tsx +2 -2
- package/src/surfaces/page/v_page.tsx +2 -2
- package/src/surfaces/panel/__stories__/panel.stories.tsx +13 -12
- package/src/surfaces/panel/h_panel.tsx +3 -9
- package/src/surfaces/panel/v_panel.tsx +3 -3
- package/src/surfaces/popover/popover.tsx +2 -2
- package/src/surfaces/window/window.stories.tsx +1 -1
- package/src/surfaces/window/window.tsx +2 -6
- package/src/themes/index.ts +0 -2
- package/src/themes/stories/themes.stories.tsx +1 -1
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_inverted_materials.module.css +34 -0
- package/src/themes/themes/ergo/__stories__/components/material_picker/sb_material_picker.tsx +52 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_card.module.css +5 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_card.tsx +40 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/sb_tone_picker.tsx +83 -0
- package/src/themes/themes/ergo/__stories__/components/tone_picker/types.ts +7 -0
- package/src/themes/themes/ergo/__stories__/material.stories.tsx +154 -0
- package/src/themes/themes/ergo/__stories__/sb_materials.module.css +110 -0
- package/src/themes/themes/ergo/__stories__/utils.ts +92 -0
- package/src/themes/themes/ergo/ergo_theme.css +348 -15
- package/src/tokens/badge/badge.stories.tsx +6 -6
- package/src/tokens/badge/badge.tsx +3 -3
- package/src/tokens/bubble/bubble.stories.tsx +16 -9
- package/src/tokens/bubble/bubble.tsx +2 -2
- package/src/tokens/chip/chip.stories.tsx +1 -1
- package/src/tokens/chip/chip.tsx +2 -2
- package/src/typography/body_text/body_text.tsx +2 -2
- package/src/typography/callout/callout.tsx +2 -2
- package/src/typography/caption/caption.tsx +2 -2
- package/src/typography/footnote/footnote.tsx +2 -2
- package/src/typography/headline/headline.tsx +2 -2
- package/src/typography/subheadline/subheadline.tsx +2 -2
- package/src/typography/title/title.tsx +2 -2
- package/src/typography/typography-showcase.stories.tsx +2 -2
- package/src/utils/click_away_listener.stories.tsx +21 -11
- package/src/utils/responsive/responsive_renderer.stories.tsx +7 -7
- package/src/utils/scroll_away_listener.stories.tsx +11 -1
- package/tsconfig.json +0 -3
- package/dist/card.css +0 -1
- package/dist/portal-qqIp4SIl.js.map +0 -1
- package/dist/themes/stylesheets/reset.css +0 -1
- package/dist/themes/themes/ergo/ergo_theme.css +0 -1
- package/dist/themes/themes/windows_98/windows_98.css +0 -1
- package/src/surfaces/card/card.module.css +0 -5
- package/src/surfaces/modal/modal.stories.tsx +0 -15
- /package/dist/{overlay/portal/portal.css → portal_platform.css} +0 -0
|
@@ -1,39 +1,51 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { HStack as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsxs as J, jsx as i, Fragment as ae } from "react/jsx-runtime";
|
|
2
|
+
import { HStack as K } from "../../stacks/h_stack.js";
|
|
3
|
+
import { clsx as h } from "clsx";
|
|
4
|
+
import ie, { useRef as Q, useState as l, useMemo as X, Children as le, isValidElement as me, useLayoutEffect as w, useCallback as fe } from "react";
|
|
5
5
|
import "../../actions/button/base_button/base_button.js";
|
|
6
6
|
import "../../actions/button/button_group/button_group.js";
|
|
7
|
-
import { SlimButton as
|
|
7
|
+
import { SlimButton as he } from "../../actions/button/slim_button/slim_button.js";
|
|
8
8
|
import "../../actions/button/button/button.js";
|
|
9
9
|
import "../../actions/button/select_group/select_group.js";
|
|
10
10
|
import "../../actions/button/select_group/single_select_group.js";
|
|
11
|
-
import { Select as
|
|
12
|
-
import { MaskInput as
|
|
13
|
-
import { countriesPhoneInformation as
|
|
14
|
-
import { NotebookIcon as
|
|
15
|
-
import { Option as
|
|
16
|
-
import { SuggestionList as
|
|
17
|
-
import { stripNonNumericAfterCountryCode as
|
|
18
|
-
import
|
|
11
|
+
import { Select as be } from "../select/select.js";
|
|
12
|
+
import { MaskInput as Y } from "../mask_input/mask_input.js";
|
|
13
|
+
import { countriesPhoneInformation as v } from "./countries_phone_information.js";
|
|
14
|
+
import { NotebookIcon as de } from "@tcn/icons/notebook_icon.js";
|
|
15
|
+
import { Option as A } from "../options/option.js";
|
|
16
|
+
import { SuggestionList as ke } from "../suggestions/suggestion_list.js";
|
|
17
|
+
import { stripNonNumericAfterCountryCode as P } from "./utils.js";
|
|
18
|
+
import "../../utils/focus_redirect.js";
|
|
19
|
+
import "../../utils/click_away_listener.js";
|
|
20
|
+
import "../../utils/scroll_away_listener.js";
|
|
21
|
+
import { useForkRef as Ie } from "../../utils/hooks/use_fork_ref.js";
|
|
22
|
+
import "../../utils/hooks/use_resize_observer.js";
|
|
23
|
+
import '../../phone_number_input.css';const Ne = "_phone-number-input_5c4483d", ye = "_phone-number-input-select_a7b33ac", xe = "_phone-number-input-input_5b14556", ge = "_phone-number-input-phone-book-popover_1511f35", Pe = "_phone-number-input-phone-book_7999ca1", Se = "_phone-number-input-obfuscated_5a0ed8c", m = { "phone-number-input": Ne, "phone-number-input-select": ye, "phone-number-input-input": xe, "phone-number-input-phone-book-popover": ge, "phone-number-input-phone-book": Pe, "phone-number-input-obfuscated": Se }, _e = "•";
|
|
24
|
+
function Be(o) {
|
|
25
|
+
return o.map((n) => ({
|
|
26
|
+
...n,
|
|
27
|
+
placeholder: n.mask.replace(/[9a*]/g, _e)
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
const F = v.map((o) => ({
|
|
19
31
|
name: o.name,
|
|
20
32
|
selectedLabel: o.prefix,
|
|
21
33
|
optionLabel: `${o.prefix} (${o.code}) ${o.unicodeFlag}`,
|
|
22
34
|
value: o.code,
|
|
23
35
|
keywords: o.keywords
|
|
24
36
|
}));
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
F.sort((o, n) => parseInt(o.value) - parseInt(n.value));
|
|
38
|
+
const _ = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
|
|
39
|
+
v.forEach((o) => {
|
|
40
|
+
b.set(o.code, o), _.has(o.prefix) ? _.get(o.prefix)?.push(o) : _.set(o.prefix, [o]);
|
|
29
41
|
});
|
|
30
|
-
function
|
|
42
|
+
function Oe(o) {
|
|
31
43
|
if (o != null) {
|
|
32
44
|
const n = {};
|
|
33
45
|
return o.forEach((t) => {
|
|
34
46
|
n[t] = !0;
|
|
35
|
-
}),
|
|
36
|
-
|
|
47
|
+
}), F.filter((t) => !!n[t.value]).map((t) => /* @__PURE__ */ i(
|
|
48
|
+
A,
|
|
37
49
|
{
|
|
38
50
|
value: t.value,
|
|
39
51
|
label: t.selectedLabel,
|
|
@@ -43,8 +55,8 @@ function be(o) {
|
|
|
43
55
|
t.value
|
|
44
56
|
));
|
|
45
57
|
} else
|
|
46
|
-
return
|
|
47
|
-
|
|
58
|
+
return F.map((n) => /* @__PURE__ */ i(
|
|
59
|
+
A,
|
|
48
60
|
{
|
|
49
61
|
value: n.value,
|
|
50
62
|
label: n.selectedLabel,
|
|
@@ -54,157 +66,186 @@ function be(o) {
|
|
|
54
66
|
n.value
|
|
55
67
|
));
|
|
56
68
|
}
|
|
57
|
-
function
|
|
58
|
-
for (let
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
(
|
|
69
|
+
function S(o, n, t) {
|
|
70
|
+
for (let u = 5; u > 1; u--) {
|
|
71
|
+
const B = o.slice(0, u), d = _.get(B);
|
|
72
|
+
if (d != null) {
|
|
73
|
+
const c = d.find(
|
|
74
|
+
(k) => k.code === n
|
|
63
75
|
);
|
|
64
|
-
return
|
|
76
|
+
return c ?? d[0];
|
|
65
77
|
}
|
|
66
78
|
}
|
|
67
|
-
return
|
|
79
|
+
return b.get(t.toUpperCase()) || b.get("US");
|
|
68
80
|
}
|
|
69
|
-
const
|
|
81
|
+
const Qe = ie.forwardRef(function({
|
|
70
82
|
value: n = "",
|
|
71
83
|
defaultCountry: t = "US",
|
|
72
|
-
onChange:
|
|
73
|
-
countrySelectRef:
|
|
74
|
-
phoneNumberInputRef:
|
|
75
|
-
disabled:
|
|
76
|
-
allowedCountryCodes:
|
|
77
|
-
children:
|
|
78
|
-
...
|
|
79
|
-
},
|
|
80
|
-
const
|
|
84
|
+
onChange: u,
|
|
85
|
+
countrySelectRef: B,
|
|
86
|
+
phoneNumberInputRef: d,
|
|
87
|
+
disabled: c = !1,
|
|
88
|
+
allowedCountryCodes: k,
|
|
89
|
+
children: $,
|
|
90
|
+
...Z
|
|
91
|
+
}, ee) {
|
|
92
|
+
const I = Q(n), [U, O] = l(
|
|
81
93
|
null
|
|
82
|
-
),
|
|
94
|
+
), T = U != null, [f, V] = l(t), j = S(
|
|
83
95
|
n,
|
|
84
|
-
|
|
96
|
+
f,
|
|
85
97
|
t
|
|
86
|
-
), [
|
|
87
|
-
const e = n.split(
|
|
88
|
-
return e == null ? "" :
|
|
89
|
-
}),
|
|
90
|
-
(e) =>
|
|
91
|
-
), [
|
|
92
|
-
...
|
|
93
|
-
]),
|
|
94
|
-
function
|
|
95
|
-
const r =
|
|
96
|
-
if (r == null || (
|
|
98
|
+
), [N, y] = l(() => {
|
|
99
|
+
const e = n.split(j.prefix)[1];
|
|
100
|
+
return e == null ? "" : P(e);
|
|
101
|
+
}), z = X(() => le.toArray($).filter(
|
|
102
|
+
(e) => me(e) && e.type === A
|
|
103
|
+
), [$]), C = z.length > 0, [M, x] = l(j.code), [H, g] = l([
|
|
104
|
+
...v[0].masks
|
|
105
|
+
]), [a, R] = l(!1), [D, W] = l(!1), E = Q(null), q = Ie(d, E), oe = X(() => Oe(k), [k]);
|
|
106
|
+
function ne(e) {
|
|
107
|
+
const r = b.get(e);
|
|
108
|
+
if (r == null || (x(r.code), g([...r.masks]), V(r.code), N == null))
|
|
97
109
|
return;
|
|
98
|
-
const
|
|
99
|
-
|
|
110
|
+
const p = `${r.prefix}${P(N)}`;
|
|
111
|
+
I.current = p, u && u(p, !1);
|
|
100
112
|
}
|
|
101
|
-
|
|
102
|
-
const e =
|
|
113
|
+
w(() => {
|
|
114
|
+
const e = S(
|
|
103
115
|
n,
|
|
104
|
-
|
|
116
|
+
f,
|
|
105
117
|
t
|
|
106
118
|
);
|
|
107
|
-
|
|
108
|
-
}, [n,
|
|
109
|
-
function
|
|
110
|
-
const r =
|
|
111
|
-
|
|
119
|
+
x(e.code), g([...e.masks]), V(e.code);
|
|
120
|
+
}, [n, f, t]);
|
|
121
|
+
function te(e) {
|
|
122
|
+
const r = b.get(M)?.prefix, p = P(e), s = r + p;
|
|
123
|
+
a && R(!1), I.current = s, N !== e && y(e), u && u(s, !1);
|
|
112
124
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
125
|
+
function re(e) {
|
|
126
|
+
O(T ? null : e.currentTarget);
|
|
115
127
|
}
|
|
116
|
-
function
|
|
117
|
-
|
|
128
|
+
function G() {
|
|
129
|
+
O(null);
|
|
118
130
|
}
|
|
119
|
-
function
|
|
120
|
-
|
|
131
|
+
function ue(e, r, p, s) {
|
|
132
|
+
R(s), L(e, s), G();
|
|
121
133
|
}
|
|
122
|
-
function
|
|
134
|
+
function se(e) {
|
|
123
135
|
if (e.startsWith("+")) {
|
|
124
|
-
const r =
|
|
136
|
+
const r = S(
|
|
125
137
|
e,
|
|
126
|
-
|
|
138
|
+
f,
|
|
127
139
|
t
|
|
128
140
|
);
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
return
|
|
141
|
+
x(r.code), g([...r.masks]);
|
|
142
|
+
const p = e.split(r.prefix)[1];
|
|
143
|
+
return y(p), p;
|
|
132
144
|
}
|
|
133
145
|
return e;
|
|
134
146
|
}
|
|
135
|
-
|
|
136
|
-
(
|
|
137
|
-
|
|
147
|
+
function pe(e) {
|
|
148
|
+
W(!0), R(!1), y(e);
|
|
149
|
+
const r = b.get(M)?.prefix, p = P(e), s = r + p;
|
|
150
|
+
I.current = s, u && u(s, !1);
|
|
151
|
+
}
|
|
152
|
+
const L = fe(
|
|
153
|
+
(e, r = !1) => {
|
|
154
|
+
const p = I.current, s = S(
|
|
138
155
|
e,
|
|
139
|
-
|
|
156
|
+
f,
|
|
140
157
|
t
|
|
141
|
-
),
|
|
142
|
-
|
|
158
|
+
), ce = e.split(s.prefix)[1];
|
|
159
|
+
x(s.code), g([...s.masks]), V(s.code), p !== e && (y(ce), u && u(e, r));
|
|
143
160
|
},
|
|
144
|
-
[t,
|
|
161
|
+
[t, f, u]
|
|
145
162
|
);
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
}, [n,
|
|
149
|
-
|
|
163
|
+
return w(() => {
|
|
164
|
+
L(n);
|
|
165
|
+
}, [n, L]), w(() => {
|
|
166
|
+
D && !a && E.current && (E.current.focus(), W(!1));
|
|
167
|
+
}, [D, a]), /* @__PURE__ */ J(
|
|
168
|
+
K,
|
|
150
169
|
{
|
|
151
|
-
ref:
|
|
152
|
-
className:
|
|
170
|
+
ref: ee,
|
|
171
|
+
className: h(m["phone-number-input"], "phone-number-input"),
|
|
153
172
|
height: "auto",
|
|
154
|
-
...
|
|
173
|
+
...Z,
|
|
155
174
|
children: [
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
|
|
175
|
+
/* @__PURE__ */ i(
|
|
176
|
+
be,
|
|
158
177
|
{
|
|
159
|
-
className:
|
|
160
|
-
|
|
161
|
-
"phone-number-input-select"
|
|
162
|
-
),
|
|
163
|
-
ref: g,
|
|
178
|
+
className: h(m["phone-number-input-select"], "phone-number-input-select"),
|
|
179
|
+
ref: B,
|
|
164
180
|
width: "auto",
|
|
165
|
-
value:
|
|
166
|
-
onChange:
|
|
167
|
-
disabled:
|
|
168
|
-
"data-is-disabled":
|
|
169
|
-
|
|
181
|
+
value: a ? "" : M,
|
|
182
|
+
onChange: ne,
|
|
183
|
+
disabled: c || a,
|
|
184
|
+
"data-is-disabled": c || a,
|
|
185
|
+
"data-is-obfuscated": a,
|
|
186
|
+
placeholder: a ? "––" : void 0,
|
|
187
|
+
children: oe
|
|
170
188
|
}
|
|
171
189
|
),
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
|
|
190
|
+
/* @__PURE__ */ i(K, { width: "flex", className: h(m["phone-number-input-container"]), children: a ? /* @__PURE__ */ i(
|
|
191
|
+
Y,
|
|
174
192
|
{
|
|
175
|
-
ref:
|
|
176
|
-
value:
|
|
177
|
-
mask:
|
|
178
|
-
onChange:
|
|
179
|
-
disabled:
|
|
180
|
-
"data-is-disabled":
|
|
181
|
-
"data-has-phone-book":
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
193
|
+
ref: q,
|
|
194
|
+
value: "",
|
|
195
|
+
mask: Be(H),
|
|
196
|
+
onChange: pe,
|
|
197
|
+
disabled: c,
|
|
198
|
+
"data-is-disabled": c,
|
|
199
|
+
"data-has-phone-book": C,
|
|
200
|
+
"data-is-obfuscated": !0,
|
|
201
|
+
className: h(
|
|
202
|
+
m["phone-number-input"],
|
|
203
|
+
m["phone-number-input-obfuscated"],
|
|
204
|
+
"phone-number-input"
|
|
205
|
+
),
|
|
206
|
+
preparePasteValue: () => "",
|
|
207
|
+
prepareCopyValue: () => "",
|
|
208
|
+
prepareCutValue: () => ""
|
|
209
|
+
},
|
|
210
|
+
"obfuscated"
|
|
211
|
+
) : /* @__PURE__ */ i(
|
|
212
|
+
Y,
|
|
213
|
+
{
|
|
214
|
+
ref: q,
|
|
215
|
+
value: N,
|
|
216
|
+
mask: H,
|
|
217
|
+
onChange: te,
|
|
218
|
+
disabled: c,
|
|
219
|
+
"data-is-disabled": c,
|
|
220
|
+
"data-has-phone-book": C,
|
|
221
|
+
"data-is-obfuscated": !1,
|
|
222
|
+
className: h(m["phone-number-input"], "phone-number-input"),
|
|
223
|
+
preparePasteValue: se
|
|
224
|
+
},
|
|
225
|
+
"normal"
|
|
185
226
|
) }),
|
|
186
|
-
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
227
|
+
C && /* @__PURE__ */ J(ae, { children: [
|
|
228
|
+
/* @__PURE__ */ i(
|
|
229
|
+
he,
|
|
189
230
|
{
|
|
190
|
-
disabled:
|
|
191
|
-
className:
|
|
192
|
-
|
|
231
|
+
disabled: c,
|
|
232
|
+
className: h(
|
|
233
|
+
m["phone-number-input-phone-book"],
|
|
193
234
|
"phone-number-input-phone-book"
|
|
194
235
|
),
|
|
195
|
-
onClick:
|
|
236
|
+
onClick: re,
|
|
196
237
|
size: "md",
|
|
197
|
-
children: /* @__PURE__ */
|
|
238
|
+
children: /* @__PURE__ */ i(de, { size: "md" })
|
|
198
239
|
}
|
|
199
240
|
),
|
|
200
|
-
|
|
201
|
-
|
|
241
|
+
T && /* @__PURE__ */ i(
|
|
242
|
+
ke,
|
|
202
243
|
{
|
|
203
|
-
anchorElement:
|
|
204
|
-
onOptionSelect:
|
|
205
|
-
onClose:
|
|
244
|
+
anchorElement: U,
|
|
245
|
+
onOptionSelect: ue,
|
|
246
|
+
onClose: G,
|
|
206
247
|
noSuggestionMessage: "No phone numbers found",
|
|
207
|
-
children:
|
|
248
|
+
children: z
|
|
208
249
|
}
|
|
209
250
|
)
|
|
210
251
|
] })
|
|
@@ -213,6 +254,6 @@ const Re = ee.forwardRef(function({
|
|
|
213
254
|
);
|
|
214
255
|
});
|
|
215
256
|
export {
|
|
216
|
-
|
|
257
|
+
Qe as PhoneNumberInput
|
|
217
258
|
};
|
|
218
259
|
//# sourceMappingURL=phone_number_input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone_number_input.js","sources":["../../../src/inputs/phone_number_input/phone_number_input.tsx"],"sourcesContent":["import { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport classNames from 'classnames';\nimport React, {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n Children,\n isValidElement,\n} from 'react';\nimport { SlimButton } from '../../actions/index.js';\nimport { Select } from '../select/select.js';\nimport { MaskInput } from '../mask_input/mask_input.js';\nimport {\n CountryPhoneInformation,\n countriesPhoneInformation,\n} from './countries_phone_information.js';\nimport styles from './phone_number_input.module.css';\nimport { NotebookIcon } from '@tcn/icons/notebook_icon.js';\nimport { Option, OptionProps } from '../options/option.js';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { stripNonNumericAfterCountryCode } from './utils.js';\n\nconst countryList = countriesPhoneInformation.map(i => ({\n name: i.name,\n selectedLabel: i.prefix,\n optionLabel: `${i.prefix} (${i.code}) ${i.unicodeFlag}`,\n value: i.code,\n keywords: i.keywords,\n}));\n\ncountryList.sort((a, b) => parseInt(a.value) - parseInt(b.value));\n\nconst countryPrefixMap: Map<string, CountryPhoneInformation[]> = new Map();\nconst countryCodeMap: Map<string, CountryPhoneInformation> = new Map();\ncountriesPhoneInformation.forEach(i => {\n countryCodeMap.set(i.code, i);\n if (countryPrefixMap.has(i.prefix)) {\n countryPrefixMap.get(i.prefix)?.push(i);\n } else {\n countryPrefixMap.set(i.prefix, [i]);\n }\n});\n\nfunction createCountryOptions(allowedCountryCodes?: string[]) {\n if (allowedCountryCodes != null) {\n const allowedMap: Record<string, boolean> = {};\n allowedCountryCodes.forEach(c => {\n allowedMap[c] = true;\n });\n return countryList\n .filter(c => Boolean(allowedMap[c.value]))\n .map(i => {\n return (\n <Option\n key={i.value}\n value={i.value}\n label={i.selectedLabel}\n keywords={i.keywords}\n >\n {i.optionLabel}\n </Option>\n );\n });\n } else {\n return countryList.map(i => {\n return (\n <Option\n key={i.value}\n value={i.value}\n label={i.selectedLabel}\n keywords={i.keywords}\n >\n {i.optionLabel}\n </Option>\n );\n });\n }\n}\n\nfunction getCountryCodeFromValue(\n value: string,\n previousCountry: string,\n defaultCountry: string\n) {\n for (let x = 5; x > 1; x--) {\n const prefix = value.slice(0, x);\n const countriesInformation = countryPrefixMap.get(prefix);\n\n if (countriesInformation != null) {\n const countryInformation = countriesInformation.find(\n c => c.code === previousCountry\n );\n\n if (countryInformation != null) {\n return countryInformation;\n } else {\n return countriesInformation[0];\n }\n }\n }\n\n return (countryCodeMap.get(defaultCountry.toUpperCase()) ||\n countryCodeMap.get('US')) as CountryPhoneInformation;\n}\n\nexport interface PhoneNumberInputProps\n extends Omit<HStackProps, 'onChange' | 'children'> {\n value?: string;\n defaultCountry?: string;\n onChange?: (value: string) => void;\n countrySelectRef?: React.Ref<HTMLButtonElement>;\n phoneNumberInputRef?: React.Ref<HTMLInputElement>;\n disabled?: boolean;\n allowedCountryCodes?: string[];\n children?: React.ReactElement<OptionProps> | React.ReactElement<OptionProps>[];\n}\n\nexport const PhoneNumberInput = React.forwardRef(function PhoneNumberInput(\n {\n value = '',\n defaultCountry = 'US',\n onChange,\n countrySelectRef: countryRef,\n phoneNumberInputRef: numberRef,\n disabled = false,\n allowedCountryCodes,\n children,\n ...props\n }: PhoneNumberInputProps,\n ref: React.Ref<HTMLElement>\n) {\n const lastOutputValueRef = useRef(value);\n const [phoneBookElement, setPhoneBookElement] = useState<HTMLButtonElement | null>(\n null\n );\n const isPhoneBookOpen = phoneBookElement != null;\n const [selectedCountry, setSelectedCountry] = useState(defaultCountry);\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n const [phoneNumber, setPhoneNumber] = useState(() => {\n const phoneNumber = value.split(countryInformation.prefix)[1];\n\n return phoneNumber == null ? '' : stripNonNumericAfterCountryCode(phoneNumber);\n });\n\n // Extract valid Option components from children\n const phoneBookOptions = useMemo(() => {\n return Children.toArray(children).filter(\n (child): child is React.ReactElement<OptionProps> =>\n isValidElement(child) && child.type === Option\n );\n }, [children]);\n\n const showPhoneBook = phoneBookOptions.length > 0;\n const [countryCode, setCountryCode] = useState(countryInformation.code);\n const [currentMasks, setCurrentMasks] = useState([\n ...countriesPhoneInformation[0].masks,\n ]);\n\n const countryOptions = useMemo(() => {\n return createCountryOptions(allowedCountryCodes);\n }, [allowedCountryCodes]);\n\n function changeCountry(countryCodeValue: string) {\n const countryInformation = countryCodeMap.get(countryCodeValue);\n\n if (countryInformation == null) {\n return;\n }\n\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n\n if (phoneNumber == null) {\n return;\n }\n\n const value = `${countryInformation.prefix}${stripNonNumericAfterCountryCode(phoneNumber)}`;\n lastOutputValueRef.current = value;\n onChange && onChange(value);\n }\n\n useLayoutEffect(() => {\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n }, [value, selectedCountry, defaultCountry]);\n\n function transformValue(newPhoneNumber: string) {\n const countryPrefix = countryCodeMap.get(countryCode)?.prefix;\n const lineNumber = stripNonNumericAfterCountryCode(newPhoneNumber);\n const outputValue = countryPrefix + lineNumber;\n\n lastOutputValueRef.current = outputValue;\n phoneNumber !== newPhoneNumber && setPhoneNumber(newPhoneNumber);\n onChange && onChange(outputValue);\n }\n\n function togglePhoneBook(e: React.MouseEvent<HTMLButtonElement>) {\n if (isPhoneBookOpen) {\n setPhoneBookElement(null);\n } else {\n setPhoneBookElement(e.currentTarget);\n }\n }\n\n function closePhoneBook() {\n setPhoneBookElement(null);\n }\n\n function handlePhoneBookOptionSelect(value: string) {\n // Update the phone number with the selected value\n updatePhoneNumber(value);\n closePhoneBook();\n }\n\n function preparePasteValue(value: string) {\n if (value.startsWith('+')) {\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n\n const phoneNumber = value.split(countryInformation.prefix)[1];\n setPhoneNumber(phoneNumber);\n\n return phoneNumber;\n }\n\n return value;\n }\n\n const updatePhoneNumber = useCallback(\n (value: string) => {\n const oldValue = lastOutputValueRef.current;\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n const phoneNumber = value.split(countryInformation.prefix)[1];\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n\n if (oldValue !== value) {\n setPhoneNumber(phoneNumber);\n onChange && onChange(value);\n }\n },\n [defaultCountry, selectedCountry, onChange]\n );\n\n useLayoutEffect(() => {\n updatePhoneNumber(value);\n }, [value, updatePhoneNumber]);\n\n return (\n <HStack\n ref={ref}\n className={classNames(styles['phone-number-input'], 'phone-number-input')}\n height=\"auto\"\n {...props}\n >\n <Select\n className={classNames(\n styles['phone-number-input-select'],\n 'phone-number-input-select'\n )}\n ref={countryRef}\n width=\"auto\"\n value={countryCode}\n onChange={changeCountry}\n disabled={disabled}\n data-is-disabled={disabled}\n >\n {countryOptions}\n </Select>\n <HStack width=\"flex\" className={styles['phone-number-input-container']}>\n <MaskInput\n ref={numberRef}\n value={phoneNumber}\n mask={currentMasks}\n onChange={transformValue}\n disabled={disabled}\n data-is-disabled={disabled}\n data-has-phone-book={showPhoneBook}\n className={classNames(styles['phone-number-input'], 'phone-number-input')}\n preparePasteValue={preparePasteValue}\n />\n </HStack>\n {showPhoneBook && (\n <>\n <SlimButton\n disabled={disabled}\n className={classNames(\n styles['phone-number-input-phone-book'],\n 'phone-number-input-phone-book'\n )}\n onClick={togglePhoneBook}\n size=\"md\"\n >\n <NotebookIcon size=\"md\" />\n </SlimButton>\n\n {isPhoneBookOpen && (\n <SuggestionList\n anchorElement={phoneBookElement}\n onOptionSelect={handlePhoneBookOptionSelect}\n onClose={closePhoneBook}\n noSuggestionMessage=\"No phone numbers found\"\n >\n {phoneBookOptions}\n </SuggestionList>\n )}\n </>\n )}\n </HStack>\n );\n});\n"],"names":["countryList","countriesPhoneInformation","i","a","b","countryPrefixMap","countryCodeMap","createCountryOptions","allowedCountryCodes","allowedMap","c","jsx","Option","getCountryCodeFromValue","value","previousCountry","defaultCountry","x","prefix","countriesInformation","countryInformation","PhoneNumberInput","React","onChange","countryRef","numberRef","disabled","children","props","ref","lastOutputValueRef","useRef","phoneBookElement","setPhoneBookElement","useState","isPhoneBookOpen","selectedCountry","setSelectedCountry","phoneNumber","setPhoneNumber","stripNonNumericAfterCountryCode","phoneBookOptions","useMemo","Children","child","isValidElement","showPhoneBook","countryCode","setCountryCode","currentMasks","setCurrentMasks","countryOptions","changeCountry","countryCodeValue","useLayoutEffect","transformValue","newPhoneNumber","countryPrefix","lineNumber","outputValue","togglePhoneBook","closePhoneBook","handlePhoneBookOptionSelect","updatePhoneNumber","preparePasteValue","useCallback","oldValue","jsxs","HStack","classNames","styles","Select","MaskInput","Fragment","SlimButton","NotebookIcon","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;;0ZAwBMA,IAAcC,EAA0B,IAAI,CAAAC,OAAM;AAAA,EACtD,MAAMA,EAAE;AAAA,EACR,eAAeA,EAAE;AAAA,EACjB,aAAa,GAAGA,EAAE,MAAM,KAAKA,EAAE,IAAI,KAAKA,EAAE,WAAW;AAAA,EACrD,OAAOA,EAAE;AAAA,EACT,UAAUA,EAAE;AACd,EAAE;AAEFF,EAAY,KAAK,CAACG,GAAGC,MAAM,SAASD,EAAE,KAAK,IAAI,SAASC,EAAE,KAAK,CAAC;AAEhE,MAAMC,wBA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AAA,0BAEFiB,GAAA,EAAO,OAAM,QAAO,WAAWE,EAAO,8BAA8B,GACnE,UAAA,gBAAA3D;AAAA,UAAC6D;AAAA,UAAA;AAAA,YACC,KAAK/C;AAAA,YACL,OAAOa;AAAA,YACP,MAAMW;AAAA,YACN,UAAUM;AAAA,YACV,UAAA7B;AAAA,YACA,oBAAkBA;AAAA,YAClB,uBAAqBoB;AAAA,YACrB,WAAWuB,EAAWC,EAAO,oBAAoB,GAAG,oBAAoB;AAAA,YACxE,mBAAAN;AAAA,UAAA;AAAA,QAAA,GAEJ;AAAA,QACClB,KACC,gBAAAqB,EAAAM,GAAA,EACE,UAAA;AAAA,UAAA,gBAAA9D;AAAA,YAAC+D;AAAA,YAAA;AAAA,cACC,UAAAhD;AAAA,cACA,WAAW2C;AAAA,gBACTC,EAAO,+BAA+B;AAAA,gBACtC;AAAA,cAAA;AAAA,cAEF,SAASV;AAAA,cACT,MAAK;AAAA,cAEL,UAAA,gBAAAjD,EAACgE,IAAA,EAAa,MAAK,KAAA,CAAK;AAAA,YAAA;AAAA,UAAA;AAAA,UAGzBxC,KACC,gBAAAxB;AAAA,YAACiE;AAAA,YAAA;AAAA,cACC,eAAe5C;AAAA,cACf,gBAAgB8B;AAAA,cAChB,SAASD;AAAA,cACT,qBAAoB;AAAA,cAEnB,UAAApB;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"phone_number_input.js","sources":["../../../src/inputs/phone_number_input/phone_number_input.tsx"],"sourcesContent":["import { HStack, type HStackProps } from '../../stacks/h_stack.js';\nimport { clsx } from 'clsx';\nimport React, {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n Children,\n isValidElement,\n} from 'react';\nimport { SlimButton } from '../../actions/index.js';\nimport { Select } from '../select/select.js';\nimport { MaskInput } from '../mask_input/mask_input.js';\nimport {\n CountryPhoneInformation,\n countriesPhoneInformation,\n} from './countries_phone_information.js';\nimport styles from './phone_number_input.module.css';\nimport { NotebookIcon } from '@tcn/icons/notebook_icon.js';\nimport { Option, OptionProps } from '../options/option.js';\nimport { SuggestionList } from '../suggestions/suggestion_list.js';\nimport { stripNonNumericAfterCountryCode } from './utils.js';\nimport { useForkRef } from '../../utils/index.js';\n\nconst OBFUSCATED_CHARACTER = '•';\n\nfunction createObfuscatedMasks(masks: { mask: string; placeholder?: string }[]) {\n return masks.map(m => ({\n ...m,\n placeholder: m.mask.replace(/[9a*]/g, OBFUSCATED_CHARACTER),\n }));\n}\n\nconst countryList = countriesPhoneInformation.map(i => ({\n name: i.name,\n selectedLabel: i.prefix,\n optionLabel: `${i.prefix} (${i.code}) ${i.unicodeFlag}`,\n value: i.code,\n keywords: i.keywords,\n}));\n\ncountryList.sort((a, b) => parseInt(a.value) - parseInt(b.value));\n\nconst countryPrefixMap: Map<string, CountryPhoneInformation[]> = new Map();\nconst countryCodeMap: Map<string, CountryPhoneInformation> = new Map();\ncountriesPhoneInformation.forEach(i => {\n countryCodeMap.set(i.code, i);\n if (countryPrefixMap.has(i.prefix)) {\n countryPrefixMap.get(i.prefix)?.push(i);\n } else {\n countryPrefixMap.set(i.prefix, [i]);\n }\n});\n\nfunction createCountryOptions(allowedCountryCodes?: string[]) {\n if (allowedCountryCodes != null) {\n const allowedMap: Record<string, boolean> = {};\n allowedCountryCodes.forEach(c => {\n allowedMap[c] = true;\n });\n return countryList\n .filter(c => Boolean(allowedMap[c.value]))\n .map(i => {\n return (\n <Option\n key={i.value}\n value={i.value}\n label={i.selectedLabel}\n keywords={i.keywords}\n >\n {i.optionLabel}\n </Option>\n );\n });\n } else {\n return countryList.map(i => {\n return (\n <Option\n key={i.value}\n value={i.value}\n label={i.selectedLabel}\n keywords={i.keywords}\n >\n {i.optionLabel}\n </Option>\n );\n });\n }\n}\n\nfunction getCountryCodeFromValue(\n value: string,\n previousCountry: string,\n defaultCountry: string\n) {\n for (let x = 5; x > 1; x--) {\n const prefix = value.slice(0, x);\n const countriesInformation = countryPrefixMap.get(prefix);\n\n if (countriesInformation != null) {\n const countryInformation = countriesInformation.find(\n c => c.code === previousCountry\n );\n\n if (countryInformation != null) {\n return countryInformation;\n } else {\n return countriesInformation[0];\n }\n }\n }\n\n return (countryCodeMap.get(defaultCountry.toUpperCase()) ||\n countryCodeMap.get('US')) as CountryPhoneInformation;\n}\n\nexport interface PhoneNumberInputProps\n extends Omit<HStackProps, 'onChange' | 'children'> {\n value?: string;\n defaultCountry?: string;\n /**\n * Callback fired when the phone number value changes.\n * @param value - The phone number value with country prefix\n * @param obfuscate - Whether the selected phone number is obfuscated (e.g., from a phone book entry marked as obfuscated)\n */\n onChange?: (value: string, obfuscate: boolean) => void;\n countrySelectRef?: React.Ref<HTMLButtonElement>;\n phoneNumberInputRef?: React.Ref<HTMLInputElement>;\n disabled?: boolean;\n allowedCountryCodes?: string[];\n children?: React.ReactElement<OptionProps> | React.ReactElement<OptionProps>[];\n}\n\nexport const PhoneNumberInput = React.forwardRef(function PhoneNumberInput(\n {\n value = '',\n defaultCountry = 'US',\n onChange,\n countrySelectRef: countryRef,\n phoneNumberInputRef: numberRef,\n disabled = false,\n allowedCountryCodes,\n children,\n ...props\n }: PhoneNumberInputProps,\n ref: React.Ref<HTMLElement>\n) {\n const lastOutputValueRef = useRef(value);\n const [phoneBookElement, setPhoneBookElement] = useState<HTMLButtonElement | null>(\n null\n );\n const isPhoneBookOpen = phoneBookElement != null;\n const [selectedCountry, setSelectedCountry] = useState(defaultCountry);\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n const [phoneNumber, setPhoneNumber] = useState(() => {\n const phoneNumber = value.split(countryInformation.prefix)[1];\n\n return phoneNumber == null ? '' : stripNonNumericAfterCountryCode(phoneNumber);\n });\n\n // Extract valid Option components from children\n const phoneBookOptions = useMemo(() => {\n return Children.toArray(children).filter(\n (child): child is React.ReactElement<OptionProps> =>\n isValidElement(child) && child.type === Option\n );\n }, [children]);\n\n const showPhoneBook = phoneBookOptions.length > 0;\n const [countryCode, setCountryCode] = useState(countryInformation.code);\n const [currentMasks, setCurrentMasks] = useState([\n ...countriesPhoneInformation[0].masks,\n ]);\n const [obfuscateValue, setObfuscateValue] = useState(false);\n const [shouldFocusAfterClear, setShouldFocusAfterClear] = useState(false);\n const internalInputRef = useRef<HTMLInputElement>(null);\n const forkedInputRef = useForkRef(numberRef, internalInputRef);\n\n const countryOptions = useMemo(() => {\n return createCountryOptions(allowedCountryCodes);\n }, [allowedCountryCodes]);\n\n function changeCountry(countryCodeValue: string) {\n const countryInformation = countryCodeMap.get(countryCodeValue);\n\n if (countryInformation == null) {\n return;\n }\n\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n\n if (phoneNumber == null) {\n return;\n }\n\n const value = `${countryInformation.prefix}${stripNonNumericAfterCountryCode(phoneNumber)}`;\n lastOutputValueRef.current = value;\n onChange && onChange(value, false);\n }\n\n useLayoutEffect(() => {\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n }, [value, selectedCountry, defaultCountry]);\n\n function transformValue(newPhoneNumber: string) {\n const countryPrefix = countryCodeMap.get(countryCode)?.prefix;\n const lineNumber = stripNonNumericAfterCountryCode(newPhoneNumber);\n const outputValue = countryPrefix + lineNumber;\n\n // Clear obfuscated state when user types manually\n if (obfuscateValue) {\n setObfuscateValue(false);\n }\n\n lastOutputValueRef.current = outputValue;\n phoneNumber !== newPhoneNumber && setPhoneNumber(newPhoneNumber);\n onChange && onChange(outputValue, false);\n }\n\n function togglePhoneBook(e: React.MouseEvent<HTMLButtonElement>) {\n if (isPhoneBookOpen) {\n setPhoneBookElement(null);\n } else {\n setPhoneBookElement(e.currentTarget);\n }\n }\n\n function closePhoneBook() {\n setPhoneBookElement(null);\n }\n\n function handlePhoneBookOptionSelect(\n value: string,\n _label: string | undefined,\n _isSuggestion: boolean,\n obfuscate: boolean\n ) {\n // Update the phone number with the selected value\n setObfuscateValue(obfuscate);\n updatePhoneNumber(value, obfuscate);\n closePhoneBook();\n }\n\n function preparePasteValue(value: string) {\n if (value.startsWith('+')) {\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n\n const phoneNumber = value.split(countryInformation.prefix)[1];\n setPhoneNumber(phoneNumber);\n\n return phoneNumber;\n }\n\n return value;\n }\n\n function handleObfuscatedInputChange(newValue: string) {\n // When user types on a obfuscated input, clear the obfuscated state and start fresh\n // The newValue will be the digits the user typed (mask filters to valid input)\n setShouldFocusAfterClear(true);\n setObfuscateValue(false);\n setPhoneNumber(newValue);\n\n const countryPrefix = countryCodeMap.get(countryCode)?.prefix;\n const lineNumber = stripNonNumericAfterCountryCode(newValue);\n const outputValue = countryPrefix + lineNumber;\n lastOutputValueRef.current = outputValue;\n onChange && onChange(outputValue, false);\n }\n\n const updatePhoneNumber = useCallback(\n (value: string, obfuscate = false) => {\n const oldValue = lastOutputValueRef.current;\n const countryInformation = getCountryCodeFromValue(\n value,\n selectedCountry,\n defaultCountry\n );\n const phoneNumber = value.split(countryInformation.prefix)[1];\n setCountryCode(countryInformation.code);\n setCurrentMasks([...countryInformation.masks]);\n setSelectedCountry(countryInformation.code);\n\n if (oldValue !== value) {\n setPhoneNumber(phoneNumber);\n onChange && onChange(value, obfuscate);\n }\n },\n [defaultCountry, selectedCountry, onChange]\n );\n\n useLayoutEffect(() => {\n updatePhoneNumber(value);\n }, [value, updatePhoneNumber]);\n\n // Focus the input after transitioning from obfuscated to normal mode\n useLayoutEffect(() => {\n if (shouldFocusAfterClear && !obfuscateValue && internalInputRef.current) {\n internalInputRef.current.focus();\n setShouldFocusAfterClear(false);\n }\n }, [shouldFocusAfterClear, obfuscateValue]);\n\n return (\n <HStack\n ref={ref}\n className={clsx(styles['phone-number-input'], 'phone-number-input')}\n height=\"auto\"\n {...props}\n >\n <Select\n className={clsx(styles['phone-number-input-select'], 'phone-number-input-select')}\n ref={countryRef}\n width=\"auto\"\n value={obfuscateValue ? '' : countryCode}\n onChange={changeCountry}\n disabled={disabled || obfuscateValue}\n data-is-disabled={disabled || obfuscateValue}\n data-is-obfuscated={obfuscateValue}\n placeholder={obfuscateValue ? '––' : undefined}\n >\n {countryOptions}\n </Select>\n <HStack width=\"flex\" className={clsx(styles['phone-number-input-container'])}>\n {obfuscateValue ? (\n <MaskInput\n key=\"obfuscated\"\n ref={forkedInputRef}\n value=\"\"\n mask={createObfuscatedMasks(currentMasks)}\n onChange={handleObfuscatedInputChange}\n disabled={disabled}\n data-is-disabled={disabled}\n data-has-phone-book={showPhoneBook}\n data-is-obfuscated={true}\n className={clsx(\n styles['phone-number-input'],\n styles['phone-number-input-obfuscated'],\n 'phone-number-input'\n )}\n preparePasteValue={() => ''}\n prepareCopyValue={() => ''}\n prepareCutValue={() => ''}\n />\n ) : (\n <MaskInput\n key=\"normal\"\n ref={forkedInputRef}\n value={phoneNumber}\n mask={currentMasks}\n onChange={transformValue}\n disabled={disabled}\n data-is-disabled={disabled}\n data-has-phone-book={showPhoneBook}\n data-is-obfuscated={false}\n className={clsx(styles['phone-number-input'], 'phone-number-input')}\n preparePasteValue={preparePasteValue}\n />\n )}\n </HStack>\n {showPhoneBook && (\n <>\n <SlimButton\n disabled={disabled}\n className={clsx(\n styles['phone-number-input-phone-book'],\n 'phone-number-input-phone-book'\n )}\n onClick={togglePhoneBook}\n size=\"md\"\n >\n <NotebookIcon size=\"md\" />\n </SlimButton>\n\n {isPhoneBookOpen && (\n <SuggestionList\n anchorElement={phoneBookElement}\n onOptionSelect={handlePhoneBookOptionSelect}\n onClose={closePhoneBook}\n noSuggestionMessage=\"No phone numbers found\"\n >\n {phoneBookOptions}\n </SuggestionList>\n )}\n </>\n )}\n </HStack>\n );\n});\n"],"names":["OBFUSCATED_CHARACTER","createObfuscatedMasks","masks","m","countryList","countriesPhoneInformation","i","a","b","countryPrefixMap","countryCodeMap","createCountryOptions","allowedCountryCodes","allowedMap","c","jsx","Option","getCountryCodeFromValue","value","previousCountry","defaultCountry","x","prefix","countriesInformation","countryInformation","PhoneNumberInput","React","onChange","countryRef","numberRef","disabled","children","props","ref","lastOutputValueRef","useRef","phoneBookElement","setPhoneBookElement","useState","isPhoneBookOpen","selectedCountry","setSelectedCountry","phoneNumber","setPhoneNumber","stripNonNumericAfterCountryCode","phoneBookOptions","useMemo","Children","child","isValidElement","showPhoneBook","countryCode","setCountryCode","currentMasks","setCurrentMasks","obfuscateValue","setObfuscateValue","shouldFocusAfterClear","setShouldFocusAfterClear","internalInputRef","forkedInputRef","useForkRef","countryOptions","changeCountry","countryCodeValue","useLayoutEffect","transformValue","newPhoneNumber","countryPrefix","lineNumber","outputValue","togglePhoneBook","closePhoneBook","handlePhoneBookOptionSelect","_label","_isSuggestion","obfuscate","updatePhoneNumber","preparePasteValue","handleObfuscatedInputChange","newValue","useCallback","oldValue","jsxs","HStack","clsx","styles","Select","MaskInput","Fragment","SlimButton","NotebookIcon","SuggestionList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;8eAyBMA,KAAuB;AAE7B,SAASC,GAAsBC,GAAiD;AAC9E,SAAOA,EAAM,IAAI,CAAAC,OAAM;AAAA,IACrB,GAAGA;AAAA,IACH,aAAaA,EAAE,KAAK,QAAQ,UAAUH,EAAoB;AAAA,EAAA,EAC1D;AACJ;AAEA,MAAMI,IAAcC,EAA0B,IAAI,CAAAC,OAAM;AAAA,EACtD,MAAMA,EAAE;AAAA,EACR,eAAeA,EAAE;AAAA,EACjB,aAAa,GAAGA,EAAE,MAAM,KAAKA,EAAE,IAAI,KAAKA,EAAE,WAAW;AAAA,EACrD,OAAOA,EAAE;AAAA,EACT,UAAUA,EAAE;AACd,EAAE;AAEFF,EAAY,KAAK,CAACG,GAAG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AAoB;AAAA,cAC3BA,EAAO,+BAA+B;AAAA,cACtC;AAAA,YAAA;AAAA,YAEF,mBAAmB,MAAM;AAAA,YACzB,kBAAkB,MAAM;AAAA,YACxB,iBAAiB,MAAM;AAAA,UAAA;AAAA,UAhBnB;AAAA,QAAA,IAmBN,gBAAAvE;AAAA,UAACyE;AAAA,UAAA;AAAA,YAEC,KAAK5B;AAAA,YACL,OAAOlB;AAAA,YACP,MAAMW;AAAA,YACN,UAAUa;AAAA,YACV,UAAApC;AAAA,YACA,oBAAkBA;AAAA,YAClB,uBAAqBoB;AAAA,YACrB,sBAAoB;AAAA,YACpB,WAAWmC,EAAKC,EAAO,oBAAoB,GAAG,oBAAoB;AAAA,YAClE,mBAAAR;AAAA,UAAA;AAAA,UAVI;AAAA,QAAA,GAaV;AAAA,QACC5B,KACC,gBAAAiC,EAAAM,IAAA,EACE,UAAA;AAAA,UAAA,gBAAA1E;AAAA,YAAC2E;AAAA,YAAA;AAAA,cACC,UAAA5D;AAAA,cACA,WAAWuD;AAAA,gBACTC,EAAO,+BAA+B;AAAA,gBACtC;AAAA,cAAA;AAAA,cAEF,SAASf;AAAA,cACT,MAAK;AAAA,cAEL,UAAA,gBAAAxD,EAAC4E,IAAA,EAAa,MAAK,KAAA,CAAK;AAAA,YAAA;AAAA,UAAA;AAAA,UAGzBpD,KACC,gBAAAxB;AAAA,YAAC6E;AAAA,YAAA;AAAA,cACC,eAAexD;AAAA,cACf,gBAAgBqC;AAAA,cAChB,SAASD;AAAA,cACT,qBAAoB;AAAA,cAEnB,UAAA3B;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsxs as b, jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { clsx as x } from "clsx";
|
|
3
|
+
import h from "react";
|
|
4
4
|
import { HStack as p } from "../../stacks/h_stack.js";
|
|
5
5
|
import '../../radio.css';const y = "_radio_ce5c4e1", R = { radio: y };
|
|
6
6
|
let g = 0;
|
|
7
|
-
function k(
|
|
8
|
-
return
|
|
7
|
+
function k(o) {
|
|
8
|
+
return o ?? `radio-${g++}`;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const C = h.forwardRef(function({
|
|
11
11
|
name: l,
|
|
12
12
|
id: s,
|
|
13
|
-
label:
|
|
13
|
+
label: a,
|
|
14
14
|
className: c,
|
|
15
15
|
checked: r,
|
|
16
16
|
backgroundColor: u,
|
|
17
17
|
value: m,
|
|
18
18
|
onChange: e,
|
|
19
|
-
...
|
|
19
|
+
...t
|
|
20
20
|
}, f) {
|
|
21
21
|
const d = k(s);
|
|
22
22
|
return /* @__PURE__ */ b(p, { inline: !0, width: "auto", children: [
|
|
@@ -24,7 +24,7 @@ const j = x.forwardRef(function({
|
|
|
24
24
|
"input",
|
|
25
25
|
{
|
|
26
26
|
ref: f,
|
|
27
|
-
className:
|
|
27
|
+
className: x(c, R.radio, "radio"),
|
|
28
28
|
type: "radio",
|
|
29
29
|
id: d,
|
|
30
30
|
name: l,
|
|
@@ -32,26 +32,26 @@ const j = x.forwardRef(function({
|
|
|
32
32
|
style: { backgroundColor: u },
|
|
33
33
|
checked: r,
|
|
34
34
|
"data-checked": r,
|
|
35
|
-
"data-is-disabled":
|
|
35
|
+
"data-is-disabled": t.disabled,
|
|
36
36
|
"data-width": "fixed",
|
|
37
37
|
onChange: (i) => {
|
|
38
38
|
e && e(i.currentTarget.value, i);
|
|
39
39
|
},
|
|
40
|
-
...
|
|
40
|
+
...t
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
|
-
|
|
43
|
+
a && /* @__PURE__ */ n(
|
|
44
44
|
"label",
|
|
45
45
|
{
|
|
46
46
|
className: "radio-label",
|
|
47
|
-
style: { pointerEvents:
|
|
47
|
+
style: { pointerEvents: t.disabled ? "none" : "auto" },
|
|
48
48
|
htmlFor: d,
|
|
49
|
-
children:
|
|
49
|
+
children: a
|
|
50
50
|
}
|
|
51
51
|
)
|
|
52
52
|
] });
|
|
53
53
|
});
|
|
54
54
|
export {
|
|
55
|
-
|
|
55
|
+
C as Radio
|
|
56
56
|
};
|
|
57
57
|
//# sourceMappingURL=radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio.js","sources":["../../../src/inputs/radio/radio.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"radio.js","sources":["../../../src/inputs/radio/radio.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { HTMLAttributes } from 'react';\nimport styles from './radio.module.css';\nimport { HStack } from '../../stacks/h_stack.js';\n\nlet idIndex = 0;\n\nfunction resolveId(id?: string | null) {\n return id == null ? `radio-${idIndex++}` : id;\n}\n\nexport interface RadioProps extends Omit<HTMLAttributes<HTMLInputElement>, 'onChange'> {\n name: string;\n id: string;\n value: string;\n checked?: boolean;\n label?: string;\n backgroundColor?: string;\n disabled?: boolean;\n onChange?: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;\n}\n\nexport const Radio = React.forwardRef(function Radio(\n {\n name,\n id,\n label,\n className,\n checked,\n backgroundColor: color,\n value,\n onChange,\n ...props\n }: RadioProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const finalId = resolveId(id);\n return (\n <HStack inline width=\"auto\">\n <input\n ref={ref}\n className={clsx(className, styles.radio, 'radio')}\n type=\"radio\"\n id={finalId}\n name={name}\n value={value}\n style={{ backgroundColor: color }}\n checked={checked}\n data-checked={checked}\n data-is-disabled={props.disabled}\n data-width=\"fixed\"\n onChange={e => {\n onChange && onChange(e.currentTarget.value, e);\n }}\n {...props}\n />\n {label && (\n <label\n className=\"radio-label\"\n style={{ pointerEvents: props.disabled ? 'none' : 'auto' }}\n htmlFor={finalId}\n >\n {label}\n </label>\n )}\n </HStack>\n );\n});\n"],"names":["idIndex","resolveId","id","Radio","React","name","label","className","checked","color","value","onChange","props","ref","finalId","jsxs","HStack","jsx","clsx","styles","e"],"mappings":";;;;;AAKA,IAAIA,IAAU;AAEd,SAASC,EAAUC,GAAoB;AACrC,SAAOA,KAAa,SAASF,GAAS;AACxC;AAaO,MAAMG,IAAQC,EAAM,WAAW,SACpC;AAAA,EACE,MAAAC;AAAA,EACA,IAAAH;AAAA,EACA,OAAAI;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,iBAAiBC;AAAA,EACjB,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAUb,EAAUC,CAAE;AAC5B,SACE,gBAAAa,EAACC,GAAA,EAAO,QAAM,IAAC,OAAM,QACnB,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAJ;AAAA,QACA,WAAWK,EAAKX,GAAWY,EAAO,OAAO,OAAO;AAAA,QAChD,MAAK;AAAA,QACL,IAAIL;AAAA,QACJ,MAAAT;AAAA,QACA,OAAAK;AAAA,QACA,OAAO,EAAE,iBAAiBD,EAAA;AAAA,QAC1B,SAAAD;AAAA,QACA,gBAAcA;AAAA,QACd,oBAAkBI,EAAM;AAAA,QACxB,cAAW;AAAA,QACX,UAAU,CAAAQ,MAAK;AACb,UAAAT,KAAYA,EAASS,EAAE,cAAc,OAAOA,CAAC;AAAA,QAC/C;AAAA,QACC,GAAGR;AAAA,MAAA;AAAA,IAAA;AAAA,IAELN,KACC,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,eAAeL,EAAM,WAAW,SAAS,OAAA;AAAA,QAClD,SAASE;AAAA,QAER,UAAAR;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ,CAAC;"}
|