@cube-dev/ui-kit 0.0.0-canary-9917823 → 0.0.0-canary-2a1d026
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/CHANGELOG.md +12 -0
- package/cjs/_internal/hooks/index.js +12 -4
- package/cjs/_internal/hooks/use-chained-callback.js +2 -1
- package/cjs/_internal/hooks/use-deprecation-warning.js +6 -2
- package/cjs/_internal/hooks/use-effect-once.js +18 -0
- package/cjs/_internal/hooks/use-event.js +1 -1
- package/cjs/_internal/hooks/use-is-first-render.js +22 -0
- package/cjs/_internal/hooks/use-sync-ref.js +1 -1
- package/cjs/_internal/hooks/use-timer/index.js +6 -2
- package/cjs/_internal/hooks/use-timer/timer.js +1 -1
- package/cjs/_internal/hooks/use-timer/use-timer.js +1 -1
- package/cjs/_internal/hooks/use-update-effect.js +24 -0
- package/cjs/_internal/hooks/use-warn.js +50 -0
- package/cjs/_internal/index.js +6 -2
- package/cjs/components/Base.js +2 -2
- package/cjs/components/Block.js +2 -2
- package/cjs/components/GlobalStyles.js +1 -1
- package/cjs/components/GridProvider.js +7 -3
- package/cjs/components/HiddenInput.js +1 -1
- package/cjs/components/OpenTrasition.js +2 -2
- package/cjs/components/Root.js +2 -2
- package/cjs/components/actions/Action.js +2 -2
- package/cjs/components/actions/Button/Button.js +2 -2
- package/cjs/components/actions/Button/index.js +6 -3
- package/cjs/components/actions/ButtonGroup/ButtonGroup.js +2 -2
- package/cjs/components/actions/index.js +6 -2
- package/cjs/components/actions/use-action.js +1 -1
- package/cjs/components/content/ActiveZone/ActiveZone.js +2 -2
- package/cjs/components/content/Alert/Alert.js +2 -2
- package/cjs/components/content/Alert/index.js +6 -2
- package/cjs/components/content/Alert/types.js +1 -1
- package/cjs/components/content/Alert/use-alert.js +1 -1
- package/cjs/components/content/Avatar/Avatar.js +2 -2
- package/cjs/components/content/Badge/Badge.js +2 -2
- package/cjs/components/content/Card/Card.js +2 -2
- package/cjs/components/content/Content.js +2 -2
- package/cjs/components/content/CopySnippet/CopySnippet.js +4 -4
- package/cjs/components/content/CopySnippet/index.js +6 -2
- package/cjs/components/content/Divider.js +2 -2
- package/cjs/components/content/Footer.js +2 -2
- package/cjs/components/content/Header.js +2 -2
- package/cjs/components/content/Paragraph.js +2 -2
- package/cjs/components/content/Placeholder/Placeholder.js +2 -2
- package/cjs/components/content/PrismCode/PrismCode.js +2 -2
- package/cjs/components/content/Result/Result.js +3 -3
- package/cjs/components/content/Skeleton/Skeleton.js +12 -12
- package/cjs/components/content/Tag/Tag.js +3 -3
- package/cjs/components/content/Text.js +8 -8
- package/cjs/components/content/Title.js +4 -4
- package/cjs/components/forms/Checkbox/Checkbox.js +31 -14
- package/cjs/components/forms/Checkbox/CheckboxGroup.js +30 -25
- package/cjs/components/forms/Checkbox/context.js +1 -1
- package/cjs/components/forms/{FieldWrapper.js → FieldWrapper/FieldWrapper.js} +22 -20
- package/cjs/components/forms/FieldWrapper/extract-field-wrapper-props.js +50 -0
- package/cjs/components/forms/FieldWrapper/index.js +28 -0
- package/cjs/components/forms/FieldWrapper/types.js +11 -0
- package/cjs/components/forms/FileInput/FileInput.js +5 -5
- package/cjs/components/forms/Form/{Field.js → Field/LegacyField.js} +48 -27
- package/cjs/components/forms/Form/Field/index.js +29 -0
- package/cjs/components/forms/Form/Field/types.js +11 -0
- package/cjs/components/forms/Form/Field/use-field-props.js +61 -0
- package/cjs/components/forms/Form/Field/use-field.js +133 -0
- package/cjs/components/forms/Form/Form.js +3 -3
- package/cjs/components/forms/Form/Submit/Submit.js +25 -0
- package/cjs/components/forms/Form/Submit/index.js +26 -0
- package/cjs/components/forms/Form/SubmitError.js +2 -2
- package/cjs/components/forms/Form/index.js +20 -3
- package/cjs/components/forms/Form/types.js +1 -1
- package/cjs/components/forms/Form/useForm.js +2 -1
- package/cjs/components/forms/Form/validation.js +1 -1
- package/cjs/components/forms/Input/Input.js +3 -7
- package/cjs/components/forms/Input/index.js +6 -2
- package/cjs/components/forms/Label.js +4 -4
- package/cjs/components/forms/NumberInput/NumberInput.js +17 -11
- package/cjs/components/forms/NumberInput/StepButton.js +3 -3
- package/cjs/components/forms/PasswordInput/PasswordInput.js +23 -6
- package/cjs/components/forms/RadioGroup/Radio.js +17 -8
- package/cjs/components/forms/RadioGroup/RadioGroup.js +13 -5
- package/cjs/components/forms/RadioGroup/context.js +1 -1
- package/cjs/components/forms/SearchInput/SearchInput.js +4 -4
- package/cjs/components/forms/Slider/Gradation.js +2 -2
- package/cjs/components/forms/Slider/Header.js +1 -1
- package/cjs/components/forms/Slider/RangeSlider.js +3 -3
- package/cjs/components/forms/Slider/Slider.js +5 -4
- package/cjs/components/forms/Slider/SliderBase.js +5 -5
- package/cjs/components/forms/Slider/SliderInput.js +2 -2
- package/cjs/components/forms/Slider/SliderThumb.js +2 -2
- package/cjs/components/forms/Slider/SliderTrack.js +2 -2
- package/cjs/components/forms/Slider/elements.js +1 -1
- package/cjs/components/forms/Slider/index.js +6 -2
- package/cjs/components/forms/Slider/types.js +1 -1
- package/cjs/components/forms/Switch/Switch.js +19 -15
- package/cjs/components/forms/TextArea/TextArea.js +30 -27
- package/cjs/components/forms/TextInput/TextInput.js +16 -9
- package/cjs/components/forms/TextInput/TextInputBase.js +12 -40
- package/cjs/components/forms/TextInput/index.js +27 -0
- package/cjs/components/forms/index.js +6 -2
- package/cjs/components/layout/Flex.js +2 -2
- package/cjs/components/layout/Flow.js +2 -2
- package/cjs/components/layout/Grid.js +2 -2
- package/cjs/components/layout/Prefix.js +2 -2
- package/cjs/components/layout/Space.js +2 -2
- package/cjs/components/layout/Suffix.js +2 -2
- package/cjs/components/navigation/LegacyTabs/LegacyTabs.js +4 -4
- package/cjs/components/navigation/Link/Link.js +2 -2
- package/cjs/components/organisms/FileTabs/FileTabs.js +4 -4
- package/cjs/components/organisms/Modal/Modal.js +3 -3
- package/cjs/components/organisms/StatsCard/StatsCard.js +2 -2
- package/cjs/components/other/Base64Upload/Base64Upload.js +2 -2
- package/cjs/components/other/CloudLogo/CloudLogo.js +2 -2
- package/cjs/components/overlays/AlertDialog/AlertDialog.js +2 -2
- package/cjs/components/overlays/AlertDialog/AlertDialogApiProvider.js +2 -2
- package/cjs/components/overlays/AlertDialog/AlertDialogZone.js +2 -2
- package/cjs/components/overlays/AlertDialog/index.js +6 -2
- package/cjs/components/overlays/AlertDialog/types.js +1 -1
- package/cjs/components/overlays/Dialog/Dialog.js +17 -5
- package/cjs/components/overlays/Dialog/DialogContainer.js +2 -2
- package/cjs/components/overlays/Dialog/DialogForm.js +4 -6
- package/cjs/components/overlays/Dialog/DialogTrigger.js +11 -11
- package/cjs/components/overlays/Dialog/context.js +1 -1
- package/cjs/components/overlays/Dialog/index.js +6 -2
- package/cjs/components/overlays/Modal/Modal.js +23 -9
- package/cjs/components/overlays/Modal/OpenTransition.js +12 -3
- package/cjs/components/overlays/Modal/Overlay.js +6 -4
- package/cjs/components/overlays/Modal/Popover.js +20 -5
- package/cjs/components/overlays/Modal/Tray.js +14 -4
- package/cjs/components/overlays/Modal/Underlay.js +2 -2
- package/cjs/components/overlays/Modal/index.js +16 -1
- package/cjs/components/overlays/Modal/types.js +11 -0
- package/cjs/components/overlays/NewNotifications/Bar/FloatingNotification.js +2 -2
- package/cjs/components/overlays/NewNotifications/Bar/NotificationsBar.js +2 -2
- package/cjs/components/overlays/NewNotifications/Bar/TransitionComponent.js +2 -2
- package/cjs/components/overlays/NewNotifications/Bar/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/Dialog/NotificationsDialogTrigger.js +3 -3
- package/cjs/components/overlays/NewNotifications/Dialog/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/Notification.js +4 -4
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationAction.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationCloseButton.js +3 -3
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationDescription.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationFooter.js +7 -3
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationHeader.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationIcon.js +5 -5
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationProvider.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/NotificationView.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/NotificationView/types.js +1 -1
- package/cjs/components/overlays/NewNotifications/NotificationsContext/NotificationsProvider.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationsContext/index.js +1 -1
- package/cjs/components/overlays/NewNotifications/NotificationsContext/use-notifications.js +1 -1
- package/cjs/components/overlays/NewNotifications/NotificationsList/NotificationsList.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationsList/NotificationsListItem.js +2 -2
- package/cjs/components/overlays/NewNotifications/NotificationsList/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/NotificationsList/types.js +1 -1
- package/cjs/components/overlays/NewNotifications/hooks/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/hooks/types.js +1 -1
- package/cjs/components/overlays/NewNotifications/hooks/use-notification-list-item.js +1 -1
- package/cjs/components/overlays/NewNotifications/hooks/use-notifications-api.js +1 -1
- package/cjs/components/overlays/NewNotifications/hooks/use-notifications-list.js +1 -1
- package/cjs/components/overlays/NewNotifications/hooks/use-notifications-observer.js +1 -1
- package/cjs/components/overlays/NewNotifications/index.js +6 -2
- package/cjs/components/overlays/NewNotifications/types.js +1 -1
- package/cjs/components/overlays/Notification/Notification.js +2 -2
- package/cjs/components/overlays/OverlayWrapper.js +3 -3
- package/cjs/components/overlays/Toasts/Toast.js +4 -4
- package/cjs/components/overlays/Toasts/index.js +6 -2
- package/cjs/components/overlays/Toasts/types.js +1 -1
- package/cjs/components/overlays/Toasts/use-toasts-api.js +1 -1
- package/cjs/components/overlays/Tooltip/Tooltip.js +2 -2
- package/cjs/components/overlays/Tooltip/TooltipProvider.js +2 -2
- package/cjs/components/overlays/Tooltip/TooltipTrigger.js +4 -4
- package/cjs/components/overlays/Tooltip/context.js +1 -1
- package/cjs/components/pickers/ComboBox/ComboBox.js +31 -19
- package/cjs/components/pickers/Menu/Menu.js +3 -3
- package/cjs/components/pickers/Menu/MenuButton.js +5 -5
- package/cjs/components/pickers/Menu/MenuItem.js +3 -3
- package/cjs/components/pickers/Menu/MenuSection.js +3 -3
- package/cjs/components/pickers/Menu/MenuTrigger.js +10 -6
- package/cjs/components/pickers/Menu/context.js +6 -2
- package/cjs/components/pickers/Menu/styled.js +1 -1
- package/cjs/components/pickers/Select/Select.js +26 -11
- package/cjs/components/portal/Portal.js +2 -2
- package/cjs/components/portal/PortalProvider.js +1 -1
- package/cjs/components/portal/index.js +6 -2
- package/cjs/components/portal/storybook/templates/CustomRoot.js +2 -2
- package/cjs/components/portal/storybook/templates/PortalOrder.js +2 -2
- package/cjs/components/portal/storybook/templates/basic.js +2 -2
- package/cjs/components/portal/storybook/templates/index.js +6 -2
- package/cjs/components/portal/types.js +1 -1
- package/cjs/components/portal/usePortal.js +1 -1
- package/cjs/components/status/LoadingAnimation/LoadingAnimation.js +3 -3
- package/cjs/components/status/LoadingAnimation/index.js +1 -1
- package/cjs/components/status/Spin/Cube.js +1 -1
- package/cjs/components/status/Spin/InternalSpinner.js +2 -2
- package/cjs/components/status/Spin/Spin.js +3 -3
- package/cjs/components/status/Spin/SpinsContainer.js +1 -1
- package/cjs/components/status/Spin/index.js +6 -2
- package/cjs/components/status/Spin/types.js +1 -1
- package/cjs/components/status/index.js +6 -2
- package/cjs/data/themes.js +1 -1
- package/cjs/icons/Attention.js +2 -2
- package/cjs/icons/Cross.js +2 -2
- package/cjs/icons/Danger.js +2 -2
- package/cjs/icons/Success.js +2 -2
- package/cjs/icons/index.js +6 -2
- package/cjs/index.js +9 -7
- package/cjs/provider.js +3 -3
- package/cjs/providers/StyleProvider.js +2 -2
- package/cjs/services/notification.js +2 -2
- package/cjs/shared/form.js +1 -1
- package/cjs/shared/index.js +6 -2
- package/cjs/styled/index.js +6 -2
- package/cjs/styled/styled.js +9 -5
- package/cjs/tasty/index.js +6 -2
- package/cjs/tasty/providers/BreakpointsProvider.js +2 -2
- package/cjs/tasty/styles/align.js +1 -1
- package/cjs/tasty/styles/border.js +1 -1
- package/cjs/tasty/styles/boxShadow.combinator.js +1 -1
- package/cjs/tasty/styles/color.js +1 -1
- package/cjs/tasty/styles/createStyle.js +1 -1
- package/cjs/tasty/styles/dimension.js +1 -1
- package/cjs/tasty/styles/display.js +1 -1
- package/cjs/tasty/styles/fill.js +1 -1
- package/cjs/tasty/styles/flow.js +1 -1
- package/cjs/tasty/styles/font.js +1 -1
- package/cjs/tasty/styles/fontStyle.js +1 -1
- package/cjs/tasty/styles/gap.js +1 -1
- package/cjs/tasty/styles/groupRadius.js +1 -1
- package/cjs/tasty/styles/height.js +1 -1
- package/cjs/tasty/styles/index.js +6 -2
- package/cjs/tasty/styles/justify.js +1 -1
- package/cjs/tasty/styles/list.js +1 -1
- package/cjs/tasty/styles/margin.js +1 -1
- package/cjs/tasty/styles/marginBlock.js +1 -1
- package/cjs/tasty/styles/marginInline.js +1 -1
- package/cjs/tasty/styles/outline.js +1 -1
- package/cjs/tasty/styles/padding.js +1 -1
- package/cjs/tasty/styles/paddingBlock.js +1 -1
- package/cjs/tasty/styles/paddingInline.js +1 -1
- package/cjs/tasty/styles/predefined.js +1 -1
- package/cjs/tasty/styles/preset.js +1 -1
- package/cjs/tasty/styles/radius.js +1 -1
- package/cjs/tasty/styles/reset.js +1 -1
- package/cjs/tasty/styles/shadow.js +1 -1
- package/cjs/tasty/styles/styledScrollbar.js +1 -1
- package/cjs/tasty/styles/transition.js +1 -1
- package/cjs/tasty/styles/types.js +1 -1
- package/cjs/tasty/styles/width.js +1 -1
- package/cjs/tasty/tasty.js +9 -5
- package/cjs/tasty/types.js +1 -1
- package/cjs/tasty/utils/colors.js +1 -1
- package/cjs/tasty/utils/dotize.js +1 -1
- package/cjs/tasty/utils/filterBaseProps.js +1 -1
- package/cjs/tasty/utils/get-display-name.js +1 -1
- package/cjs/tasty/utils/index.js +1 -1
- package/cjs/tasty/utils/mergeStyles.js +1 -1
- package/cjs/tasty/utils/modAttrs.js +1 -1
- package/cjs/tasty/utils/renderStyles.js +1 -1
- package/cjs/tasty/utils/responsive.js +1 -1
- package/cjs/tasty/utils/string.js +1 -1
- package/cjs/tasty/utils/styles.js +1 -1
- package/cjs/tasty/utils/warnings.js +1 -1
- package/cjs/test/index.js +14 -2
- package/cjs/test/render.js +7 -3
- package/cjs/test/setup.js +48 -4
- package/cjs/test/utils/index.js +6 -2
- package/cjs/test/utils/wait.js +1 -1
- package/cjs/tokens.js +1 -1
- package/cjs/type-checks.js +1 -1
- package/cjs/utils/ResizeSensor.js +1 -1
- package/cjs/utils/modules.js +1 -1
- package/cjs/utils/promise.js +1 -1
- package/cjs/utils/random.js +1 -1
- package/cjs/utils/range.js +1 -1
- package/cjs/utils/react/Slots.js +3 -3
- package/cjs/utils/react/chain.js +1 -1
- package/cjs/utils/react/index.js +1 -1
- package/cjs/utils/react/interactions.js +1 -1
- package/cjs/utils/react/isTextOnly.js +1 -1
- package/cjs/utils/react/mapProps.js +1 -1
- package/cjs/utils/react/mergeProps.js +1 -1
- package/cjs/utils/react/nullableValue.js +1 -1
- package/cjs/utils/react/useCombinedRefs.js +1 -1
- package/cjs/utils/react/useId.js +1 -1
- package/cjs/utils/react/useLayoutEffect.js +6 -2
- package/cjs/utils/react/useViewportSize.js +1 -1
- package/cjs/utils/react/wrapNodeIfPlain.js +1 -1
- package/cjs/utils/transitions.js +1 -1
- package/cjs/utils/tree.js +1 -1
- package/cjs/utils/warnings.js +2 -2
- package/es/_internal/hooks/index.js +7 -3
- package/es/_internal/hooks/use-chained-callback.js +2 -1
- package/es/_internal/hooks/use-deprecation-warning.js +1 -1
- package/es/_internal/hooks/use-effect-once.js +14 -0
- package/es/_internal/hooks/use-event.js +1 -1
- package/es/_internal/hooks/use-is-first-render.js +18 -0
- package/es/_internal/hooks/use-sync-ref.js +1 -1
- package/es/_internal/hooks/use-timer/index.js +1 -1
- package/es/_internal/hooks/use-timer/timer.js +1 -1
- package/es/_internal/hooks/use-timer/use-timer.js +1 -1
- package/es/_internal/hooks/use-update-effect.js +20 -0
- package/es/_internal/hooks/use-warn.js +23 -0
- package/es/_internal/index.js +1 -1
- package/es/components/Base.js +2 -2
- package/es/components/Block.js +2 -2
- package/es/components/GlobalStyles.js +1 -1
- package/es/components/GridProvider.js +2 -2
- package/es/components/HiddenInput.js +1 -1
- package/es/components/OpenTrasition.js +2 -2
- package/es/components/Root.js +2 -2
- package/es/components/actions/Action.js +2 -2
- package/es/components/actions/Button/Button.js +2 -2
- package/es/components/actions/Button/index.js +1 -2
- package/es/components/actions/ButtonGroup/ButtonGroup.js +2 -2
- package/es/components/actions/index.js +1 -1
- package/es/components/actions/use-action.js +1 -1
- package/es/components/content/ActiveZone/ActiveZone.js +2 -2
- package/es/components/content/Alert/Alert.js +2 -2
- package/es/components/content/Alert/index.js +1 -1
- package/es/components/content/Alert/types.js +1 -1
- package/es/components/content/Alert/use-alert.js +1 -1
- package/es/components/content/Avatar/Avatar.js +2 -2
- package/es/components/content/Badge/Badge.js +2 -2
- package/es/components/content/Card/Card.js +2 -2
- package/es/components/content/Content.js +2 -2
- package/es/components/content/CopySnippet/CopySnippet.js +4 -4
- package/es/components/content/CopySnippet/index.js +1 -1
- package/es/components/content/Divider.js +2 -2
- package/es/components/content/Footer.js +2 -2
- package/es/components/content/Header.js +2 -2
- package/es/components/content/Paragraph.js +2 -2
- package/es/components/content/Placeholder/Placeholder.js +2 -2
- package/es/components/content/PrismCode/PrismCode.js +2 -2
- package/es/components/content/Result/Result.js +3 -3
- package/es/components/content/Skeleton/Skeleton.js +12 -12
- package/es/components/content/Tag/Tag.js +3 -3
- package/es/components/content/Text.js +8 -8
- package/es/components/content/Title.js +4 -4
- package/es/components/forms/Checkbox/Checkbox.js +32 -15
- package/es/components/forms/Checkbox/CheckboxGroup.js +30 -25
- package/es/components/forms/Checkbox/context.js +1 -1
- package/es/components/forms/{FieldWrapper.js → FieldWrapper/FieldWrapper.js} +22 -20
- package/es/components/forms/FieldWrapper/extract-field-wrapper-props.js +46 -0
- package/es/components/forms/FieldWrapper/index.js +12 -0
- package/es/components/forms/FieldWrapper/types.js +10 -0
- package/es/components/forms/FileInput/FileInput.js +4 -4
- package/es/components/forms/Form/{Field.js → Field/LegacyField.js} +47 -27
- package/es/components/forms/Form/Field/index.js +13 -0
- package/es/components/forms/Form/Field/types.js +10 -0
- package/es/components/forms/Form/Field/use-field-props.js +57 -0
- package/es/components/forms/Form/Field/use-field.js +129 -0
- package/es/components/forms/Form/Form.js +3 -3
- package/es/components/forms/Form/Submit/Submit.js +22 -0
- package/es/components/forms/Form/Submit/index.js +10 -0
- package/es/components/forms/Form/SubmitError.js +2 -2
- package/es/components/forms/Form/index.js +5 -3
- package/es/components/forms/Form/types.js +1 -1
- package/es/components/forms/Form/useForm.js +2 -1
- package/es/components/forms/Form/validation.js +1 -1
- package/es/components/forms/Input/Input.js +3 -7
- package/es/components/forms/Input/index.js +1 -1
- package/es/components/forms/Label.js +4 -4
- package/es/components/forms/NumberInput/NumberInput.js +17 -11
- package/es/components/forms/NumberInput/StepButton.js +3 -3
- package/es/components/forms/PasswordInput/PasswordInput.js +23 -6
- package/es/components/forms/RadioGroup/Radio.js +18 -9
- package/es/components/forms/RadioGroup/RadioGroup.js +14 -6
- package/es/components/forms/RadioGroup/context.js +1 -1
- package/es/components/forms/SearchInput/SearchInput.js +4 -4
- package/es/components/forms/Slider/Gradation.js +2 -2
- package/es/components/forms/Slider/Header.js +1 -1
- package/es/components/forms/Slider/RangeSlider.js +3 -3
- package/es/components/forms/Slider/Slider.js +5 -4
- package/es/components/forms/Slider/SliderBase.js +5 -5
- package/es/components/forms/Slider/SliderInput.js +2 -2
- package/es/components/forms/Slider/SliderThumb.js +2 -2
- package/es/components/forms/Slider/SliderTrack.js +2 -2
- package/es/components/forms/Slider/elements.js +1 -1
- package/es/components/forms/Slider/index.js +1 -1
- package/es/components/forms/Slider/types.js +1 -1
- package/es/components/forms/Switch/Switch.js +19 -15
- package/es/components/forms/TextArea/TextArea.js +31 -28
- package/es/components/forms/TextInput/TextInput.js +16 -9
- package/es/components/forms/TextInput/TextInputBase.js +13 -41
- package/es/components/forms/TextInput/index.js +11 -0
- package/es/components/forms/index.js +1 -1
- package/es/components/layout/Flex.js +2 -2
- package/es/components/layout/Flow.js +2 -2
- package/es/components/layout/Grid.js +2 -2
- package/es/components/layout/Prefix.js +2 -2
- package/es/components/layout/Space.js +2 -2
- package/es/components/layout/Suffix.js +2 -2
- package/es/components/navigation/LegacyTabs/LegacyTabs.js +4 -4
- package/es/components/navigation/Link/Link.js +2 -2
- package/es/components/organisms/FileTabs/FileTabs.js +4 -4
- package/es/components/organisms/Modal/Modal.js +3 -3
- package/es/components/organisms/StatsCard/StatsCard.js +2 -2
- package/es/components/other/Base64Upload/Base64Upload.js +2 -2
- package/es/components/other/CloudLogo/CloudLogo.js +2 -2
- package/es/components/overlays/AlertDialog/AlertDialog.js +2 -2
- package/es/components/overlays/AlertDialog/AlertDialogApiProvider.js +2 -2
- package/es/components/overlays/AlertDialog/AlertDialogZone.js +2 -2
- package/es/components/overlays/AlertDialog/index.js +1 -1
- package/es/components/overlays/AlertDialog/types.js +1 -1
- package/es/components/overlays/Dialog/Dialog.js +14 -5
- package/es/components/overlays/Dialog/DialogContainer.js +2 -2
- package/es/components/overlays/Dialog/DialogForm.js +5 -7
- package/es/components/overlays/Dialog/DialogTrigger.js +11 -11
- package/es/components/overlays/Dialog/context.js +1 -1
- package/es/components/overlays/Dialog/index.js +1 -1
- package/es/components/overlays/Modal/Modal.js +23 -9
- package/es/components/overlays/Modal/OpenTransition.js +11 -3
- package/es/components/overlays/Modal/Overlay.js +6 -4
- package/es/components/overlays/Modal/Popover.js +21 -6
- package/es/components/overlays/Modal/Tray.js +14 -4
- package/es/components/overlays/Modal/Underlay.js +2 -2
- package/es/components/overlays/Modal/index.js +2 -1
- package/es/components/overlays/Modal/types.js +10 -0
- package/es/components/overlays/NewNotifications/Bar/FloatingNotification.js +2 -2
- package/es/components/overlays/NewNotifications/Bar/NotificationsBar.js +2 -2
- package/es/components/overlays/NewNotifications/Bar/TransitionComponent.js +2 -2
- package/es/components/overlays/NewNotifications/Bar/index.js +1 -1
- package/es/components/overlays/NewNotifications/Dialog/NotificationsDialogTrigger.js +3 -3
- package/es/components/overlays/NewNotifications/Dialog/index.js +1 -1
- package/es/components/overlays/NewNotifications/Notification.js +4 -4
- package/es/components/overlays/NewNotifications/NotificationView/NotificationAction.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/NotificationCloseButton.js +3 -3
- package/es/components/overlays/NewNotifications/NotificationView/NotificationDescription.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/NotificationFooter.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/NotificationHeader.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/NotificationIcon.js +5 -5
- package/es/components/overlays/NewNotifications/NotificationView/NotificationProvider.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/NotificationView.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationView/index.js +1 -1
- package/es/components/overlays/NewNotifications/NotificationView/types.js +1 -1
- package/es/components/overlays/NewNotifications/NotificationsContext/NotificationsProvider.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationsContext/index.js +1 -1
- package/es/components/overlays/NewNotifications/NotificationsContext/use-notifications.js +1 -1
- package/es/components/overlays/NewNotifications/NotificationsList/NotificationsList.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationsList/NotificationsListItem.js +2 -2
- package/es/components/overlays/NewNotifications/NotificationsList/index.js +1 -1
- package/es/components/overlays/NewNotifications/NotificationsList/types.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/index.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/types.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/use-notification-list-item.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/use-notifications-api.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/use-notifications-list.js +1 -1
- package/es/components/overlays/NewNotifications/hooks/use-notifications-observer.js +1 -1
- package/es/components/overlays/NewNotifications/index.js +1 -1
- package/es/components/overlays/NewNotifications/types.js +1 -1
- package/es/components/overlays/Notification/Notification.js +2 -2
- package/es/components/overlays/OverlayWrapper.js +3 -3
- package/es/components/overlays/Toasts/Toast.js +4 -4
- package/es/components/overlays/Toasts/index.js +1 -1
- package/es/components/overlays/Toasts/types.js +1 -1
- package/es/components/overlays/Toasts/use-toasts-api.js +1 -1
- package/es/components/overlays/Tooltip/Tooltip.js +2 -2
- package/es/components/overlays/Tooltip/TooltipProvider.js +2 -2
- package/es/components/overlays/Tooltip/TooltipTrigger.js +4 -4
- package/es/components/overlays/Tooltip/context.js +1 -1
- package/es/components/pickers/ComboBox/ComboBox.js +29 -17
- package/es/components/pickers/Menu/Menu.js +3 -3
- package/es/components/pickers/Menu/MenuButton.js +5 -5
- package/es/components/pickers/Menu/MenuItem.js +3 -3
- package/es/components/pickers/Menu/MenuSection.js +3 -3
- package/es/components/pickers/Menu/MenuTrigger.js +5 -5
- package/es/components/pickers/Menu/context.js +1 -1
- package/es/components/pickers/Menu/styled.js +1 -1
- package/es/components/pickers/Select/Select.js +27 -12
- package/es/components/portal/Portal.js +2 -2
- package/es/components/portal/PortalProvider.js +1 -1
- package/es/components/portal/index.js +1 -1
- package/es/components/portal/storybook/templates/CustomRoot.js +2 -2
- package/es/components/portal/storybook/templates/PortalOrder.js +2 -2
- package/es/components/portal/storybook/templates/basic.js +2 -2
- package/es/components/portal/storybook/templates/index.js +1 -1
- package/es/components/portal/types.js +1 -1
- package/es/components/portal/usePortal.js +1 -1
- package/es/components/status/LoadingAnimation/LoadingAnimation.js +3 -3
- package/es/components/status/LoadingAnimation/index.js +1 -1
- package/es/components/status/Spin/Cube.js +1 -1
- package/es/components/status/Spin/InternalSpinner.js +2 -2
- package/es/components/status/Spin/Spin.js +3 -3
- package/es/components/status/Spin/SpinsContainer.js +1 -1
- package/es/components/status/Spin/index.js +1 -1
- package/es/components/status/Spin/types.js +1 -1
- package/es/components/status/index.js +1 -1
- package/es/data/themes.js +1 -1
- package/es/icons/Attention.js +2 -2
- package/es/icons/Cross.js +2 -2
- package/es/icons/Danger.js +2 -2
- package/es/icons/Success.js +2 -2
- package/es/icons/index.js +1 -1
- package/es/index.js +2 -3
- package/es/provider.js +3 -3
- package/es/providers/StyleProvider.js +2 -2
- package/es/services/notification.js +2 -2
- package/es/shared/form.js +1 -1
- package/es/shared/index.js +1 -1
- package/es/styled/index.js +1 -1
- package/es/styled/styled.js +4 -4
- package/es/tasty/index.js +1 -1
- package/es/tasty/providers/BreakpointsProvider.js +2 -2
- package/es/tasty/styles/align.js +1 -1
- package/es/tasty/styles/border.js +1 -1
- package/es/tasty/styles/boxShadow.combinator.js +1 -1
- package/es/tasty/styles/color.js +1 -1
- package/es/tasty/styles/createStyle.js +1 -1
- package/es/tasty/styles/dimension.js +1 -1
- package/es/tasty/styles/display.js +1 -1
- package/es/tasty/styles/fill.js +1 -1
- package/es/tasty/styles/flow.js +1 -1
- package/es/tasty/styles/font.js +1 -1
- package/es/tasty/styles/fontStyle.js +1 -1
- package/es/tasty/styles/gap.js +1 -1
- package/es/tasty/styles/groupRadius.js +1 -1
- package/es/tasty/styles/height.js +1 -1
- package/es/tasty/styles/index.js +1 -1
- package/es/tasty/styles/justify.js +1 -1
- package/es/tasty/styles/list.js +1 -1
- package/es/tasty/styles/margin.js +1 -1
- package/es/tasty/styles/marginBlock.js +1 -1
- package/es/tasty/styles/marginInline.js +1 -1
- package/es/tasty/styles/outline.js +1 -1
- package/es/tasty/styles/padding.js +1 -1
- package/es/tasty/styles/paddingBlock.js +1 -1
- package/es/tasty/styles/paddingInline.js +1 -1
- package/es/tasty/styles/predefined.js +1 -1
- package/es/tasty/styles/preset.js +1 -1
- package/es/tasty/styles/radius.js +1 -1
- package/es/tasty/styles/reset.js +1 -1
- package/es/tasty/styles/shadow.js +1 -1
- package/es/tasty/styles/styledScrollbar.js +1 -1
- package/es/tasty/styles/transition.js +1 -1
- package/es/tasty/styles/types.js +1 -1
- package/es/tasty/styles/width.js +1 -1
- package/es/tasty/tasty.js +4 -4
- package/es/tasty/types.js +1 -1
- package/es/tasty/utils/colors.js +1 -1
- package/es/tasty/utils/dotize.js +1 -1
- package/es/tasty/utils/filterBaseProps.js +1 -1
- package/es/tasty/utils/get-display-name.js +1 -1
- package/es/tasty/utils/index.js +1 -1
- package/es/tasty/utils/mergeStyles.js +1 -1
- package/es/tasty/utils/modAttrs.js +1 -1
- package/es/tasty/utils/renderStyles.js +1 -1
- package/es/tasty/utils/responsive.js +1 -1
- package/es/tasty/utils/string.js +1 -1
- package/es/tasty/utils/styles.js +1 -1
- package/es/tasty/utils/warnings.js +1 -1
- package/es/test/index.js +5 -1
- package/es/test/render.js +2 -2
- package/es/test/setup.js +43 -2
- package/es/test/utils/index.js +1 -1
- package/es/test/utils/wait.js +1 -1
- package/es/tokens.js +1 -1
- package/es/type-checks.js +1 -1
- package/es/utils/ResizeSensor.js +1 -1
- package/es/utils/modules.js +1 -1
- package/es/utils/promise.js +1 -1
- package/es/utils/random.js +1 -1
- package/es/utils/range.js +1 -1
- package/es/utils/react/Slots.js +3 -3
- package/es/utils/react/chain.js +1 -1
- package/es/utils/react/index.js +1 -1
- package/es/utils/react/interactions.js +1 -1
- package/es/utils/react/isTextOnly.js +1 -1
- package/es/utils/react/mapProps.js +1 -1
- package/es/utils/react/mergeProps.js +1 -1
- package/es/utils/react/nullableValue.js +1 -1
- package/es/utils/react/useCombinedRefs.js +1 -1
- package/es/utils/react/useId.js +1 -1
- package/es/utils/react/useLayoutEffect.js +1 -1
- package/es/utils/react/useViewportSize.js +1 -1
- package/es/utils/react/wrapNodeIfPlain.js +1 -1
- package/es/utils/transitions.js +1 -1
- package/es/utils/tree.js +1 -1
- package/es/utils/warnings.js +2 -2
- package/package.json +2 -1
- package/types/_internal/hooks/index.d.ts +6 -2
- package/types/_internal/hooks/use-effect-once.d.ts +2 -0
- package/types/_internal/hooks/use-is-first-render.d.ts +1 -0
- package/types/_internal/hooks/use-update-effect.d.ts +2 -0
- package/types/_internal/hooks/use-warn.d.ts +2 -0
- package/types/components/actions/Button/index.d.ts +0 -1
- package/types/components/forms/Checkbox/CheckboxGroup.d.ts +1 -2
- package/types/components/forms/FieldWrapper/FieldWrapper.d.ts +7 -0
- package/types/components/forms/FieldWrapper/extract-field-wrapper-props.d.ts +9 -0
- package/types/components/forms/FieldWrapper/index.d.ts +3 -0
- package/types/components/forms/{FieldWrapper.d.ts → FieldWrapper/types.d.ts} +15 -20
- package/types/components/forms/Form/Field/LegacyField.d.ts +14 -0
- package/types/components/forms/Form/Field/index.d.ts +4 -0
- package/types/components/forms/Form/Field/types.d.ts +72 -0
- package/types/components/forms/Form/Field/use-field-props.d.ts +19 -0
- package/types/components/forms/Form/Field/use-field.d.ts +7 -0
- package/types/components/forms/Form/Form.d.ts +3 -1
- package/types/components/forms/Form/Submit/Submit.d.ts +8 -0
- package/types/components/forms/Form/Submit/index.d.ts +1 -0
- package/types/components/forms/Form/index.d.ts +5 -1
- package/types/components/forms/Form/useForm.d.ts +1 -1
- package/types/components/forms/Input/Input.d.ts +1 -1
- package/types/components/forms/NumberInput/NumberInput.d.ts +2 -3
- package/types/components/forms/PasswordInput/PasswordInput.d.ts +3 -1
- package/types/components/forms/Slider/types.d.ts +1 -1
- package/types/components/forms/Switch/Switch.d.ts +2 -3
- package/types/components/forms/TextArea/TextArea.d.ts +3 -4
- package/types/components/forms/TextInput/TextInput.d.ts +5 -0
- package/types/components/forms/TextInput/TextInputBase.d.ts +1 -2
- package/types/components/forms/TextInput/index.d.ts +2 -0
- package/types/components/other/Base64Upload/Base64Upload.d.ts +4 -1
- package/types/components/overlays/Dialog/DialogForm.d.ts +1 -2
- package/types/components/overlays/Dialog/DialogTrigger.d.ts +2 -1
- package/types/components/overlays/Modal/Modal.d.ts +2 -1
- package/types/components/overlays/Modal/OpenTransition.d.ts +6 -1
- package/types/components/overlays/Modal/Overlay.d.ts +2 -1
- package/types/components/overlays/Modal/Popover.d.ts +3 -1
- package/types/components/overlays/Modal/Tray.d.ts +2 -1
- package/types/components/overlays/Modal/index.d.ts +1 -0
- package/types/components/overlays/Modal/types.d.ts +9 -0
- package/types/components/pickers/ComboBox/ComboBox.d.ts +5 -5
- package/types/components/pickers/Select/Select.d.ts +5 -2
- package/types/index.d.ts +1 -2
- package/types/shared/form.d.ts +10 -0
- package/types/test/index.d.ts +4 -0
- package/types/test/setup.d.ts +0 -1
- package/cjs/components/actions/Button/Submit.js +0 -29
- package/cjs/stories/FormFieldArgs.js +0 -324
- package/cjs/stories/components/ConfirmDeletionDialogForm.js +0 -36
- package/cjs/stories/components/DialogFormApp.js +0 -19
- package/cjs/stories/components/StyledButton.js +0 -37
- package/cjs/stories/lists/baseProps.js +0 -42
- package/es/components/actions/Button/Submit.js +0 -26
- package/es/stories/FormFieldArgs.js +0 -321
- package/es/stories/components/ConfirmDeletionDialogForm.js +0 -32
- package/es/stories/components/DialogFormApp.js +0 -15
- package/es/stories/components/StyledButton.js +0 -33
- package/es/stories/lists/baseProps.js +0 -39
- package/types/components/actions/Button/Submit.d.ts +0 -3
- package/types/components/forms/Form/Field.d.ts +0 -41
- package/types/stories/FormFieldArgs.d.ts +0 -369
- package/types/stories/components/ConfirmDeletionDialogForm.d.ts +0 -8
- package/types/stories/components/DialogFormApp.d.ts +0 -2
- package/types/stories/components/StyledButton.d.ts +0 -119
- package/types/stories/lists/baseProps.d.ts +0 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* author: Cube Dev Team
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
|
+
* Released under the MIT license.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useRef } from 'react';
|
|
9
|
+
import { useDebugValue } from 'react';
|
|
10
|
+
import { useChainedCallback, useEvent, useWarn } from '../../../../_internal';
|
|
11
|
+
import { useField } from './use-field';
|
|
12
|
+
import { useInsideLegacyField } from './LegacyField';
|
|
13
|
+
export function useFieldProps(props, params = {}) {
|
|
14
|
+
// We use ref here to "memoize" initial value
|
|
15
|
+
const isDisabledRef = useRef(params.unsafe__isDisabled ?? false);
|
|
16
|
+
const { valuePropsMapper = ({ value, onChange }) => ({
|
|
17
|
+
value: value ?? null,
|
|
18
|
+
onChange,
|
|
19
|
+
}), defaultValidationTrigger = 'onBlur', } = params;
|
|
20
|
+
const isInsideLegacyField = useInsideLegacyField();
|
|
21
|
+
useWarn(isInsideLegacyField, '<Field /> is deprecated, use component without <Field /> instead.');
|
|
22
|
+
if (isInsideLegacyField || isDisabledRef.current || props.name == null) {
|
|
23
|
+
return props;
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
26
|
+
const field = useField(props, {
|
|
27
|
+
defaultValidationTrigger: params.defaultValidationTrigger,
|
|
28
|
+
});
|
|
29
|
+
const isOutsideOfForm = field?.form == null;
|
|
30
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
31
|
+
const onBlurChained = useChainedCallback(field?.onBlur,
|
|
32
|
+
// TODO: remove type casting after updating to typescipt@4.9
|
|
33
|
+
'onBlur' in props ? props.onBlur : undefined);
|
|
34
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
+
const onChangeEvent = useEvent((value, dontTouch) => {
|
|
36
|
+
return field?.onChange?.(value, dontTouch, field?.validateTrigger ?? defaultValidationTrigger);
|
|
37
|
+
});
|
|
38
|
+
const result = isOutsideOfForm
|
|
39
|
+
? props
|
|
40
|
+
: {
|
|
41
|
+
...props,
|
|
42
|
+
...field,
|
|
43
|
+
...valuePropsMapper({
|
|
44
|
+
value: field.value,
|
|
45
|
+
onChange: onChangeEvent,
|
|
46
|
+
}),
|
|
47
|
+
validateTrigger: field.validateTrigger ?? defaultValidationTrigger,
|
|
48
|
+
onBlur: onBlurChained,
|
|
49
|
+
};
|
|
50
|
+
if (process.env.NODE_ENV === 'development') {
|
|
51
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
52
|
+
useDebugValue(result);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* author: Cube Dev Team
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
|
+
* Released under the MIT license.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
9
|
+
import { useEvent, useWarn } from '../../../../_internal';
|
|
10
|
+
import { useFormProps } from '../Form';
|
|
11
|
+
const ID_MAP = {};
|
|
12
|
+
function createId(name) {
|
|
13
|
+
if (!name)
|
|
14
|
+
return;
|
|
15
|
+
if (!ID_MAP[name]) {
|
|
16
|
+
ID_MAP[name] = [];
|
|
17
|
+
}
|
|
18
|
+
let i = 0;
|
|
19
|
+
let id;
|
|
20
|
+
do {
|
|
21
|
+
id = i ? `${name}_${i}` : name;
|
|
22
|
+
i++;
|
|
23
|
+
} while (ID_MAP[name].includes(id));
|
|
24
|
+
ID_MAP[name].push(id);
|
|
25
|
+
return id;
|
|
26
|
+
}
|
|
27
|
+
function removeId(name, id) {
|
|
28
|
+
if (!ID_MAP[name])
|
|
29
|
+
return;
|
|
30
|
+
ID_MAP[name] = ID_MAP[name].filter((_id) => _id !== id);
|
|
31
|
+
}
|
|
32
|
+
export function useField(props, params) {
|
|
33
|
+
props = useFormProps(props);
|
|
34
|
+
let { defaultValue, id, idPrefix, name, form, rules, validateTrigger = params.defaultValidationTrigger, validationState, shouldUpdate, } = props;
|
|
35
|
+
const nonInput = !name;
|
|
36
|
+
const fieldName = name ?? '';
|
|
37
|
+
const [fieldId, setFieldId] = useState(id ?? (idPrefix ? `${idPrefix}_${fieldName}` : fieldName));
|
|
38
|
+
let field = form?.getFieldInstance(fieldName);
|
|
39
|
+
if (!field) {
|
|
40
|
+
field = form?.createField(fieldName, true);
|
|
41
|
+
}
|
|
42
|
+
useWarn(!form && name !== undefined, 'Form Field requires declared form instance if field name is specified');
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
let newId;
|
|
45
|
+
if (!id && !nonInput) {
|
|
46
|
+
newId = createId(fieldId);
|
|
47
|
+
setFieldId(newId);
|
|
48
|
+
}
|
|
49
|
+
return () => {
|
|
50
|
+
if (!id) {
|
|
51
|
+
removeId(idPrefix ? `${idPrefix}_${fieldName}` : fieldName, newId);
|
|
52
|
+
}
|
|
53
|
+
if (fieldName && form) {
|
|
54
|
+
form.removeField(fieldName);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
if (field) {
|
|
59
|
+
field.rules = rules;
|
|
60
|
+
if (defaultValue != null && !field.touched) {
|
|
61
|
+
form?.setFieldValue(fieldName, defaultValue, false, true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let isRequired = rules && !!rules.find((rule) => rule.required);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!form)
|
|
67
|
+
return;
|
|
68
|
+
if (field) {
|
|
69
|
+
form.forceReRender();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
form.createField(fieldName);
|
|
73
|
+
}
|
|
74
|
+
}, [field]);
|
|
75
|
+
const onBlurHandler = useEvent(() => {
|
|
76
|
+
if (validateTrigger === 'onBlur') {
|
|
77
|
+
// We need a timeout so the change event can be done.
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
form?.validateField(fieldName).catch(() => { }); // do nothing on fail
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const onChangeHandler = useEvent((value, dontTouch) => {
|
|
84
|
+
const field = form?.getFieldInstance(fieldName);
|
|
85
|
+
if (shouldUpdate) {
|
|
86
|
+
const fieldsValue = form?.getFieldsValue();
|
|
87
|
+
// check if we should update the value of the field
|
|
88
|
+
const shouldNotBeUpdated = typeof shouldUpdate === 'boolean'
|
|
89
|
+
? !shouldUpdate
|
|
90
|
+
: !shouldUpdate(fieldsValue, {
|
|
91
|
+
...fieldsValue,
|
|
92
|
+
[fieldName]: value,
|
|
93
|
+
});
|
|
94
|
+
if (shouldNotBeUpdated) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
form?.setFieldValue(fieldName, value, !dontTouch, false, dontTouch);
|
|
99
|
+
if (!dontTouch &&
|
|
100
|
+
(validateTrigger === 'onChange' || field?.errors?.length)) {
|
|
101
|
+
form?.validateField(fieldName).catch(() => { }); // do nothing on fail
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return useMemo(() => ({
|
|
105
|
+
id: fieldId,
|
|
106
|
+
name: fieldName,
|
|
107
|
+
value: field?.inputValue,
|
|
108
|
+
validateTrigger,
|
|
109
|
+
form,
|
|
110
|
+
validationState: validationState ?? (field?.errors?.length ? 'invalid' : undefined),
|
|
111
|
+
...(isRequired && { isRequired }),
|
|
112
|
+
...(field?.errors?.length && { message: field.errors[0] }),
|
|
113
|
+
onBlur: onBlurHandler,
|
|
114
|
+
onChange: onChangeHandler,
|
|
115
|
+
}), [
|
|
116
|
+
form,
|
|
117
|
+
field?.errors,
|
|
118
|
+
field?.inputValue,
|
|
119
|
+
fieldId,
|
|
120
|
+
fieldName,
|
|
121
|
+
isRequired,
|
|
122
|
+
onBlurHandler,
|
|
123
|
+
onChangeHandler,
|
|
124
|
+
validateTrigger,
|
|
125
|
+
validationState,
|
|
126
|
+
]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -106,7 +106,7 @@ function Form(props, ref) {
|
|
|
106
106
|
// onSubmit(Object.fromEntries(new FormData(e.target).entries()));
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
[form] = useForm(form, ref
|
|
109
|
+
[form] = useForm(form, ref?.current, {
|
|
110
110
|
onSubmit: onSubmitCallback,
|
|
111
111
|
onValuesChange,
|
|
112
112
|
});
|
|
@@ -138,7 +138,7 @@ function Form(props, ref) {
|
|
|
138
138
|
form?.setInitialFieldsValue(defaultValues);
|
|
139
139
|
}
|
|
140
140
|
}, [defaultValues]);
|
|
141
|
-
return (_jsx(FormElement, { ...filterBaseProps(otherProps, { propNames: formPropNames }), ref: domRef, noValidate: true, styles: styles, mods: { 'has-sider': labelPosition === 'side', horizontal: isHorizontal }, onSubmit: onSubmitCallback, children: _jsx(FormContext.Provider, { value: ctx, children: _jsx(Provider, { insideForm: true, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, validationState: validationState, children: children }
|
|
141
|
+
return (_jsx(FormElement, { ...filterBaseProps(otherProps, { propNames: formPropNames }), ref: domRef, noValidate: true, styles: styles, mods: { 'has-sider': labelPosition === 'side', horizontal: isHorizontal }, onSubmit: onSubmitCallback, children: _jsx(FormContext.Provider, { value: ctx, children: _jsx(Provider, { insideForm: true, isDisabled: isDisabled, isReadOnly: isReadOnly, isRequired: isRequired, validationState: validationState, children: children }) }) }));
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Forms allow users to enter data that can be submitted while providing alignment and styling for form fields.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* author: Cube Dev Team
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
|
+
* Released under the MIT license.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { forwardRef } from 'react';
|
|
10
|
+
import { useProviderProps } from '../../../../provider';
|
|
11
|
+
import { useFormProps } from '../Form';
|
|
12
|
+
import { Button } from '../../../actions';
|
|
13
|
+
export const Submit = forwardRef(function Submit(props, ref) {
|
|
14
|
+
props = useProviderProps(props);
|
|
15
|
+
props = useFormProps(props);
|
|
16
|
+
const { form, ...otherProps } = props;
|
|
17
|
+
const formData = form?.getFieldsValue() ?? {};
|
|
18
|
+
const isInvalid = Object.keys(formData).some((name) => form?.isFieldInvalid(name) ?? false);
|
|
19
|
+
return (_jsx(Button, { ref: ref, type: "primary", htmlType: "submit", isLoading: form?.isSubmitting, isDisabled: isInvalid, ...otherProps }));
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -21,7 +21,7 @@ export const SubmitError = function SubmitError(props) {
|
|
|
21
21
|
typeof submitError !== 'string') {
|
|
22
22
|
submitError = 'Internal error';
|
|
23
23
|
}
|
|
24
|
-
return (_jsx(Alert, { theme: "danger", ...props, children: submitError }
|
|
24
|
+
return (_jsx(Alert, { theme: "danger", ...props, children: submitError }));
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { Submit } from './Submit';
|
|
8
9
|
import { Field } from './Field';
|
|
9
10
|
import { SubmitError } from './SubmitError';
|
|
10
11
|
import { useForm } from './useForm';
|
|
11
12
|
import { useFormProps, FormContext, Form as _Form } from './Form';
|
|
12
|
-
const Form = Object.assign(_Form, { Item: Field, useForm, SubmitError });
|
|
13
|
-
export { useFormProps, Form, Field, useForm, FormContext, SubmitError };
|
|
13
|
+
const Form = Object.assign(_Form, { Item: Field, useForm, Submit, SubmitError });
|
|
14
|
+
export { useFormProps, Form, Field, useForm, FormContext, Submit, SubmitError };
|
|
15
|
+
export * from './Field';
|
|
14
16
|
|
|
15
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -217,6 +217,7 @@ export class CubeFormInstance {
|
|
|
217
217
|
if (!skipRender) {
|
|
218
218
|
this.forceReRender();
|
|
219
219
|
}
|
|
220
|
+
return this.fields[name];
|
|
220
221
|
}
|
|
221
222
|
removeField(name, skipRender) {
|
|
222
223
|
if (this.fields[name]) {
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { forwardRef } from 'react';
|
|
10
|
-
import { TextInput } from '../TextInput/TextInput';
|
|
8
|
+
import { TextInput } from '../TextInput';
|
|
11
9
|
import { PasswordInput } from '../PasswordInput/PasswordInput';
|
|
12
10
|
import { NumberInput } from '../NumberInput/NumberInput';
|
|
13
11
|
import { FileInput } from '../FileInput/FileInput';
|
|
14
12
|
import { TextArea } from '../TextArea/TextArea';
|
|
15
|
-
export const Input = Object.assign(
|
|
16
|
-
return _jsx(TextInput, { ref: ref, ...props }, void 0);
|
|
17
|
-
}), {
|
|
13
|
+
export const Input = Object.assign(TextInput, {
|
|
18
14
|
Text: TextInput,
|
|
19
15
|
Password: PasswordInput,
|
|
20
16
|
Number: NumberInput,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ const REQUIRED_ICON = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", versio
|
|
|
16
16
|
width: '.8em',
|
|
17
17
|
height: '.8em',
|
|
18
18
|
transform: 'rotate(-5deg)',
|
|
19
|
-
}, children: _jsx("switch", { children: _jsx("g", { children: _jsx("polygon", { fill: "currentColor", points: "97.5,47.5 90.5,26.1 61.3,35.6 61.3,4.8 38.7,4.8 38.7,35.6 9.5,26.1 2.5,47.5 31.8,57 13.7,82 31.9,95.2 50,70.3 68.1,95.2 86.3,82 68.2,57" }
|
|
19
|
+
}, children: _jsx("switch", { children: _jsx("g", { children: _jsx("polygon", { fill: "currentColor", points: "97.5,47.5 90.5,26.1 61.3,35.6 61.3,4.8 38.7,4.8 38.7,35.6 9.5,26.1 2.5,47.5 31.8,57 13.7,82 31.9,95.2 50,70.3 68.1,95.2 86.3,82 68.2,57" }) }) }) }));
|
|
20
20
|
const INTL_MESSAGES = {
|
|
21
21
|
'(required)': '(required)',
|
|
22
22
|
'(optional)': '(optional)',
|
|
@@ -58,7 +58,7 @@ function Label(props, ref) {
|
|
|
58
58
|
: formatMessage('(optional)');
|
|
59
59
|
let icon = (_jsx("span", { "aria-label": includeNecessityIndicatorInAccessibilityName
|
|
60
60
|
? formatMessage('(required)')
|
|
61
|
-
: undefined, children: REQUIRED_ICON }
|
|
61
|
+
: undefined, children: REQUIRED_ICON }));
|
|
62
62
|
return (_jsx(LabelElement, { ...filterBaseProps(otherProps), ref: domRef, styles: styles, htmlFor: labelFor || htmlFor, mods: {
|
|
63
63
|
side: labelPosition === 'side',
|
|
64
64
|
disabled: isDisabled,
|
|
@@ -68,7 +68,7 @@ function Label(props, ref) {
|
|
|
68
68
|
(necessityIndicator === 'icon' && isRequired)) &&
|
|
69
69
|
' \u200b', necessityIndicator === 'label' && (_jsx("span", { "aria-hidden": !includeNecessityIndicatorInAccessibilityName
|
|
70
70
|
? isRequired
|
|
71
|
-
: undefined, children: necessityLabel }
|
|
71
|
+
: undefined, children: necessityLabel })), necessityIndicator === 'icon' && isRequired && icon] })) }));
|
|
72
72
|
}
|
|
73
73
|
let _Label = forwardRef(Label);
|
|
74
74
|
export { _Label as Label };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -10,9 +10,9 @@ import { forwardRef, useRef } from 'react';
|
|
|
10
10
|
import { useLocale } from '@react-aria/i18n';
|
|
11
11
|
import { useNumberFieldState } from '@react-stately/numberfield';
|
|
12
12
|
import { useNumberField } from '@react-aria/numberfield';
|
|
13
|
-
import {
|
|
13
|
+
import { useFieldProps } from '../Form';
|
|
14
14
|
import { useProviderProps } from '../../../provider';
|
|
15
|
-
import { TextInputBase
|
|
15
|
+
import { TextInputBase } from '../TextInput';
|
|
16
16
|
import { tasty } from '../../../tasty';
|
|
17
17
|
import { castNullableNumberValue, } from '../../../utils/react/nullableValue';
|
|
18
18
|
import { StepButton } from './StepButton';
|
|
@@ -30,23 +30,29 @@ const StepperContainer = tasty({
|
|
|
30
30
|
placeSelf: 'stretch',
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* NumberFields allow users to enter a number, and increment or decrement the value using stepper buttons.
|
|
35
|
+
*/
|
|
36
|
+
export const NumberInput = forwardRef(function NumberInput(props, ref) {
|
|
34
37
|
props = castNullableNumberValue(props);
|
|
35
38
|
props = useProviderProps(props);
|
|
36
|
-
props =
|
|
39
|
+
props = useFieldProps(props);
|
|
37
40
|
let { hideStepper, suffix, value, defaultValue, onChange, ...otherProps } = props;
|
|
38
41
|
let showStepper = !hideStepper;
|
|
39
42
|
let { locale } = useLocale();
|
|
40
43
|
let state = useNumberFieldState({ ...props, locale });
|
|
41
44
|
let inputRef = useRef(null);
|
|
42
45
|
let { groupProps, labelProps, inputProps, incrementButtonProps, decrementButtonProps, } = useNumberField(props, state, inputRef);
|
|
43
|
-
return (_jsx(StyledTextInputBase, { ...otherProps, ref: ref, labelProps: labelProps, inputProps: inputProps, inputRef: inputRef, wrapperProps: groupProps, suffixPosition: "after", suffix: showStepper ? (_jsxs(StepperContainer, { children: [_jsx(StepButton, { isDisabled: props.isDisabled, direction: "up", ...incrementButtonProps, size: otherProps.size }
|
|
44
|
-
}
|
|
46
|
+
return (_jsx(StyledTextInputBase, { ...otherProps, ref: ref, labelProps: labelProps, inputProps: inputProps, inputRef: inputRef, wrapperProps: groupProps, suffixPosition: "after", suffix: showStepper ? (_jsxs(StepperContainer, { children: [_jsx(StepButton, { isDisabled: props.isDisabled, direction: "up", ...incrementButtonProps, size: otherProps.size }), _jsx(StepButton, { isDisabled: props.isDisabled, direction: "down", ...decrementButtonProps, size: otherProps.size })] })) : (suffix) }));
|
|
47
|
+
});
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* @legacy should be removed with legacy <Field />
|
|
47
50
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
Object.defineProperty(NumberInput, 'cubeInputType', {
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: false,
|
|
54
|
+
writable: false,
|
|
55
|
+
value: 'Number',
|
|
56
|
+
});
|
|
51
57
|
|
|
52
58
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -32,10 +32,10 @@ const STEP_BUTTON_STYLES = {
|
|
|
32
32
|
* Buttons for NumberField.
|
|
33
33
|
*/
|
|
34
34
|
export function StepButton(props) {
|
|
35
|
-
return (_jsx(Button, { preventDefault: true, type: "neutral", styles: STEP_BUTTON_STYLES, icon: props.direction === 'up' ? (_jsx(CaretUpOutlined, { style: { fontSize: 'var(--icon-size)' } }
|
|
35
|
+
return (_jsx(Button, { preventDefault: true, type: "neutral", styles: STEP_BUTTON_STYLES, icon: props.direction === 'up' ? (_jsx(CaretUpOutlined, { style: { fontSize: 'var(--icon-size)' } })) : (_jsx(CaretDownOutlined, { style: { fontSize: 'var(--icon-size)' } })), mods: {
|
|
36
36
|
up: props.direction === 'up',
|
|
37
37
|
down: props.direction === 'down',
|
|
38
|
-
}, label: `Step ${props.direction}`, ...props }
|
|
38
|
+
}, label: `Step ${props.direction}`, ...props }));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -9,13 +9,22 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
9
9
|
import { forwardRef, useCallback, useRef, useState } from 'react';
|
|
10
10
|
import { useTextField } from '@react-aria/textfield';
|
|
11
11
|
import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons';
|
|
12
|
-
import { TextInputBase
|
|
12
|
+
import { TextInputBase } from '../TextInput';
|
|
13
13
|
import { useProviderProps } from '../../../provider';
|
|
14
14
|
import { Button } from '../../actions';
|
|
15
15
|
import { castNullableStringValue, } from '../../../utils/react/nullableValue';
|
|
16
|
+
import { useFieldProps } from '../Form';
|
|
16
17
|
function PasswordInput(props, ref) {
|
|
17
18
|
props = castNullableStringValue(props);
|
|
18
|
-
|
|
19
|
+
props = useProviderProps(props);
|
|
20
|
+
props = useFieldProps(props, {
|
|
21
|
+
defaultValidationTrigger: 'onBlur',
|
|
22
|
+
valuePropsMapper: ({ value, onChange }) => ({
|
|
23
|
+
value: value?.toString() ?? '',
|
|
24
|
+
onChange,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
const { suffix, multiLine, ...otherProps } = props;
|
|
19
28
|
let [type, setType] = useState('password');
|
|
20
29
|
let inputRef = useRef(null);
|
|
21
30
|
let { labelProps, inputProps } = useTextField({
|
|
@@ -25,8 +34,8 @@ function PasswordInput(props, ref) {
|
|
|
25
34
|
const toggleType = useCallback((e) => {
|
|
26
35
|
setType((type) => (type === 'password' ? 'text' : 'password'));
|
|
27
36
|
}, []);
|
|
28
|
-
const wrappedSuffix = (_jsxs(_Fragment, { children: [suffix, _jsx(Button, { excludeFromTabOrder: true, type: "neutral", htmlType: "button", placeSelf: "stretch", height: "auto", radius: "right", width: "4x", label: "Toggle masking", icon: type === 'password' ? _jsx(EyeInvisibleOutlined, {}
|
|
29
|
-
return (_jsx(TextInputBase, { ref: ref, labelProps: labelProps, inputProps: inputProps, inputRef: inputRef, inputStyles: { paddingRight: '4x' }, type: type, suffixPosition: "after", suffix: wrappedSuffix, multiLine: multiLine, ...otherProps }
|
|
37
|
+
const wrappedSuffix = (_jsxs(_Fragment, { children: [suffix, _jsx(Button, { excludeFromTabOrder: true, type: "neutral", htmlType: "button", placeSelf: "stretch", height: "auto", radius: "right", width: "4x", label: "Toggle masking", icon: type === 'password' ? _jsx(EyeInvisibleOutlined, {}) : _jsx(EyeOutlined, {}), onPress: toggleType })] }));
|
|
38
|
+
return (_jsx(TextInputBase, { ref: ref, labelProps: labelProps, inputProps: inputProps, inputRef: inputRef, inputStyles: { paddingRight: '4x' }, type: type, suffixPosition: "after", suffix: wrappedSuffix, multiLine: multiLine, ...otherProps }));
|
|
30
39
|
}
|
|
31
40
|
/**
|
|
32
41
|
* PasswordInputs are password inputs that allow users to input passwords or code entries
|
|
@@ -34,7 +43,15 @@ function PasswordInput(props, ref) {
|
|
|
34
43
|
* communicate the entry requirements.
|
|
35
44
|
*/
|
|
36
45
|
const _PasswordInput = forwardRef(PasswordInput);
|
|
37
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @legacy should be removed with legacy <Field />
|
|
48
|
+
*/
|
|
49
|
+
Object.defineProperty(_PasswordInput, 'cubeInputType', {
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: false,
|
|
52
|
+
writable: false,
|
|
53
|
+
value: 'Text',
|
|
54
|
+
});
|
|
38
55
|
export { _PasswordInput as PasswordInput };
|
|
39
56
|
|
|
40
57
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
* author: Cube Dev Team
|
|
4
|
-
* @cube-dev/ui-kit v0.0.0-canary-
|
|
4
|
+
* @cube-dev/ui-kit v0.0.0-canary-2a1d026
|
|
5
5
|
* Released under the MIT license.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ import { mergeProps } from '../../../utils/react';
|
|
|
16
16
|
import { useProviderProps } from '../../../provider';
|
|
17
17
|
import { INLINE_LABEL_STYLES } from '../Label';
|
|
18
18
|
import { HiddenInput } from '../../HiddenInput';
|
|
19
|
-
import {
|
|
19
|
+
import { useFieldProps } from '../Form';
|
|
20
20
|
import { RadioGroup } from './RadioGroup';
|
|
21
21
|
import { useRadioProvider } from './context';
|
|
22
22
|
const RadioWrapperElement = tasty({
|
|
@@ -107,17 +107,17 @@ const RadioNormalElement = tasty({
|
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
});
|
|
110
|
-
const RadioCircleElement = _jsx("div", { "data-element": "RadioCircle" }
|
|
110
|
+
const RadioCircleElement = _jsx("div", { "data-element": "RadioCircle" });
|
|
111
111
|
const RadioLabelElement = tasty({
|
|
112
112
|
qa: 'RadioLabel',
|
|
113
113
|
styles: INLINE_LABEL_STYLES,
|
|
114
114
|
});
|
|
115
115
|
function Radio(props, ref) {
|
|
116
116
|
props = useProviderProps(props);
|
|
117
|
-
props =
|
|
117
|
+
props = useFieldProps(props, { defaultValidationTrigger: 'onChange' });
|
|
118
118
|
let { qa, isDisabled, validationState, children, label, autoFocus, labelStyles, labelProps, inputStyles, type = 'radio', 'aria-label': ariaLabel, ...otherProps } = props;
|
|
119
119
|
let isButton = type === 'button';
|
|
120
|
-
label = label
|
|
120
|
+
label = label ?? children;
|
|
121
121
|
let styles = extractStyles(otherProps, OUTER_STYLES);
|
|
122
122
|
const RadioElement = isButton ? RadioButtonElement : RadioNormalElement;
|
|
123
123
|
labelStyles = {
|
|
@@ -141,22 +141,22 @@ function Radio(props, ref) {
|
|
|
141
141
|
invalid: validationState === 'invalid',
|
|
142
142
|
hovered: isHovered,
|
|
143
143
|
button: isButton,
|
|
144
|
-
}, "data-type": type, children: [_jsx(HiddenInput, { "data-qa": qa || 'Radio', "aria-label": ariaLabel, ...mergeProps(inputProps, focusProps), ref: inputRef, isButton: isButton }
|
|
144
|
+
}, "data-type": type, children: [_jsx(HiddenInput, { "data-qa": qa || 'Radio', "aria-label": ariaLabel, ...mergeProps(inputProps, focusProps), ref: inputRef, isButton: isButton }), _jsx(RadioElement, { mods: {
|
|
145
145
|
checked: inputProps.checked,
|
|
146
146
|
invalid: validationState === 'invalid',
|
|
147
147
|
valid: validationState === 'valid',
|
|
148
148
|
disabled: isDisabled,
|
|
149
149
|
hovered: isHovered,
|
|
150
150
|
focused: isFocused,
|
|
151
|
-
}, "data-type": type, styles: inputStyles, children: !isButton ? RadioCircleElement : children }
|
|
151
|
+
}, "data-type": type, styles: inputStyles, children: !isButton ? RadioCircleElement : children }), label && !isButton && (_jsx(RadioLabelElement, { mods: {
|
|
152
152
|
invalid: validationState === 'invalid',
|
|
153
153
|
valid: validationState === 'valid',
|
|
154
154
|
disabled: isDisabled,
|
|
155
|
-
}, ...filterBaseProps(labelProps), children: label }
|
|
155
|
+
}, ...filterBaseProps(labelProps), children: label }))] }));
|
|
156
156
|
}
|
|
157
157
|
function RadioButton(props, ref) {
|
|
158
158
|
const Radio = _Radio;
|
|
159
|
-
return _jsx(Radio, { ...props, ref: ref, type: "button" }
|
|
159
|
+
return _jsx(Radio, { ...props, ref: ref, type: "button" });
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Radio buttons allow users to select a single option from a list of mutually exclusive options.
|
|
@@ -172,6 +172,15 @@ const __Radio = Object.assign(_Radio, {
|
|
|
172
172
|
Group: RadioGroup,
|
|
173
173
|
Button: _RadioButton,
|
|
174
174
|
});
|
|
175
|
+
/**
|
|
176
|
+
* @legacy should be removed with legacy <Field />
|
|
177
|
+
*/
|
|
178
|
+
Object.defineProperty(_Radio, 'cubeInputType', {
|
|
179
|
+
enumerable: false,
|
|
180
|
+
configurable: false,
|
|
181
|
+
writable: false,
|
|
182
|
+
value: 'Radio',
|
|
183
|
+
});
|
|
175
184
|
export { __Radio as Radio };
|
|
176
185
|
export { _RadioButton as RadioButton };
|
|
177
186
|
|