powell-react 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.storybook/main.ts +28 -0
- package/.storybook/preview.scss +13 -0
- package/.storybook/preview.tsx +24 -0
- package/README.md +0 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/types/src/components/Button/Button.d.ts +6 -0
- package/dist/cjs/types/src/components/Button/index.d.ts +1 -0
- package/dist/cjs/types/src/components/index.d.ts +1 -0
- package/dist/cjs/types/src/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/api/PowellProvider.d.ts +5 -0
- package/dist/cjs/types/src/powell/api/configService.d.ts +2 -0
- package/dist/cjs/types/src/powell/api/forms.d.ts +73 -0
- package/dist/cjs/types/src/powell/api/index.d.ts +5 -0
- package/dist/cjs/types/src/powell/api/powellDefaults.d.ts +2 -0
- package/dist/cjs/types/src/powell/api/primereact.d.ts +968 -0
- package/dist/cjs/types/src/powell/components/AutoComplete/AutoComplete.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/AutoComplete/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Button/Button.d.ts +22 -0
- package/dist/cjs/types/src/powell/components/Button/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/CascadeSelect/CascadeSelect.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/CascadeSelect/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Checkbox/Checkbox.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/Checkbox/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Chips/Chips.d.ts +23 -0
- package/dist/cjs/types/src/powell/components/Chips/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/ColorPicker/ColorPicker.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/ColorPicker/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Dropdown/Dropdown.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/Dropdown/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Editor/Editor.d.ts +23 -0
- package/dist/cjs/types/src/powell/components/Editor/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/FormContainer/FormContainer.d.ts +7 -0
- package/dist/cjs/types/src/powell/components/FormContainer/FormContext.d.ts +4 -0
- package/dist/cjs/types/src/powell/components/FormContainer/index.d.ts +2 -0
- package/dist/cjs/types/src/powell/components/InputMask/InputMask.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/InputMask/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputNumber/InputNumber.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/InputNumber/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputOtp/InputOtp.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/InputOtp/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputPassword/InputPassword.d.ts +23 -0
- package/dist/cjs/types/src/powell/components/InputPassword/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputSwitch/InputSwitch.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/InputSwitch/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputText/InputText.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/InputText/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/InputTextarea/InputTextarea.d.ts +23 -0
- package/dist/cjs/types/src/powell/components/InputTextarea/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Knob/Knob.d.ts +20 -0
- package/dist/cjs/types/src/powell/components/Knob/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/ListBox/ListBox.d.ts +20 -0
- package/dist/cjs/types/src/powell/components/ListBox/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Mention/Mention.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/Mention/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/MultiSelect/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/MultiStateCheckbox/MultiStateCheckbox.d.ts +20 -0
- package/dist/cjs/types/src/powell/components/MultiStateCheckbox/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/RadioGroup/RadioGroup.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/RadioGroup/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Rating/Rating.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/Rating/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/SelectButton/SelectButton.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/SelectButton/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/Slider/Slider.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/Slider/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/ToggleButton/ToggleButton.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/ToggleButton/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/TreeSelect/TreeSelect.d.ts +24 -0
- package/dist/cjs/types/src/powell/components/TreeSelect/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/components/TriStateCheckbox/TriStateCheckbox.d.ts +21 -0
- package/dist/cjs/types/src/powell/components/TriStateCheckbox/index.d.ts +1 -0
- package/dist/cjs/types/src/powell/hooks/index.d.ts +3 -0
- package/dist/cjs/types/src/powell/hooks/useApplyConfig.d.ts +17 -0
- package/dist/cjs/types/src/powell/hooks/useFormContext.d.ts +2 -0
- package/dist/cjs/types/src/powell/hooks/usePowellConfig.d.ts +2 -0
- package/dist/cjs/types/src/powell/index.d.ts +29 -0
- package/dist/cjs/types/src/powell/models/common.d.ts +7 -0
- package/dist/cjs/types/src/powell/models/config.d.ts +13 -0
- package/dist/cjs/types/src/powell/models/forms.d.ts +28 -0
- package/dist/cjs/types/src/powell/models/index.d.ts +3 -0
- package/dist/cjs/types/src/powell/utils/globalState.d.ts +19 -0
- package/dist/cjs/types/src/powell/utils/index.d.ts +2 -0
- package/dist/cjs/types/src/powell/utils/utilsService.d.ts +8 -0
- package/dist/cjs/types/vite.config.d.ts +2 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types/src/components/Button/Button.d.ts +6 -0
- package/dist/esm/types/src/components/Button/index.d.ts +1 -0
- package/dist/esm/types/src/components/index.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +1 -0
- package/dist/esm/types/src/powell/api/PowellProvider.d.ts +5 -0
- package/dist/esm/types/src/powell/api/configService.d.ts +2 -0
- package/dist/esm/types/src/powell/api/forms.d.ts +73 -0
- package/dist/esm/types/src/powell/api/index.d.ts +5 -0
- package/dist/esm/types/src/powell/api/powellDefaults.d.ts +2 -0
- package/dist/esm/types/src/powell/api/primereact.d.ts +968 -0
- package/dist/esm/types/src/powell/components/AutoComplete/AutoComplete.d.ts +24 -0
- package/dist/esm/types/src/powell/components/AutoComplete/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Button/Button.d.ts +22 -0
- package/dist/esm/types/src/powell/components/Button/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/CascadeSelect/CascadeSelect.d.ts +24 -0
- package/dist/esm/types/src/powell/components/CascadeSelect/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Checkbox/Checkbox.d.ts +21 -0
- package/dist/esm/types/src/powell/components/Checkbox/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Chips/Chips.d.ts +23 -0
- package/dist/esm/types/src/powell/components/Chips/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/ColorPicker/ColorPicker.d.ts +24 -0
- package/dist/esm/types/src/powell/components/ColorPicker/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Dropdown/Dropdown.d.ts +24 -0
- package/dist/esm/types/src/powell/components/Dropdown/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Editor/Editor.d.ts +23 -0
- package/dist/esm/types/src/powell/components/Editor/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/FormContainer/FormContainer.d.ts +7 -0
- package/dist/esm/types/src/powell/components/FormContainer/FormContext.d.ts +4 -0
- package/dist/esm/types/src/powell/components/FormContainer/index.d.ts +2 -0
- package/dist/esm/types/src/powell/components/InputMask/InputMask.d.ts +24 -0
- package/dist/esm/types/src/powell/components/InputMask/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputNumber/InputNumber.d.ts +24 -0
- package/dist/esm/types/src/powell/components/InputNumber/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputOtp/InputOtp.d.ts +21 -0
- package/dist/esm/types/src/powell/components/InputOtp/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputPassword/InputPassword.d.ts +23 -0
- package/dist/esm/types/src/powell/components/InputPassword/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputSwitch/InputSwitch.d.ts +21 -0
- package/dist/esm/types/src/powell/components/InputSwitch/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputText/InputText.d.ts +24 -0
- package/dist/esm/types/src/powell/components/InputText/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/InputTextarea/InputTextarea.d.ts +23 -0
- package/dist/esm/types/src/powell/components/InputTextarea/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Knob/Knob.d.ts +20 -0
- package/dist/esm/types/src/powell/components/Knob/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/ListBox/ListBox.d.ts +20 -0
- package/dist/esm/types/src/powell/components/ListBox/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Mention/Mention.d.ts +24 -0
- package/dist/esm/types/src/powell/components/Mention/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/MultiSelect/MultiSelect.d.ts +24 -0
- package/dist/esm/types/src/powell/components/MultiSelect/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/MultiStateCheckbox/MultiStateCheckbox.d.ts +20 -0
- package/dist/esm/types/src/powell/components/MultiStateCheckbox/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/RadioGroup/RadioGroup.d.ts +24 -0
- package/dist/esm/types/src/powell/components/RadioGroup/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Rating/Rating.d.ts +21 -0
- package/dist/esm/types/src/powell/components/Rating/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/SelectButton/SelectButton.d.ts +21 -0
- package/dist/esm/types/src/powell/components/SelectButton/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/Slider/Slider.d.ts +21 -0
- package/dist/esm/types/src/powell/components/Slider/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/ToggleButton/ToggleButton.d.ts +21 -0
- package/dist/esm/types/src/powell/components/ToggleButton/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/TreeSelect/TreeSelect.d.ts +24 -0
- package/dist/esm/types/src/powell/components/TreeSelect/index.d.ts +1 -0
- package/dist/esm/types/src/powell/components/TriStateCheckbox/TriStateCheckbox.d.ts +21 -0
- package/dist/esm/types/src/powell/components/TriStateCheckbox/index.d.ts +1 -0
- package/dist/esm/types/src/powell/hooks/index.d.ts +3 -0
- package/dist/esm/types/src/powell/hooks/useApplyConfig.d.ts +17 -0
- package/dist/esm/types/src/powell/hooks/useFormContext.d.ts +2 -0
- package/dist/esm/types/src/powell/hooks/usePowellConfig.d.ts +2 -0
- package/dist/esm/types/src/powell/index.d.ts +29 -0
- package/dist/esm/types/src/powell/models/common.d.ts +7 -0
- package/dist/esm/types/src/powell/models/config.d.ts +13 -0
- package/dist/esm/types/src/powell/models/forms.d.ts +28 -0
- package/dist/esm/types/src/powell/models/index.d.ts +3 -0
- package/dist/esm/types/src/powell/utils/globalState.d.ts +19 -0
- package/dist/esm/types/src/powell/utils/index.d.ts +2 -0
- package/dist/esm/types/src/powell/utils/utilsService.d.ts +8 -0
- package/dist/esm/types/vite.config.d.ts +2 -0
- package/package.json +70 -0
- package/rollup.config.mjs +95 -0
- package/src/components/Button/Button.scss +43 -0
- package/src/components/Button/Button.stories.tsx +13 -0
- package/src/components/Button/Button.tsx +19 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/powell/api/PowellProvider.tsx +37 -0
- package/src/powell/api/configService.ts +4 -0
- package/src/powell/api/forms.ts +145 -0
- package/src/powell/api/index.ts +5 -0
- package/src/powell/api/powellDefaults.ts +11 -0
- package/src/powell/api/primereact.ts +1945 -0
- package/src/powell/components/AutoComplete/AutoComplete.scss +126 -0
- package/src/powell/components/AutoComplete/AutoComplete.tsx +190 -0
- package/src/powell/components/AutoComplete/index.ts +1 -0
- package/src/powell/components/Button/Button.tsx +90 -0
- package/src/powell/components/Button/index.ts +1 -0
- package/src/powell/components/CascadeSelect/CascadeSelect.scss +126 -0
- package/src/powell/components/CascadeSelect/CascadeSelect.tsx +190 -0
- package/src/powell/components/CascadeSelect/index.ts +1 -0
- package/src/powell/components/Checkbox/Checkbox.scss +32 -0
- package/src/powell/components/Checkbox/Checkbox.tsx +147 -0
- package/src/powell/components/Checkbox/index.ts +1 -0
- package/src/powell/components/Chips/Chips.scss +126 -0
- package/src/powell/components/Chips/Chips.tsx +190 -0
- package/src/powell/components/Chips/index.ts +1 -0
- package/src/powell/components/ColorPicker/ColorPicker.scss +126 -0
- package/src/powell/components/ColorPicker/ColorPicker.tsx +186 -0
- package/src/powell/components/ColorPicker/index.ts +1 -0
- package/src/powell/components/Dropdown/Dropdown.scss +126 -0
- package/src/powell/components/Dropdown/Dropdown.tsx +190 -0
- package/src/powell/components/Dropdown/index.ts +1 -0
- package/src/powell/components/Editor/Editor.scss +126 -0
- package/src/powell/components/Editor/Editor.tsx +183 -0
- package/src/powell/components/Editor/index.ts +1 -0
- package/src/powell/components/FormContainer/FormContainer.tsx +49 -0
- package/src/powell/components/FormContainer/FormContext.tsx +18 -0
- package/src/powell/components/FormContainer/index.ts +2 -0
- package/src/powell/components/InputMask/InputMask.scss +126 -0
- package/src/powell/components/InputMask/InputMask.tsx +190 -0
- package/src/powell/components/InputMask/index.ts +1 -0
- package/src/powell/components/InputNumber/InputNumber.scss +126 -0
- package/src/powell/components/InputNumber/InputNumber.tsx +190 -0
- package/src/powell/components/InputNumber/index.ts +1 -0
- package/src/powell/components/InputOtp/InputOtp.scss +126 -0
- package/src/powell/components/InputOtp/InputOtp.tsx +154 -0
- package/src/powell/components/InputOtp/index.ts +1 -0
- package/src/powell/components/InputPassword/InputPassword.scss +126 -0
- package/src/powell/components/InputPassword/InputPassword.tsx +189 -0
- package/src/powell/components/InputPassword/index.ts +1 -0
- package/src/powell/components/InputSwitch/InputSwitch.scss +32 -0
- package/src/powell/components/InputSwitch/InputSwitch.tsx +144 -0
- package/src/powell/components/InputSwitch/index.ts +1 -0
- package/src/powell/components/InputText/InputText.scss +126 -0
- package/src/powell/components/InputText/InputText.tsx +190 -0
- package/src/powell/components/InputText/index.ts +1 -0
- package/src/powell/components/InputTextarea/InputTextarea.scss +126 -0
- package/src/powell/components/InputTextarea/InputTextarea.tsx +187 -0
- package/src/powell/components/InputTextarea/index.ts +1 -0
- package/src/powell/components/Knob/Knob.scss +32 -0
- package/src/powell/components/Knob/Knob.tsx +134 -0
- package/src/powell/components/Knob/index.ts +1 -0
- package/src/powell/components/ListBox/ListBox.scss +32 -0
- package/src/powell/components/ListBox/ListBox.tsx +135 -0
- package/src/powell/components/ListBox/index.ts +1 -0
- package/src/powell/components/Mention/Mention.scss +126 -0
- package/src/powell/components/Mention/Mention.tsx +186 -0
- package/src/powell/components/Mention/index.ts +1 -0
- package/src/powell/components/MultiSelect/MultiSelect.scss +126 -0
- package/src/powell/components/MultiSelect/MultiSelect.tsx +190 -0
- package/src/powell/components/MultiSelect/index.ts +1 -0
- package/src/powell/components/MultiStateCheckbox/MultiStateCheckbox.scss +32 -0
- package/src/powell/components/MultiStateCheckbox/MultiStateCheckbox.tsx +143 -0
- package/src/powell/components/MultiStateCheckbox/index.ts +1 -0
- package/src/powell/components/RadioGroup/RadioGroup.scss +32 -0
- package/src/powell/components/RadioGroup/RadioGroup.tsx +167 -0
- package/src/powell/components/RadioGroup/index.ts +1 -0
- package/src/powell/components/Rating/Rating.scss +32 -0
- package/src/powell/components/Rating/Rating.tsx +135 -0
- package/src/powell/components/Rating/index.ts +1 -0
- package/src/powell/components/SelectButton/SelectButton.scss +32 -0
- package/src/powell/components/SelectButton/SelectButton.tsx +144 -0
- package/src/powell/components/SelectButton/index.ts +1 -0
- package/src/powell/components/Slider/Slider.scss +32 -0
- package/src/powell/components/Slider/Slider.tsx +135 -0
- package/src/powell/components/Slider/index.ts +1 -0
- package/src/powell/components/ToggleButton/ToggleButton.scss +32 -0
- package/src/powell/components/ToggleButton/ToggleButton.tsx +144 -0
- package/src/powell/components/ToggleButton/index.ts +1 -0
- package/src/powell/components/TreeSelect/TreeSelect.scss +126 -0
- package/src/powell/components/TreeSelect/TreeSelect.tsx +190 -0
- package/src/powell/components/TreeSelect/index.ts +1 -0
- package/src/powell/components/TriStateCheckbox/TriStateCheckbox.scss +32 -0
- package/src/powell/components/TriStateCheckbox/TriStateCheckbox.tsx +144 -0
- package/src/powell/components/TriStateCheckbox/index.ts +1 -0
- package/src/powell/hooks/index.ts +3 -0
- package/src/powell/hooks/useApplyConfig.ts +36 -0
- package/src/powell/hooks/useFormContext.ts +14 -0
- package/src/powell/hooks/usePowellConfig.ts +64 -0
- package/src/powell/index.ts +29 -0
- package/src/powell/models/common.ts +7 -0
- package/src/powell/models/config.ts +85 -0
- package/src/powell/models/forms.ts +33 -0
- package/src/powell/models/index.ts +3 -0
- package/src/powell/styles/common.scss +9 -0
- package/src/powell/styles/mixins.scss +0 -0
- package/src/powell/themes/arya-blue.css +1 -0
- package/src/powell/themes/arya-green.css +1 -0
- package/src/powell/themes/arya-orange.css +1 -0
- package/src/powell/themes/arya-purple.css +1 -0
- package/src/powell/themes/bootstrap4-dark-blue.css +1 -0
- package/src/powell/themes/bootstrap4-dark-purple.css +1 -0
- package/src/powell/themes/bootstrap4-light-blue.css +1 -0
- package/src/powell/themes/bootstrap4-light-purple.css +1 -0
- package/src/powell/themes/fluent-light.css +1 -0
- package/src/powell/themes/lara-dark-amber.css +1 -0
- package/src/powell/themes/lara-dark-blue.css +1 -0
- package/src/powell/themes/lara-dark-cyan.css +1 -0
- package/src/powell/themes/lara-dark-green.css +1 -0
- package/src/powell/themes/lara-dark-indigo.css +1 -0
- package/src/powell/themes/lara-dark-pink.css +1 -0
- package/src/powell/themes/lara-dark-purple.css +1 -0
- package/src/powell/themes/lara-dark-teal.css +1 -0
- package/src/powell/themes/lara-light-amber.css +1 -0
- package/src/powell/themes/lara-light-blue.css +1 -0
- package/src/powell/themes/lara-light-cyan.css +1 -0
- package/src/powell/themes/lara-light-green.css +1 -0
- package/src/powell/themes/lara-light-indigo.css +1 -0
- package/src/powell/themes/lara-light-pink.css +1 -0
- package/src/powell/themes/lara-light-purple.css +1 -0
- package/src/powell/themes/lara-light-teal.css +1 -0
- package/src/powell/themes/luna-amber.css +1 -0
- package/src/powell/themes/luna-blue.css +1 -0
- package/src/powell/themes/luna-green.css +1 -0
- package/src/powell/themes/luna-pink.css +1 -0
- package/src/powell/themes/md-dark-deeppurple.css +1 -0
- package/src/powell/themes/md-dark-indigo.css +1 -0
- package/src/powell/themes/md-light-deeppurple.css +1 -0
- package/src/powell/themes/md-light-indigo.css +1 -0
- package/src/powell/themes/mdc-dark-deeppurple.css +1 -0
- package/src/powell/themes/mdc-dark-indigo.css +1 -0
- package/src/powell/themes/mdc-light-deeppurple.css +1 -0
- package/src/powell/themes/mdc-light-indigo.css +1 -0
- package/src/powell/themes/mira.css +1 -0
- package/src/powell/themes/nano.css +1 -0
- package/src/powell/themes/nova-accent.css +1 -0
- package/src/powell/themes/nova-alt.css +1 -0
- package/src/powell/themes/nova.css +1 -0
- package/src/powell/themes/rhea.css +1 -0
- package/src/powell/themes/saga-blue.css +1 -0
- package/src/powell/themes/saga-green.css +1 -0
- package/src/powell/themes/saga-orange.css +1 -0
- package/src/powell/themes/saga-purple.css +1 -0
- package/src/powell/themes/soho-dark.css +1 -0
- package/src/powell/themes/soho-light.css +1 -0
- package/src/powell/themes/tailwind-light.css +1 -0
- package/src/powell/themes/vela-blue.css +1 -0
- package/src/powell/themes/vela-green.css +1 -0
- package/src/powell/themes/vela-orange.css +1 -0
- package/src/powell/themes/vela-purple.css +1 -0
- package/src/powell/themes/viva-dark.css +1 -0
- package/src/powell/themes/viva-light.css +1 -0
- package/src/powell/utils/globalState.ts +96 -0
- package/src/powell/utils/index.ts +2 -0
- package/src/powell/utils/utilsService.tsx +55 -0
- package/src/stories/Button.stories.tsx +16 -0
- package/tsconfig.json +55 -0
- package/vite.config.ts +14 -0
@@ -0,0 +1,135 @@
|
|
1
|
+
import {ChangeEvent, ReactNode, useCallback, useRef, useState} from "react";
|
2
|
+
import {FixLabelPosition} from "@powell/models";
|
3
|
+
import {$classNames, $ErrorMessage, $Field, $FieldProps, $Rating, $RatingProps, $UniqueComponentId} from "@powell/api";
|
4
|
+
import {isRequiredField, transformer} from "@powell/utils";
|
5
|
+
import {useApplyConfig, useFormContext} from "@powell/hooks";
|
6
|
+
import {SafeAny} from "@powell/models";
|
7
|
+
import '@components/Rating/Rating.scss';
|
8
|
+
|
9
|
+
interface RatingProps extends Omit<$RatingProps, 'checked'> {
|
10
|
+
checked?: boolean;
|
11
|
+
name?: string;
|
12
|
+
parseError?: (error: string) => ReactNode;
|
13
|
+
transform?: {
|
14
|
+
input?: (value: SafeAny) => string;
|
15
|
+
output?: (event: ChangeEvent<HTMLInputElement>) => SafeAny;
|
16
|
+
};
|
17
|
+
showRequiredStar?: boolean;
|
18
|
+
rtl?: boolean;
|
19
|
+
label?: string;
|
20
|
+
hint?: string;
|
21
|
+
labelPosition?: FixLabelPosition;
|
22
|
+
}
|
23
|
+
|
24
|
+
export const Rating = (props: RatingProps) => {
|
25
|
+
props = useApplyConfig(props, {sizable: false, isFixLabel: true});
|
26
|
+
const {
|
27
|
+
parseError,
|
28
|
+
name,
|
29
|
+
transform = {},
|
30
|
+
labelPosition,
|
31
|
+
rtl,
|
32
|
+
showRequiredStar,
|
33
|
+
...rest
|
34
|
+
} = props;
|
35
|
+
|
36
|
+
const inputId = useRef($UniqueComponentId());
|
37
|
+
|
38
|
+
// Check if we're in Formik context
|
39
|
+
const formContext = useFormContext();
|
40
|
+
const withinForm = !!formContext && !!name;
|
41
|
+
const isRequired = withinForm && isRequiredField(formContext, name);
|
42
|
+
|
43
|
+
// Internal state for non-Formik usage
|
44
|
+
const [internalValue, setInternalValue] = useState(rest.checked);
|
45
|
+
|
46
|
+
const rootEl = useCallback(() => {
|
47
|
+
const commonProps = {
|
48
|
+
...rest,
|
49
|
+
inputId: inputId.current,
|
50
|
+
name,
|
51
|
+
};
|
52
|
+
|
53
|
+
if (withinForm) {
|
54
|
+
// if in Formik context
|
55
|
+
return (
|
56
|
+
<$Field name={name}>
|
57
|
+
{({field}: $FieldProps) => {
|
58
|
+
const {value, onChange} = transformer({
|
59
|
+
value: field.value,
|
60
|
+
onChange: (event: boolean) => formContext.setFieldValue(name, event),
|
61
|
+
transform: {
|
62
|
+
input: transform.input ?? (value => value),
|
63
|
+
output: transform.output ?? (event => event.value)
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
return (
|
68
|
+
<>
|
69
|
+
<$Rating
|
70
|
+
{...commonProps}
|
71
|
+
value={value}
|
72
|
+
onChange={(event) => {
|
73
|
+
onChange(event);
|
74
|
+
rest.onChange?.(event);
|
75
|
+
}}
|
76
|
+
/>
|
77
|
+
<$ErrorMessage name={name}>
|
78
|
+
{
|
79
|
+
(message) => <small className="error">{parseError?.(message) ?? message}</small>
|
80
|
+
}
|
81
|
+
</$ErrorMessage>
|
82
|
+
<small className="hint">{rest.hint}</small>
|
83
|
+
</>
|
84
|
+
);
|
85
|
+
}}
|
86
|
+
</$Field>
|
87
|
+
);
|
88
|
+
} else {
|
89
|
+
// if outside Formik context
|
90
|
+
const {value, onChange} = transformer({
|
91
|
+
value: internalValue,
|
92
|
+
onChange: (event: boolean) => setInternalValue(event),
|
93
|
+
transform: {
|
94
|
+
input: transform.input ?? (value => value),
|
95
|
+
output: transform.output ?? (event => event.value)
|
96
|
+
}
|
97
|
+
});
|
98
|
+
|
99
|
+
return (
|
100
|
+
<$Rating
|
101
|
+
{...commonProps}
|
102
|
+
checked={value}
|
103
|
+
onChange={(event) => {
|
104
|
+
onChange(event);
|
105
|
+
rest.onChange?.(event);
|
106
|
+
}}
|
107
|
+
onBlur={rest.onBlur}
|
108
|
+
/>
|
109
|
+
);
|
110
|
+
}
|
111
|
+
}, [internalValue, props]);
|
112
|
+
|
113
|
+
const labelEl = rest.label && (
|
114
|
+
<label htmlFor={inputId.current}>
|
115
|
+
{rest.label}
|
116
|
+
{isRequired && showRequiredStar ? '*' : ''}
|
117
|
+
</label>
|
118
|
+
);
|
119
|
+
|
120
|
+
return (
|
121
|
+
<div className={$classNames('checkbox-wrapper',
|
122
|
+
{
|
123
|
+
[`label-${labelPosition}`]: rest.label,
|
124
|
+
'is-rtl': rtl,
|
125
|
+
'is-ltr': !rtl,
|
126
|
+
})}>
|
127
|
+
<div className="field">
|
128
|
+
{labelEl}
|
129
|
+
<div className={$classNames('field-inner')}>
|
130
|
+
{rootEl()}
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
);
|
135
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./Rating";
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.knob-wrapper {
|
2
|
+
.field {
|
3
|
+
display: flex;
|
4
|
+
gap: 0.25rem 1rem;
|
5
|
+
|
6
|
+
> .field-inner {
|
7
|
+
flex-grow: 1;
|
8
|
+
display: flex;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
&.label-fix-side .field {
|
13
|
+
flex-direction: row;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
&.label-fix-top .field {
|
18
|
+
flex-direction: column;
|
19
|
+
|
20
|
+
label {
|
21
|
+
margin-bottom: 0.25rem;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&.is-ltr {
|
26
|
+
direction: ltr;
|
27
|
+
}
|
28
|
+
|
29
|
+
&.is-rtl {
|
30
|
+
direction: rtl;
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
import {ChangeEvent, ReactNode, useCallback, useRef, useState} from "react";
|
2
|
+
import {FixLabelPosition} from "@powell/models";
|
3
|
+
import {
|
4
|
+
$classNames,
|
5
|
+
$ErrorMessage,
|
6
|
+
$Field,
|
7
|
+
$FieldProps,
|
8
|
+
$SelectButton,
|
9
|
+
$SelectButtonProps,
|
10
|
+
$UniqueComponentId
|
11
|
+
} from "@powell/api";
|
12
|
+
import {isRequiredField, transformer} from "@powell/utils";
|
13
|
+
import {useApplyConfig, useFormContext} from "@powell/hooks";
|
14
|
+
import {SafeAny} from "@powell/models";
|
15
|
+
import '@components/SelectButton/SelectButton.scss';
|
16
|
+
|
17
|
+
interface SelectButtonProps extends Omit<$SelectButtonProps, 'checked'> {
|
18
|
+
checked?: boolean;
|
19
|
+
name?: string;
|
20
|
+
parseError?: (error: string) => ReactNode;
|
21
|
+
transform?: {
|
22
|
+
input?: (value: SafeAny) => string;
|
23
|
+
output?: (event: ChangeEvent<HTMLInputElement>) => SafeAny;
|
24
|
+
};
|
25
|
+
showRequiredStar?: boolean;
|
26
|
+
rtl?: boolean;
|
27
|
+
label?: string;
|
28
|
+
hint?: string;
|
29
|
+
labelPosition?: FixLabelPosition;
|
30
|
+
}
|
31
|
+
|
32
|
+
export const SelectButton = (props: SelectButtonProps) => {
|
33
|
+
props = useApplyConfig(props, {sizable: false, isFixLabel: true});
|
34
|
+
const {
|
35
|
+
parseError,
|
36
|
+
name,
|
37
|
+
transform = {},
|
38
|
+
labelPosition,
|
39
|
+
rtl,
|
40
|
+
showRequiredStar,
|
41
|
+
...rest
|
42
|
+
} = props;
|
43
|
+
|
44
|
+
const inputId = useRef($UniqueComponentId());
|
45
|
+
|
46
|
+
// Check if we're in Formik context
|
47
|
+
const formContext = useFormContext();
|
48
|
+
const withinForm = !!formContext && !!name;
|
49
|
+
const isRequired = withinForm && isRequiredField(formContext, name);
|
50
|
+
|
51
|
+
// Internal state for non-Formik usage
|
52
|
+
const [internalValue, setInternalValue] = useState(rest.checked);
|
53
|
+
|
54
|
+
const rootEl = useCallback(() => {
|
55
|
+
const commonProps = {
|
56
|
+
...rest,
|
57
|
+
inputId: inputId.current,
|
58
|
+
name,
|
59
|
+
};
|
60
|
+
|
61
|
+
if (withinForm) {
|
62
|
+
// if in Formik context
|
63
|
+
return (
|
64
|
+
<$Field name={name}>
|
65
|
+
{({field, meta}: $FieldProps) => {
|
66
|
+
const {value, onChange} = transformer({
|
67
|
+
value: field.value,
|
68
|
+
onChange: (event: boolean) => formContext.setFieldValue(name, event),
|
69
|
+
transform: {
|
70
|
+
input: transform.input ?? (value => value),
|
71
|
+
output: transform.output ?? (event => event.value)
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
return (
|
76
|
+
<>
|
77
|
+
<$SelectButton
|
78
|
+
{...commonProps}
|
79
|
+
value={value}
|
80
|
+
onChange={(event) => {
|
81
|
+
onChange(event);
|
82
|
+
rest.onChange?.(event);
|
83
|
+
}}
|
84
|
+
invalid={!!meta.error}
|
85
|
+
/>
|
86
|
+
<$ErrorMessage name={name}>
|
87
|
+
{
|
88
|
+
(message) => <small className="error">{parseError?.(message) ?? message}</small>
|
89
|
+
}
|
90
|
+
</$ErrorMessage>
|
91
|
+
<small className="hint">{rest.hint}</small>
|
92
|
+
</>
|
93
|
+
);
|
94
|
+
}}
|
95
|
+
</$Field>
|
96
|
+
);
|
97
|
+
} else {
|
98
|
+
// if outside Formik context
|
99
|
+
const {value, onChange} = transformer({
|
100
|
+
value: internalValue,
|
101
|
+
onChange: (event: boolean) => setInternalValue(event),
|
102
|
+
transform: {
|
103
|
+
input: transform.input ?? (value => value),
|
104
|
+
output: transform.output ?? (event => event.value)
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
return (
|
109
|
+
<$SelectButton
|
110
|
+
{...commonProps}
|
111
|
+
checked={value}
|
112
|
+
onChange={(event) => {
|
113
|
+
onChange(event);
|
114
|
+
rest.onChange?.(event);
|
115
|
+
}}
|
116
|
+
onBlur={rest.onBlur}
|
117
|
+
/>
|
118
|
+
);
|
119
|
+
}
|
120
|
+
}, [internalValue, props]);
|
121
|
+
|
122
|
+
const labelEl = rest.label && (
|
123
|
+
<label htmlFor={inputId.current}>
|
124
|
+
{rest.label}
|
125
|
+
{isRequired && showRequiredStar ? '*' : ''}
|
126
|
+
</label>
|
127
|
+
);
|
128
|
+
|
129
|
+
return (
|
130
|
+
<div className={$classNames('checkbox-wrapper',
|
131
|
+
{
|
132
|
+
[`label-${labelPosition}`]: rest.label,
|
133
|
+
'is-rtl': rtl,
|
134
|
+
'is-ltr': !rtl,
|
135
|
+
})}>
|
136
|
+
<div className="field">
|
137
|
+
{labelEl}
|
138
|
+
<div className={$classNames('field-inner')}>
|
139
|
+
{rootEl()}
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
);
|
144
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./SelectButton";
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.knob-wrapper {
|
2
|
+
.field {
|
3
|
+
display: flex;
|
4
|
+
gap: 0.25rem 1rem;
|
5
|
+
|
6
|
+
> .field-inner {
|
7
|
+
flex-grow: 1;
|
8
|
+
display: flex;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
&.label-fix-side .field {
|
13
|
+
flex-direction: row;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
&.label-fix-top .field {
|
18
|
+
flex-direction: column;
|
19
|
+
|
20
|
+
label {
|
21
|
+
margin-bottom: 0.25rem;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&.is-ltr {
|
26
|
+
direction: ltr;
|
27
|
+
}
|
28
|
+
|
29
|
+
&.is-rtl {
|
30
|
+
direction: rtl;
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,135 @@
|
|
1
|
+
import {ChangeEvent, ReactNode, useCallback, useRef, useState} from "react";
|
2
|
+
import {FixLabelPosition} from "@powell/models";
|
3
|
+
import {$classNames, $ErrorMessage, $Field, $FieldProps, $Slider, $SliderProps, $UniqueComponentId} from "@powell/api";
|
4
|
+
import {isRequiredField, transformer} from "@powell/utils";
|
5
|
+
import {useApplyConfig, useFormContext} from "@powell/hooks";
|
6
|
+
import {SafeAny} from "@powell/models";
|
7
|
+
import '@components/Slider/Slider.scss';
|
8
|
+
|
9
|
+
interface SliderProps extends Omit<$SliderProps, 'checked'> {
|
10
|
+
checked?: boolean;
|
11
|
+
name?: string;
|
12
|
+
parseError?: (error: string) => ReactNode;
|
13
|
+
transform?: {
|
14
|
+
input?: (value: SafeAny) => string;
|
15
|
+
output?: (event: ChangeEvent<HTMLInputElement>) => SafeAny;
|
16
|
+
};
|
17
|
+
showRequiredStar?: boolean;
|
18
|
+
rtl?: boolean;
|
19
|
+
label?: string;
|
20
|
+
hint?: string;
|
21
|
+
labelPosition?: FixLabelPosition;
|
22
|
+
}
|
23
|
+
|
24
|
+
export const Slider = (props: SliderProps) => {
|
25
|
+
props = useApplyConfig(props, {sizable: false, isFixLabel: true});
|
26
|
+
const {
|
27
|
+
parseError,
|
28
|
+
name,
|
29
|
+
transform = {},
|
30
|
+
labelPosition,
|
31
|
+
rtl,
|
32
|
+
showRequiredStar,
|
33
|
+
...rest
|
34
|
+
} = props;
|
35
|
+
|
36
|
+
const inputId = useRef($UniqueComponentId());
|
37
|
+
|
38
|
+
// Check if we're in Formik context
|
39
|
+
const formContext = useFormContext();
|
40
|
+
const withinForm = !!formContext && !!name;
|
41
|
+
const isRequired = withinForm && isRequiredField(formContext, name);
|
42
|
+
|
43
|
+
// Internal state for non-Formik usage
|
44
|
+
const [internalValue, setInternalValue] = useState(rest.checked);
|
45
|
+
|
46
|
+
const rootEl = useCallback(() => {
|
47
|
+
const commonProps = {
|
48
|
+
...rest,
|
49
|
+
inputId: inputId.current,
|
50
|
+
name,
|
51
|
+
};
|
52
|
+
|
53
|
+
if (withinForm) {
|
54
|
+
// if in Formik context
|
55
|
+
return (
|
56
|
+
<$Field name={name}>
|
57
|
+
{({field}: $FieldProps) => {
|
58
|
+
const {value, onChange} = transformer({
|
59
|
+
value: field.value,
|
60
|
+
onChange: (event: boolean) => formContext.setFieldValue(name, event),
|
61
|
+
transform: {
|
62
|
+
input: transform.input ?? (value => value),
|
63
|
+
output: transform.output ?? (event => event.value)
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
return (
|
68
|
+
<>
|
69
|
+
<$Slider
|
70
|
+
{...commonProps}
|
71
|
+
value={value}
|
72
|
+
onChange={(event) => {
|
73
|
+
onChange(event);
|
74
|
+
rest.onChange?.(event);
|
75
|
+
}}
|
76
|
+
/>
|
77
|
+
<$ErrorMessage name={name}>
|
78
|
+
{
|
79
|
+
(message) => <small className="error">{parseError?.(message) ?? message}</small>
|
80
|
+
}
|
81
|
+
</$ErrorMessage>
|
82
|
+
<small className="hint">{rest.hint}</small>
|
83
|
+
</>
|
84
|
+
);
|
85
|
+
}}
|
86
|
+
</$Field>
|
87
|
+
);
|
88
|
+
} else {
|
89
|
+
// if outside Formik context
|
90
|
+
const {value, onChange} = transformer({
|
91
|
+
value: internalValue,
|
92
|
+
onChange: (event: boolean) => setInternalValue(event),
|
93
|
+
transform: {
|
94
|
+
input: transform.input ?? (value => value),
|
95
|
+
output: transform.output ?? (event => event.value)
|
96
|
+
}
|
97
|
+
});
|
98
|
+
|
99
|
+
return (
|
100
|
+
<$Slider
|
101
|
+
{...commonProps}
|
102
|
+
checked={value}
|
103
|
+
onChange={(event) => {
|
104
|
+
onChange(event);
|
105
|
+
rest.onChange?.(event);
|
106
|
+
}}
|
107
|
+
onBlur={rest.onBlur}
|
108
|
+
/>
|
109
|
+
);
|
110
|
+
}
|
111
|
+
}, [internalValue, props]);
|
112
|
+
|
113
|
+
const labelEl = rest.label && (
|
114
|
+
<label htmlFor={inputId.current}>
|
115
|
+
{rest.label}
|
116
|
+
{isRequired && showRequiredStar ? '*' : ''}
|
117
|
+
</label>
|
118
|
+
);
|
119
|
+
|
120
|
+
return (
|
121
|
+
<div className={$classNames('checkbox-wrapper',
|
122
|
+
{
|
123
|
+
[`label-${labelPosition}`]: rest.label,
|
124
|
+
'is-rtl': rtl,
|
125
|
+
'is-ltr': !rtl,
|
126
|
+
})}>
|
127
|
+
<div className="field">
|
128
|
+
{labelEl}
|
129
|
+
<div className={$classNames('field-inner')}>
|
130
|
+
{rootEl()}
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
);
|
135
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./Slider";
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.knob-wrapper {
|
2
|
+
.field {
|
3
|
+
display: flex;
|
4
|
+
gap: 0.25rem 1rem;
|
5
|
+
|
6
|
+
> .field-inner {
|
7
|
+
flex-grow: 1;
|
8
|
+
display: flex;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
&.label-fix-side .field {
|
13
|
+
flex-direction: row;
|
14
|
+
align-items: center;
|
15
|
+
}
|
16
|
+
|
17
|
+
&.label-fix-top .field {
|
18
|
+
flex-direction: column;
|
19
|
+
|
20
|
+
label {
|
21
|
+
margin-bottom: 0.25rem;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&.is-ltr {
|
26
|
+
direction: ltr;
|
27
|
+
}
|
28
|
+
|
29
|
+
&.is-rtl {
|
30
|
+
direction: rtl;
|
31
|
+
}
|
32
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
import {ChangeEvent, ReactNode, useCallback, useRef, useState} from "react";
|
2
|
+
import {FixLabelPosition} from "@powell/models";
|
3
|
+
import {
|
4
|
+
$classNames,
|
5
|
+
$ErrorMessage,
|
6
|
+
$Field,
|
7
|
+
$FieldProps,
|
8
|
+
$ToggleButton,
|
9
|
+
$ToggleButtonProps,
|
10
|
+
$UniqueComponentId
|
11
|
+
} from "@powell/api";
|
12
|
+
import {isRequiredField, transformer} from "@powell/utils";
|
13
|
+
import {useApplyConfig, useFormContext} from "@powell/hooks";
|
14
|
+
import {SafeAny} from "@powell/models";
|
15
|
+
import '@components/ToggleButton/ToggleButton.scss';
|
16
|
+
|
17
|
+
interface ToggleButtonProps extends Omit<$ToggleButtonProps, 'checked'> {
|
18
|
+
checked?: boolean;
|
19
|
+
name?: string;
|
20
|
+
parseError?: (error: string) => ReactNode;
|
21
|
+
transform?: {
|
22
|
+
input?: (value: SafeAny) => string;
|
23
|
+
output?: (event: ChangeEvent<HTMLInputElement>) => SafeAny;
|
24
|
+
};
|
25
|
+
showRequiredStar?: boolean;
|
26
|
+
rtl?: boolean;
|
27
|
+
label?: string;
|
28
|
+
hint?: string;
|
29
|
+
labelPosition?: FixLabelPosition;
|
30
|
+
}
|
31
|
+
|
32
|
+
export const ToggleButton = (props: ToggleButtonProps) => {
|
33
|
+
props = useApplyConfig(props, {sizable: false, isFixLabel: true});
|
34
|
+
const {
|
35
|
+
parseError,
|
36
|
+
name,
|
37
|
+
transform = {},
|
38
|
+
labelPosition,
|
39
|
+
rtl,
|
40
|
+
showRequiredStar,
|
41
|
+
...rest
|
42
|
+
} = props;
|
43
|
+
|
44
|
+
const inputId = useRef($UniqueComponentId());
|
45
|
+
|
46
|
+
// Check if we're in Formik context
|
47
|
+
const formContext = useFormContext();
|
48
|
+
const withinForm = !!formContext && !!name;
|
49
|
+
const isRequired = withinForm && isRequiredField(formContext, name);
|
50
|
+
|
51
|
+
// Internal state for non-Formik usage
|
52
|
+
const [internalValue, setInternalValue] = useState(rest.checked);
|
53
|
+
|
54
|
+
const rootEl = useCallback(() => {
|
55
|
+
const commonProps = {
|
56
|
+
...rest,
|
57
|
+
inputId: inputId.current,
|
58
|
+
name,
|
59
|
+
};
|
60
|
+
|
61
|
+
if (withinForm) {
|
62
|
+
// if in Formik context
|
63
|
+
return (
|
64
|
+
<$Field name={name}>
|
65
|
+
{({field, meta}: $FieldProps) => {
|
66
|
+
const {value, onChange} = transformer({
|
67
|
+
value: field.value,
|
68
|
+
onChange: (event: boolean) => formContext.setFieldValue(name, event),
|
69
|
+
transform: {
|
70
|
+
input: transform.input ?? (value => value),
|
71
|
+
output: transform.output ?? (event => event.value)
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
return (
|
76
|
+
<>
|
77
|
+
<$ToggleButton
|
78
|
+
{...commonProps}
|
79
|
+
checked={value}
|
80
|
+
onChange={(event) => {
|
81
|
+
onChange(event);
|
82
|
+
rest.onChange?.(event);
|
83
|
+
}}
|
84
|
+
invalid={!!meta.error}
|
85
|
+
/>
|
86
|
+
<$ErrorMessage name={name}>
|
87
|
+
{
|
88
|
+
(message) => <small className="error">{parseError?.(message) ?? message}</small>
|
89
|
+
}
|
90
|
+
</$ErrorMessage>
|
91
|
+
<small className="hint">{rest.hint}</small>
|
92
|
+
</>
|
93
|
+
);
|
94
|
+
}}
|
95
|
+
</$Field>
|
96
|
+
);
|
97
|
+
} else {
|
98
|
+
// if outside Formik context
|
99
|
+
const {value, onChange} = transformer({
|
100
|
+
value: internalValue,
|
101
|
+
onChange: (event: boolean) => setInternalValue(event),
|
102
|
+
transform: {
|
103
|
+
input: transform.input ?? (value => value),
|
104
|
+
output: transform.output ?? (event => event.value)
|
105
|
+
}
|
106
|
+
});
|
107
|
+
|
108
|
+
return (
|
109
|
+
<$ToggleButton
|
110
|
+
{...commonProps}
|
111
|
+
checked={value}
|
112
|
+
onChange={(event) => {
|
113
|
+
onChange(event);
|
114
|
+
rest.onChange?.(event);
|
115
|
+
}}
|
116
|
+
onBlur={rest.onBlur}
|
117
|
+
/>
|
118
|
+
);
|
119
|
+
}
|
120
|
+
}, [internalValue, props]);
|
121
|
+
|
122
|
+
const labelEl = rest.label && (
|
123
|
+
<label htmlFor={inputId.current}>
|
124
|
+
{rest.label}
|
125
|
+
{isRequired && showRequiredStar ? '*' : ''}
|
126
|
+
</label>
|
127
|
+
);
|
128
|
+
|
129
|
+
return (
|
130
|
+
<div className={$classNames('checkbox-wrapper',
|
131
|
+
{
|
132
|
+
[`label-${labelPosition}`]: rest.label,
|
133
|
+
'is-rtl': rtl,
|
134
|
+
'is-ltr': !rtl,
|
135
|
+
})}>
|
136
|
+
<div className="field">
|
137
|
+
{labelEl}
|
138
|
+
<div className={$classNames('field-inner')}>
|
139
|
+
{rootEl()}
|
140
|
+
</div>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
);
|
144
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./ToggleButton";
|