@fountain-ui/core 2.0.0-beta.92 → 2.0.0-beta.93
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/build/commonjs/Button/Button.js +51 -63
- package/build/commonjs/Button/Button.js.map +1 -1
- package/build/commonjs/Button/ButtonProps.js +11 -0
- package/build/commonjs/Button/ButtonProps.js.map +1 -1
- package/build/commonjs/Button/LegacyButton.js +144 -0
- package/build/commonjs/Button/LegacyButton.js.map +1 -0
- package/build/commonjs/Button/LegacyButtonProps.js +2 -0
- package/build/commonjs/Button/LegacyButtonProps.js.map +1 -0
- package/build/commonjs/Button/index.js +2 -2
- package/build/commonjs/Button/index.js.map +1 -1
- package/build/commonjs/Button/useVariantStyleMap.js +95 -0
- package/build/commonjs/Button/useVariantStyleMap.js.map +1 -0
- package/build/commonjs/ButtonSet/ButtonSet.js +54 -0
- package/build/commonjs/ButtonSet/ButtonSet.js.map +1 -0
- package/build/commonjs/ButtonSet/ButtonSetProps.js +11 -0
- package/build/commonjs/ButtonSet/ButtonSetProps.js.map +1 -0
- package/build/commonjs/ButtonSet/index.js +30 -0
- package/build/commonjs/ButtonSet/index.js.map +1 -0
- package/build/commonjs/ButtonSet/useVariantStyleMap.js +85 -0
- package/build/commonjs/ButtonSet/useVariantStyleMap.js.map +1 -0
- package/build/commonjs/Checkbox/Checkbox.js +33 -23
- package/build/commonjs/Checkbox/Checkbox.js.map +1 -1
- package/build/commonjs/Checkbox/CheckboxProps.js +7 -0
- package/build/commonjs/Checkbox/CheckboxProps.js.map +1 -1
- package/build/commonjs/Checkbox/LegacyCheckbox.js +65 -0
- package/build/commonjs/Checkbox/LegacyCheckbox.js.map +1 -0
- package/build/commonjs/Checkbox/LegacyCheckboxProps.js +2 -0
- package/build/commonjs/Checkbox/LegacyCheckboxProps.js.map +1 -0
- package/build/commonjs/Checkbox/index.js +2 -2
- package/build/commonjs/Checkbox/index.js.map +1 -1
- package/build/commonjs/Checkbox/useVariantStyleMap.js +70 -0
- package/build/commonjs/Checkbox/useVariantStyleMap.js.map +1 -0
- package/build/commonjs/CheckboxGroup/CheckboxGroup.js +50 -0
- package/build/commonjs/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/build/commonjs/CheckboxGroup/CheckboxGroupProps.js +2 -0
- package/build/commonjs/CheckboxGroup/CheckboxGroupProps.js.map +1 -0
- package/build/commonjs/CheckboxGroup/index.js +16 -0
- package/build/commonjs/CheckboxGroup/index.js.map +1 -0
- package/build/commonjs/IconButton/IconButton.js +39 -42
- package/build/commonjs/IconButton/IconButton.js.map +1 -1
- package/build/commonjs/IconButton/IconButtonProps.js +7 -0
- package/build/commonjs/IconButton/IconButtonProps.js.map +1 -1
- package/build/commonjs/IconButton/LegacyIconButton.js +88 -0
- package/build/commonjs/IconButton/LegacyIconButton.js.map +1 -0
- package/build/commonjs/IconButton/LegacyIconButtonProps.js +2 -0
- package/build/commonjs/IconButton/LegacyIconButtonProps.js.map +1 -0
- package/build/commonjs/IconButton/index.js +2 -2
- package/build/commonjs/IconButton/index.js.map +1 -1
- package/build/commonjs/Radio/LegacyRadio.js +82 -0
- package/build/commonjs/Radio/LegacyRadio.js.map +1 -0
- package/build/commonjs/Radio/LegacyRadioProps.js +2 -0
- package/build/commonjs/Radio/LegacyRadioProps.js.map +1 -0
- package/build/commonjs/Radio/Radio.js +40 -19
- package/build/commonjs/Radio/Radio.js.map +1 -1
- package/build/commonjs/Radio/RadioProps.js.map +1 -1
- package/build/commonjs/Radio/index.js +2 -2
- package/build/commonjs/Radio/index.js.map +1 -1
- package/build/commonjs/RadioGroup/LegacyRadioGroup.js +31 -0
- package/build/commonjs/RadioGroup/LegacyRadioGroup.js.map +1 -0
- package/build/commonjs/RadioGroup/RadioGroup.js +28 -2
- package/build/commonjs/RadioGroup/RadioGroup.js.map +1 -1
- package/build/commonjs/RadioGroup/index.js +2 -2
- package/build/commonjs/RadioGroup/index.js.map +1 -1
- package/build/commonjs/ShadowView/ShadowView.js +35 -0
- package/build/commonjs/ShadowView/ShadowView.js.map +1 -0
- package/build/commonjs/ShadowView/ShadowView.native.js +35 -0
- package/build/commonjs/ShadowView/ShadowView.native.js.map +1 -0
- package/build/commonjs/ShadowView/ShadowViewProps.js +2 -0
- package/build/commonjs/ShadowView/ShadowViewProps.js.map +1 -0
- package/build/commonjs/ShadowView/index.js +16 -0
- package/build/commonjs/ShadowView/index.js.map +1 -0
- package/build/commonjs/SvgIcon/LegacySvgIcon.js +43 -0
- package/build/commonjs/SvgIcon/LegacySvgIcon.js.map +1 -0
- package/build/commonjs/SvgIcon/LegacySvgIconProps.js +2 -0
- package/build/commonjs/SvgIcon/LegacySvgIconProps.js.map +1 -0
- package/build/commonjs/SvgIcon/SvgIcon.js +16 -4
- package/build/commonjs/SvgIcon/SvgIcon.js.map +1 -1
- package/build/commonjs/SvgIcon/SvgIconProps.js +15 -0
- package/build/commonjs/SvgIcon/SvgIconProps.js.map +1 -1
- package/build/commonjs/SvgIcon/index.js +2 -2
- package/build/commonjs/SvgIcon/index.js.map +1 -1
- package/build/commonjs/Toggle/Toggle.js +110 -0
- package/build/commonjs/Toggle/Toggle.js.map +1 -0
- package/build/commonjs/Toggle/ToggleProps.js +2 -0
- package/build/commonjs/Toggle/ToggleProps.js.map +1 -0
- package/build/commonjs/Toggle/index.js +16 -0
- package/build/commonjs/Toggle/index.js.map +1 -0
- package/build/commonjs/Typography/LegacyTypography.js +142 -0
- package/build/commonjs/Typography/LegacyTypography.js.map +1 -0
- package/build/commonjs/Typography/LegacyTypographyProps.js +2 -0
- package/build/commonjs/Typography/LegacyTypographyProps.js.map +1 -0
- package/build/commonjs/Typography/Typography.js +15 -54
- package/build/commonjs/Typography/Typography.js.map +1 -1
- package/build/commonjs/Typography/TypographyProps.js +7 -0
- package/build/commonjs/Typography/TypographyProps.js.map +1 -1
- package/build/commonjs/Typography/index.js +2 -2
- package/build/commonjs/Typography/index.js.map +1 -1
- package/build/commonjs/hooks/useCollapsibleAppBar.js +11 -2
- package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/index.js +84 -0
- package/build/commonjs/index.js.map +1 -1
- package/build/commonjs/internal/icons/Check.js +23 -0
- package/build/commonjs/internal/icons/Check.js.map +1 -0
- package/build/commonjs/internal/icons/CheckboxOn.js +23 -0
- package/build/commonjs/internal/icons/CheckboxOn.js.map +1 -0
- package/build/commonjs/internal/icons/index.js +16 -0
- package/build/commonjs/internal/icons/index.js.map +1 -1
- package/build/commonjs/styles/createFontStyle.js.map +1 -1
- package/build/commonjs/utils/cloneElementSafely.js.map +1 -1
- package/build/commonjs/utils/createSvgIcon.js +15 -3
- package/build/commonjs/utils/createSvgIcon.js.map +1 -1
- package/build/commonjs/utils/index.js.map +1 -1
- package/build/module/Button/Button.js +53 -63
- package/build/module/Button/Button.js.map +1 -1
- package/build/module/Button/ButtonProps.js +3 -1
- package/build/module/Button/ButtonProps.js.map +1 -1
- package/build/module/Button/LegacyButton.js +127 -0
- package/build/module/Button/LegacyButton.js.map +1 -0
- package/build/module/Button/LegacyButtonProps.js +2 -0
- package/build/module/Button/LegacyButtonProps.js.map +1 -0
- package/build/module/Button/index.js +1 -1
- package/build/module/Button/index.js.map +1 -1
- package/build/module/Button/useVariantStyleMap.js +85 -0
- package/build/module/Button/useVariantStyleMap.js.map +1 -0
- package/build/module/ButtonSet/ButtonSet.js +34 -0
- package/build/module/ButtonSet/ButtonSet.js.map +1 -0
- package/build/module/ButtonSet/ButtonSetProps.js +3 -0
- package/build/module/ButtonSet/ButtonSetProps.js.map +1 -0
- package/build/module/ButtonSet/index.js +3 -0
- package/build/module/ButtonSet/index.js.map +1 -0
- package/build/module/ButtonSet/useVariantStyleMap.js +76 -0
- package/build/module/ButtonSet/useVariantStyleMap.js.map +1 -0
- package/build/module/Checkbox/Checkbox.js +32 -26
- package/build/module/Checkbox/Checkbox.js.map +1 -1
- package/build/module/Checkbox/CheckboxProps.js +1 -1
- package/build/module/Checkbox/CheckboxProps.js.map +1 -1
- package/build/module/Checkbox/LegacyCheckbox.js +52 -0
- package/build/module/Checkbox/LegacyCheckbox.js.map +1 -0
- package/build/module/Checkbox/LegacyCheckboxProps.js +2 -0
- package/build/module/Checkbox/LegacyCheckboxProps.js.map +1 -0
- package/build/module/Checkbox/index.js +1 -1
- package/build/module/Checkbox/index.js.map +1 -1
- package/build/module/Checkbox/useVariantStyleMap.js +59 -0
- package/build/module/Checkbox/useVariantStyleMap.js.map +1 -0
- package/build/module/CheckboxGroup/CheckboxGroup.js +34 -0
- package/build/module/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/build/module/CheckboxGroup/CheckboxGroupProps.js +2 -0
- package/build/module/CheckboxGroup/CheckboxGroupProps.js.map +1 -0
- package/build/module/CheckboxGroup/index.js +2 -0
- package/build/module/CheckboxGroup/index.js.map +1 -0
- package/build/module/IconButton/IconButton.js +36 -40
- package/build/module/IconButton/IconButton.js.map +1 -1
- package/build/module/IconButton/IconButtonProps.js +1 -1
- package/build/module/IconButton/IconButtonProps.js.map +1 -1
- package/build/module/IconButton/LegacyIconButton.js +73 -0
- package/build/module/IconButton/LegacyIconButton.js.map +1 -0
- package/build/module/IconButton/LegacyIconButtonProps.js +2 -0
- package/build/module/IconButton/LegacyIconButtonProps.js.map +1 -0
- package/build/module/IconButton/index.js +1 -1
- package/build/module/IconButton/index.js.map +1 -1
- package/build/module/Radio/LegacyRadio.js +63 -0
- package/build/module/Radio/LegacyRadio.js.map +1 -0
- package/build/module/Radio/LegacyRadioProps.js +2 -0
- package/build/module/Radio/LegacyRadioProps.js.map +1 -0
- package/build/module/Radio/Radio.js +35 -18
- package/build/module/Radio/Radio.js.map +1 -1
- package/build/module/Radio/RadioProps.js.map +1 -1
- package/build/module/Radio/index.js +1 -1
- package/build/module/Radio/index.js.map +1 -1
- package/build/module/RadioGroup/LegacyRadioGroup.js +18 -0
- package/build/module/RadioGroup/LegacyRadioGroup.js.map +1 -0
- package/build/module/RadioGroup/RadioGroup.js +21 -2
- package/build/module/RadioGroup/RadioGroup.js.map +1 -1
- package/build/module/RadioGroup/index.js +1 -1
- package/build/module/RadioGroup/index.js.map +1 -1
- package/build/module/ShadowView/ShadowView.js +23 -0
- package/build/module/ShadowView/ShadowView.js.map +1 -0
- package/build/module/ShadowView/ShadowView.native.js +23 -0
- package/build/module/ShadowView/ShadowView.native.js.map +1 -0
- package/build/module/ShadowView/ShadowViewProps.js +2 -0
- package/build/module/ShadowView/ShadowViewProps.js.map +1 -0
- package/build/module/ShadowView/index.js +2 -0
- package/build/module/ShadowView/index.js.map +1 -0
- package/build/module/SvgIcon/LegacySvgIcon.js +30 -0
- package/build/module/SvgIcon/LegacySvgIcon.js.map +1 -0
- package/build/module/SvgIcon/LegacySvgIconProps.js +2 -0
- package/build/module/SvgIcon/LegacySvgIconProps.js.map +1 -0
- package/build/module/SvgIcon/SvgIcon.js +15 -4
- package/build/module/SvgIcon/SvgIcon.js.map +1 -1
- package/build/module/SvgIcon/SvgIconProps.js +7 -1
- package/build/module/SvgIcon/SvgIconProps.js.map +1 -1
- package/build/module/SvgIcon/index.js +1 -1
- package/build/module/SvgIcon/index.js.map +1 -1
- package/build/module/Toggle/Toggle.js +90 -0
- package/build/module/Toggle/Toggle.js.map +1 -0
- package/build/module/Toggle/ToggleProps.js +2 -0
- package/build/module/Toggle/ToggleProps.js.map +1 -0
- package/build/module/Toggle/index.js +2 -0
- package/build/module/Toggle/index.js.map +1 -0
- package/build/module/Typography/LegacyTypography.js +126 -0
- package/build/module/Typography/LegacyTypography.js.map +1 -0
- package/build/module/Typography/LegacyTypographyProps.js +2 -0
- package/build/module/Typography/LegacyTypographyProps.js.map +1 -0
- package/build/module/Typography/Typography.js +15 -54
- package/build/module/Typography/Typography.js.map +1 -1
- package/build/module/Typography/TypographyProps.js +1 -1
- package/build/module/Typography/TypographyProps.js.map +1 -1
- package/build/module/Typography/index.js +1 -1
- package/build/module/Typography/index.js.map +1 -1
- package/build/module/hooks/useCollapsibleAppBar.js +12 -3
- package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/module/index.js +8 -0
- package/build/module/index.js.map +1 -1
- package/build/module/internal/icons/Check.js +9 -0
- package/build/module/internal/icons/Check.js.map +1 -0
- package/build/module/internal/icons/CheckboxOn.js +9 -0
- package/build/module/internal/icons/CheckboxOn.js.map +1 -0
- package/build/module/internal/icons/index.js +2 -0
- package/build/module/internal/icons/index.js.map +1 -1
- package/build/module/styles/createFontStyle.js.map +1 -1
- package/build/module/utils/cloneElementSafely.js.map +1 -1
- package/build/module/utils/createSvgIcon.js +14 -3
- package/build/module/utils/createSvgIcon.js.map +1 -1
- package/build/module/utils/index.js.map +1 -1
- package/build/typescript/Button/ButtonProps.d.ts +13 -11
- package/build/typescript/Button/LegacyButton.d.ts +3 -0
- package/build/typescript/Button/LegacyButtonProps.d.ts +51 -0
- package/build/typescript/Button/index.d.ts +2 -2
- package/build/typescript/Button/useVariantStyleMap.d.ts +9 -0
- package/build/typescript/ButtonSet/ButtonSet.d.ts +3 -0
- package/build/typescript/ButtonSet/ButtonSetProps.d.ts +20 -0
- package/build/typescript/ButtonSet/index.d.ts +3 -0
- package/build/typescript/ButtonSet/useVariantStyleMap.d.ts +10 -0
- package/build/typescript/Checkbox/CheckboxProps.d.ts +10 -14
- package/build/typescript/Checkbox/LegacyCheckbox.d.ts +3 -0
- package/build/typescript/Checkbox/LegacyCheckboxProps.d.ts +36 -0
- package/build/typescript/Checkbox/index.d.ts +2 -2
- package/build/typescript/Checkbox/useVariantStyleMap.d.ts +9 -0
- package/build/typescript/CheckboxGroup/CheckboxGroup.d.ts +3 -0
- package/build/typescript/CheckboxGroup/CheckboxGroupProps.d.ts +11 -0
- package/build/typescript/CheckboxGroup/index.d.ts +2 -0
- package/build/typescript/IconButton/IconButtonProps.d.ts +7 -10
- package/build/typescript/IconButton/LegacyIconButton.d.ts +3 -0
- package/build/typescript/IconButton/LegacyIconButtonProps.d.ts +26 -0
- package/build/typescript/IconButton/index.d.ts +2 -2
- package/build/typescript/Radio/LegacyRadio.d.ts +3 -0
- package/build/typescript/Radio/LegacyRadioProps.d.ts +43 -0
- package/build/typescript/Radio/RadioProps.d.ts +9 -14
- package/build/typescript/Radio/index.d.ts +2 -2
- package/build/typescript/RadioGroup/LegacyRadioGroup.d.ts +3 -0
- package/build/typescript/RadioGroup/index.d.ts +1 -1
- package/build/typescript/ShadowView/ShadowView.d.ts +3 -0
- package/build/typescript/ShadowView/ShadowView.native.d.ts +3 -0
- package/build/typescript/ShadowView/ShadowViewProps.d.ts +11 -0
- package/build/typescript/ShadowView/index.d.ts +2 -0
- package/build/typescript/SvgIcon/LegacySvgIcon.d.ts +3 -0
- package/build/typescript/SvgIcon/LegacySvgIconProps.d.ts +35 -0
- package/build/typescript/SvgIcon/SvgIconProps.d.ts +17 -6
- package/build/typescript/SvgIcon/index.d.ts +2 -2
- package/build/typescript/Toggle/Toggle.d.ts +3 -0
- package/build/typescript/Toggle/ToggleProps.d.ts +19 -0
- package/build/typescript/Toggle/index.d.ts +2 -0
- package/build/typescript/Typography/LegacyTypography.d.ts +5 -0
- package/build/typescript/Typography/LegacyTypographyProps.d.ts +81 -0
- package/build/typescript/Typography/Typography.d.ts +1 -1
- package/build/typescript/Typography/TypographyProps.d.ts +12 -9
- package/build/typescript/Typography/index.d.ts +2 -2
- package/build/typescript/hooks/useCollapsibleAppBar.d.ts +1 -0
- package/build/typescript/index.d.ts +8 -0
- package/build/typescript/internal/icons/Check.d.ts +8 -0
- package/build/typescript/internal/icons/Checkbox.d.ts +2 -124
- package/build/typescript/internal/icons/CheckboxChecked.d.ts +2 -124
- package/build/typescript/internal/icons/CheckboxOn.d.ts +8 -0
- package/build/typescript/internal/icons/ChevronDown.d.ts +2 -124
- package/build/typescript/internal/icons/ChevronLeft.d.ts +2 -124
- package/build/typescript/internal/icons/ChevronRight.d.ts +2 -124
- package/build/typescript/internal/icons/Close.d.ts +2 -124
- package/build/typescript/internal/icons/Radio.d.ts +2 -124
- package/build/typescript/internal/icons/RadioChecked.d.ts +2 -124
- package/build/typescript/internal/icons/index.d.ts +2 -0
- package/build/typescript/styles/createFontStyle.d.ts +1 -1
- package/build/typescript/utils/cloneElementSafely.d.ts +1 -2
- package/build/typescript/utils/createSvgIcon.d.ts +8 -3
- package/build/typescript/utils/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Button/Button.tsx +53 -71
- package/src/Button/ButtonProps.ts +29 -12
- package/src/Button/LegacyButton.tsx +157 -0
- package/src/Button/LegacyButtonProps.ts +62 -0
- package/src/Button/index.ts +2 -2
- package/src/Button/useVariantStyleMap.ts +99 -0
- package/src/ButtonSet/ButtonSet.tsx +43 -0
- package/src/ButtonSet/ButtonSetProps.ts +27 -0
- package/src/ButtonSet/index.ts +3 -0
- package/src/ButtonSet/useVariantStyleMap.ts +84 -0
- package/src/Checkbox/Checkbox.tsx +48 -33
- package/src/Checkbox/CheckboxProps.ts +10 -15
- package/src/Checkbox/LegacyCheckbox.tsx +62 -0
- package/src/Checkbox/LegacyCheckboxProps.ts +42 -0
- package/src/Checkbox/index.ts +2 -2
- package/src/Checkbox/useVariantStyleMap.ts +71 -0
- package/src/CheckboxGroup/CheckboxGroup.tsx +47 -0
- package/src/CheckboxGroup/CheckboxGroupProps.ts +11 -0
- package/src/CheckboxGroup/index.ts +2 -0
- package/src/IconButton/IconButton.tsx +36 -54
- package/src/IconButton/IconButtonProps.ts +12 -12
- package/src/IconButton/LegacyIconButton.tsx +96 -0
- package/src/IconButton/LegacyIconButtonProps.ts +31 -0
- package/src/IconButton/index.ts +2 -2
- package/src/Radio/LegacyRadio.tsx +72 -0
- package/src/Radio/LegacyRadioProps.ts +50 -0
- package/src/Radio/Radio.tsx +47 -16
- package/src/Radio/RadioProps.ts +10 -16
- package/src/Radio/index.ts +2 -2
- package/src/RadioGroup/LegacyRadioGroup.tsx +20 -0
- package/src/RadioGroup/RadioGroup.tsx +31 -4
- package/src/RadioGroup/index.ts +2 -2
- package/src/ShadowView/ShadowView.native.tsx +37 -0
- package/src/ShadowView/ShadowView.tsx +33 -0
- package/src/ShadowView/ShadowViewProps.ts +11 -0
- package/src/ShadowView/index.ts +2 -0
- package/src/SvgIcon/LegacySvgIcon.tsx +36 -0
- package/src/SvgIcon/LegacySvgIconProps.ts +41 -0
- package/src/SvgIcon/SvgIcon.tsx +19 -5
- package/src/SvgIcon/SvgIconProps.ts +33 -6
- package/src/SvgIcon/index.ts +2 -2
- package/src/Toggle/Toggle.tsx +113 -0
- package/src/Toggle/ToggleProps.ts +21 -0
- package/src/Toggle/index.ts +2 -0
- package/src/Typography/LegacyTypography.tsx +107 -0
- package/src/Typography/LegacyTypographyProps.ts +122 -0
- package/src/Typography/Typography.tsx +24 -30
- package/src/Typography/TypographyProps.ts +29 -34
- package/src/Typography/index.ts +2 -2
- package/src/hooks/useCollapsibleAppBar.ts +12 -2
- package/src/index.ts +12 -0
- package/src/internal/icons/Check.tsx +13 -0
- package/src/internal/icons/CheckboxOn.tsx +13 -0
- package/src/internal/icons/index.ts +2 -0
- package/src/styles/createFontStyle.ts +1 -1
- package/src/utils/cloneElementSafely.ts +1 -1
- package/src/utils/createSvgIcon.tsx +29 -6
- package/src/utils/index.ts +1 -0
|
@@ -15,40 +15,50 @@ var _styles = require("../styles");
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("../utils");
|
|
17
17
|
|
|
18
|
+
var _useVariantStyleMap = _interopRequireDefault(require("./useVariantStyleMap"));
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
21
|
|
|
20
22
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
const useStyles = function () {
|
|
25
|
+
const theme = (0, _styles.useTheme)();
|
|
26
|
+
return {
|
|
27
|
+
root: {
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
borderRadius: theme.shape.radius.sm,
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
justifyContent: 'center'
|
|
32
|
+
},
|
|
33
|
+
fullWidth: {
|
|
34
|
+
width: '100%'
|
|
35
|
+
},
|
|
36
|
+
large: {
|
|
37
|
+
gap: theme.spacing(2),
|
|
38
|
+
minWidth: 104,
|
|
39
|
+
paddingHorizontal: theme.spacing(6),
|
|
40
|
+
paddingVertical: theme.spacing(3.5)
|
|
41
|
+
},
|
|
42
|
+
medium: {
|
|
43
|
+
gap: theme.spacing(1.5),
|
|
44
|
+
minWidth: 88,
|
|
45
|
+
paddingHorizontal: 11,
|
|
46
|
+
paddingVertical: theme.spacing(3)
|
|
47
|
+
},
|
|
48
|
+
small: {
|
|
49
|
+
minWidth: 64,
|
|
50
|
+
paddingHorizontal: theme.spacing(2.5),
|
|
51
|
+
paddingVertical: theme.spacing(2)
|
|
52
|
+
}
|
|
53
|
+
};
|
|
25
54
|
};
|
|
26
55
|
|
|
27
|
-
const styles = _styles.StyleSheet.create({
|
|
28
|
-
root: {
|
|
29
|
-
flexDirection: 'row',
|
|
30
|
-
justifyContent: 'center',
|
|
31
|
-
alignItems: 'center'
|
|
32
|
-
},
|
|
33
|
-
fullWidth: {
|
|
34
|
-
width: '100%'
|
|
35
|
-
},
|
|
36
|
-
medium: {
|
|
37
|
-
minWidth: 104,
|
|
38
|
-
height: 48
|
|
39
|
-
},
|
|
40
|
-
small: {
|
|
41
|
-
minWidth: 56,
|
|
42
|
-
height: 32
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
56
|
function Button(props) {
|
|
47
57
|
const {
|
|
48
58
|
children,
|
|
49
|
-
clipHorizontalSpacing = false,
|
|
50
59
|
color = 'primary',
|
|
51
60
|
disabled = false,
|
|
61
|
+
disableMinWidth = false,
|
|
52
62
|
endIcon: endIconProp,
|
|
53
63
|
fullWidth = false,
|
|
54
64
|
href,
|
|
@@ -57,57 +67,35 @@ function Button(props) {
|
|
|
57
67
|
size = 'medium',
|
|
58
68
|
startIcon: startIconProp,
|
|
59
69
|
style: styleProp,
|
|
60
|
-
variant = '
|
|
70
|
+
variant = 'solid',
|
|
61
71
|
...otherProps
|
|
62
72
|
} = props;
|
|
63
73
|
const theme = (0, _styles.useTheme)();
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
backgroundColor: 'transparent',
|
|
72
|
-
borderColor: mainColor,
|
|
73
|
-
borderStyle: 'solid',
|
|
74
|
-
borderWidth: 1
|
|
75
|
-
},
|
|
76
|
-
text: {
|
|
77
|
-
backgroundColor: 'transparent'
|
|
78
|
-
}
|
|
79
|
-
};
|
|
74
|
+
const styles = useStyles();
|
|
75
|
+
const {
|
|
76
|
+
borderColor,
|
|
77
|
+
fillColor,
|
|
78
|
+
iconColor,
|
|
79
|
+
labelColor
|
|
80
|
+
} = (0, _useVariantStyleMap.default)(variant, color);
|
|
80
81
|
const iconProps = {
|
|
81
|
-
|
|
82
|
-
height: iconSizes[size],
|
|
83
|
-
fill: fontColor
|
|
82
|
+
fill: iconColor
|
|
84
83
|
};
|
|
85
84
|
const startIcon = (0, _utils.cloneElementSafely)(startIconProp, iconProps);
|
|
86
85
|
const endIcon = (0, _utils.cloneElementSafely)(endIconProp, iconProps);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
color: fontColor
|
|
94
|
-
}, variant === 'text' && clipHorizontalSpacing ? {
|
|
86
|
+
const buttonBaseStyle = (0, _styles.css)([styles.root, {
|
|
87
|
+
backgroundColor: fillColor
|
|
88
|
+
}, variant === 'outlined' ? {
|
|
89
|
+
borderColor,
|
|
90
|
+
borderWidth: 1
|
|
91
|
+
} : undefined, styles[size], fullWidth ? styles.fullWidth : undefined, disableMinWidth ? {
|
|
95
92
|
minWidth: 0
|
|
96
|
-
} :
|
|
97
|
-
paddingLeft,
|
|
98
|
-
paddingRight
|
|
99
|
-
}, styleProp]);
|
|
93
|
+
} : undefined, styleProp]);
|
|
100
94
|
const fontStyle = (0, _styles.createFontStyle)(theme, {
|
|
101
95
|
selector: typo => size === 'small' ? typo.button2 : typo.button1,
|
|
102
|
-
color:
|
|
96
|
+
color: labelColor
|
|
103
97
|
});
|
|
104
|
-
const
|
|
105
|
-
const textMarginStyle = startIcon ? {
|
|
106
|
-
marginLeft: textMarginSize
|
|
107
|
-
} : endIcon ? {
|
|
108
|
-
marginRight: textMarginSize
|
|
109
|
-
} : undefined;
|
|
110
|
-
const textStyle = (0, _styles.css)([fontStyle, textMarginStyle, {
|
|
98
|
+
const textStyle = (0, _styles.css)([fontStyle, {
|
|
111
99
|
textAlign: 'center'
|
|
112
100
|
}]);
|
|
113
101
|
const modifiedPressEffect = variant !== 'text' && !pressEffect ? 'scale' : pressEffect;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useStyles","theme","useTheme","root","alignItems","borderRadius","shape","radius","sm","flexDirection","justifyContent","fullWidth","width","large","gap","spacing","minWidth","paddingHorizontal","paddingVertical","medium","small","Button","props","children","color","disabled","disableMinWidth","endIcon","endIconProp","href","onPress","pressEffect","size","startIcon","startIconProp","style","styleProp","variant","otherProps","styles","borderColor","fillColor","iconColor","labelColor","useVariantStyleMap","iconProps","fill","cloneElementSafely","buttonBaseStyle","css","backgroundColor","borderWidth","undefined","fontStyle","createFontStyle","selector","typo","button2","button1","textStyle","textAlign","modifiedPressEffect","handlePress","Linking","canOpenURL","openURL"],"sources":["Button.tsx"],"sourcesContent":["import React from 'react';\nimport { Linking, Text } from 'react-native';\nimport type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport { createFontStyle, css, useTheme } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ButtonProps from './ButtonProps';\nimport type { ButtonColor, ButtonSize, ButtonVariant } from './ButtonProps';\nimport useVariantStyleMap from './useVariantStyleMap';\n\ntype ButtonStyles = NamedStylesStringUnion<'root' | 'fullWidth' | 'large' | 'medium' | 'small'>;\n\nconst useStyles: UseStyles<ButtonStyles> = function (): ButtonStyles {\n const theme = useTheme();\n\n return {\n root: {\n alignItems: 'center',\n borderRadius: theme.shape.radius.sm,\n flexDirection: 'row',\n justifyContent: 'center',\n },\n fullWidth: {\n width: '100%',\n },\n large: {\n gap: theme.spacing(2),\n minWidth: 104,\n paddingHorizontal: theme.spacing(6),\n paddingVertical: theme.spacing(3.5),\n },\n medium: {\n gap: theme.spacing(1.5),\n minWidth: 88,\n paddingHorizontal: 11,\n paddingVertical: theme.spacing(3),\n },\n small: {\n minWidth: 64,\n paddingHorizontal: theme.spacing(2.5),\n paddingVertical: theme.spacing(2),\n },\n };\n};\n\nexport default function Button(props: ButtonProps) {\n const {\n children,\n color = 'primary' as ButtonColor,\n disabled = false,\n disableMinWidth = false,\n endIcon: endIconProp,\n fullWidth = false,\n href,\n onPress,\n pressEffect,\n size = 'medium' as ButtonSize,\n startIcon: startIconProp,\n style: styleProp,\n variant = 'solid' as ButtonVariant,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const styles = useStyles();\n\n const {\n borderColor,\n fillColor,\n iconColor,\n labelColor,\n } = useVariantStyleMap(variant, color);\n\n const iconProps = {\n fill: iconColor,\n };\n\n const startIcon = cloneElementSafely(startIconProp, iconProps);\n const endIcon = cloneElementSafely(endIconProp, iconProps);\n\n const buttonBaseStyle = css([\n styles.root,\n { backgroundColor: fillColor },\n variant === 'outlined' ? { borderColor, borderWidth: 1 } : undefined,\n styles[size],\n fullWidth ? styles.fullWidth : undefined,\n disableMinWidth ? { minWidth: 0 } : undefined,\n styleProp,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => size === 'small' ? typo.button2 : typo.button1,\n color: labelColor,\n });\n\n const textStyle = css([\n fontStyle,\n { textAlign: 'center' },\n ]);\n\n const modifiedPressEffect = variant !== 'text' && !pressEffect\n ? 'scale'\n : pressEffect;\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n if (href) {\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={buttonBaseStyle}\n pressEffect={modifiedPressEffect}\n {...otherProps}\n >\n {startIcon}\n\n <Text\n children={children}\n style={textStyle}\n />\n\n {endIcon}\n </ButtonBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AAGA;;;;;;AAIA,MAAMA,SAAkC,GAAG,YAA0B;EACjE,MAAMC,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,OAAO;IACHC,IAAI,EAAE;MACFC,UAAU,EAAE,QADV;MAEFC,YAAY,EAAEJ,KAAK,CAACK,KAAN,CAAYC,MAAZ,CAAmBC,EAF/B;MAGFC,aAAa,EAAE,KAHb;MAIFC,cAAc,EAAE;IAJd,CADH;IAOHC,SAAS,EAAE;MACPC,KAAK,EAAE;IADA,CAPR;IAUHC,KAAK,EAAE;MACHC,GAAG,EAAEb,KAAK,CAACc,OAAN,CAAc,CAAd,CADF;MAEHC,QAAQ,EAAE,GAFP;MAGHC,iBAAiB,EAAEhB,KAAK,CAACc,OAAN,CAAc,CAAd,CAHhB;MAIHG,eAAe,EAAEjB,KAAK,CAACc,OAAN,CAAc,GAAd;IAJd,CAVJ;IAgBHI,MAAM,EAAE;MACJL,GAAG,EAAEb,KAAK,CAACc,OAAN,CAAc,GAAd,CADD;MAEJC,QAAQ,EAAE,EAFN;MAGJC,iBAAiB,EAAE,EAHf;MAIJC,eAAe,EAAEjB,KAAK,CAACc,OAAN,CAAc,CAAd;IAJb,CAhBL;IAsBHK,KAAK,EAAE;MACHJ,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|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ButtonVariants = exports.ButtonSizes = exports.ButtonColors = void 0;
|
|
7
|
+
const ButtonColors = ['accent', 'primary', 'danger', 'disabled', 'secondary', 'accentAlt'];
|
|
8
|
+
exports.ButtonColors = ButtonColors;
|
|
9
|
+
const ButtonSizes = ['small', 'medium', 'large'];
|
|
10
|
+
exports.ButtonSizes = ButtonSizes;
|
|
11
|
+
const ButtonVariants = ['solid', 'outlined', 'text'];
|
|
12
|
+
exports.ButtonVariants = ButtonVariants;
|
|
2
13
|
//# sourceMappingURL=ButtonProps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["ButtonProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ButtonBaseProps } from '../ButtonBase';\nimport type { OverridableComponentProps
|
|
1
|
+
{"version":3,"names":["ButtonColors","ButtonSizes","ButtonVariants"],"sources":["ButtonProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ButtonBaseProps } from '../ButtonBase';\nimport type { OverridableComponentProps } from '../types';\n\nexport const ButtonColors = [\n 'accent',\n 'primary',\n 'danger',\n 'disabled',\n 'secondary',\n 'accentAlt',\n] as const;\nexport type ButtonColor = typeof ButtonColors[number];\n\nexport const ButtonSizes = [\n 'small',\n 'medium',\n 'large',\n] as const;\nexport type ButtonSize = typeof ButtonSizes[number];\n\nexport const ButtonVariants = [\n 'solid',\n 'outlined',\n 'text',\n] as const;\nexport type ButtonVariant = typeof ButtonVariants[number];\n\nexport default interface ButtonProps extends OverridableComponentProps<ButtonBaseProps, {\n /**\n * The content of the button.\n */\n children: string;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'primary'\n */\n color?: ButtonColor;\n\n /**\n * Determines whether minWidth should be applied.\n * @default false\n */\n disableMinWidth?: boolean;\n\n /**\n * Element placed after the children.\n */\n endIcon?: React.ReactElement;\n\n /**\n * If `true`, the button will take up the full width of its container.\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * The URL to link to when the button is clicked.\n */\n href?: string;\n\n /**\n * The size of the button.\n * @default 'medium'\n */\n size?: ButtonSize;\n\n /**\n * Element placed before the children.\n */\n startIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'solid'\n */\n variant?: ButtonVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,YAAY,GAAG,CACxB,QADwB,EAExB,SAFwB,EAGxB,QAHwB,EAIxB,UAJwB,EAKxB,WALwB,EAMxB,WANwB,CAArB;;AAUA,MAAMC,WAAW,GAAG,CACvB,OADuB,EAEvB,QAFuB,EAGvB,OAHuB,CAApB;;AAOA,MAAMC,cAAc,GAAG,CAC1B,OAD0B,EAE1B,UAF0B,EAG1B,MAH0B,CAAvB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = Button;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _ButtonBase = _interopRequireDefault(require("../ButtonBase"));
|
|
13
|
+
|
|
14
|
+
var _styles = require("../styles");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
+
|
|
22
|
+
const iconSizes = {
|
|
23
|
+
small: 20,
|
|
24
|
+
medium: 24
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const styles = _styles.StyleSheet.create({
|
|
28
|
+
root: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
alignItems: 'center'
|
|
32
|
+
},
|
|
33
|
+
fullWidth: {
|
|
34
|
+
width: '100%'
|
|
35
|
+
},
|
|
36
|
+
medium: {
|
|
37
|
+
minWidth: 104,
|
|
38
|
+
height: 48
|
|
39
|
+
},
|
|
40
|
+
small: {
|
|
41
|
+
minWidth: 56,
|
|
42
|
+
height: 32
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
function Button(props) {
|
|
47
|
+
const {
|
|
48
|
+
children,
|
|
49
|
+
clipHorizontalSpacing = false,
|
|
50
|
+
color = 'primary',
|
|
51
|
+
disabled = false,
|
|
52
|
+
endIcon: endIconProp,
|
|
53
|
+
fullWidth = false,
|
|
54
|
+
href,
|
|
55
|
+
onPress,
|
|
56
|
+
pressEffect,
|
|
57
|
+
size = 'medium',
|
|
58
|
+
startIcon: startIconProp,
|
|
59
|
+
style: styleProp,
|
|
60
|
+
variant = 'contained',
|
|
61
|
+
...otherProps
|
|
62
|
+
} = props;
|
|
63
|
+
const theme = (0, _styles.useTheme)();
|
|
64
|
+
const mainColor = theme.palette[color].main;
|
|
65
|
+
const fontColor = variant === 'contained' ? theme.palette[color].contrastTextColor : theme.palette[color].main;
|
|
66
|
+
const variantStyleMap = {
|
|
67
|
+
contained: {
|
|
68
|
+
backgroundColor: mainColor
|
|
69
|
+
},
|
|
70
|
+
outlined: {
|
|
71
|
+
backgroundColor: 'transparent',
|
|
72
|
+
borderColor: mainColor,
|
|
73
|
+
borderStyle: 'solid',
|
|
74
|
+
borderWidth: 1
|
|
75
|
+
},
|
|
76
|
+
text: {
|
|
77
|
+
backgroundColor: 'transparent'
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const iconProps = {
|
|
81
|
+
width: iconSizes[size],
|
|
82
|
+
height: iconSizes[size],
|
|
83
|
+
fill: fontColor
|
|
84
|
+
};
|
|
85
|
+
const startIcon = (0, _utils.cloneElementSafely)(startIconProp, iconProps);
|
|
86
|
+
const endIcon = (0, _utils.cloneElementSafely)(endIconProp, iconProps);
|
|
87
|
+
const paddingSize = size === 'small' ? theme.spacing(3) : theme.spacing(4);
|
|
88
|
+
const paddingLeft = startIcon ? paddingSize - theme.spacing(1) : paddingSize;
|
|
89
|
+
const paddingRight = endIcon ? paddingSize - theme.spacing(1) : paddingSize;
|
|
90
|
+
const borderRadius = theme.shape.roundnessLarge;
|
|
91
|
+
const buttonBaseStyle = (0, _styles.css)([styles.root, variantStyleMap[variant], size === 'medium' ? styles.medium : styles.small, fullWidth ? styles.fullWidth : undefined, {
|
|
92
|
+
borderRadius,
|
|
93
|
+
color: fontColor
|
|
94
|
+
}, variant === 'text' && clipHorizontalSpacing ? {
|
|
95
|
+
minWidth: 0
|
|
96
|
+
} : {
|
|
97
|
+
paddingLeft,
|
|
98
|
+
paddingRight
|
|
99
|
+
}, styleProp]);
|
|
100
|
+
const fontStyle = (0, _styles.createFontStyle)(theme, {
|
|
101
|
+
selector: typo => size === 'small' ? typo.button2 : typo.button1,
|
|
102
|
+
color: fontColor
|
|
103
|
+
});
|
|
104
|
+
const textMarginSize = size === 'small' ? theme.spacing(1) : theme.spacing(2);
|
|
105
|
+
const textMarginStyle = startIcon ? {
|
|
106
|
+
marginLeft: textMarginSize
|
|
107
|
+
} : endIcon ? {
|
|
108
|
+
marginRight: textMarginSize
|
|
109
|
+
} : undefined;
|
|
110
|
+
const textStyle = (0, _styles.css)([fontStyle, textMarginStyle, {
|
|
111
|
+
textAlign: 'center'
|
|
112
|
+
}]);
|
|
113
|
+
const modifiedPressEffect = variant !== 'text' && !pressEffect ? 'scale' : pressEffect;
|
|
114
|
+
|
|
115
|
+
const handlePress = async () => {
|
|
116
|
+
if (disabled) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (onPress) {
|
|
121
|
+
onPress();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (href) {
|
|
126
|
+
if (await _reactNative.Linking.canOpenURL(href)) {
|
|
127
|
+
await _reactNative.Linking.openURL(href);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return /*#__PURE__*/_react.default.createElement(_ButtonBase.default, _extends({
|
|
133
|
+
disabled: disabled,
|
|
134
|
+
onPress: handlePress,
|
|
135
|
+
style: buttonBaseStyle,
|
|
136
|
+
pressEffect: modifiedPressEffect
|
|
137
|
+
}, otherProps), startIcon, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
138
|
+
children: children,
|
|
139
|
+
style: textStyle
|
|
140
|
+
}), endIcon);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
;
|
|
144
|
+
//# sourceMappingURL=LegacyButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["iconSizes","small","medium","styles","StyleSheet","create","root","flexDirection","justifyContent","alignItems","fullWidth","width","minWidth","height","Button","props","children","clipHorizontalSpacing","color","disabled","endIcon","endIconProp","href","onPress","pressEffect","size","startIcon","startIconProp","style","styleProp","variant","otherProps","theme","useTheme","mainColor","palette","main","fontColor","contrastTextColor","variantStyleMap","contained","backgroundColor","outlined","borderColor","borderStyle","borderWidth","text","iconProps","fill","cloneElementSafely","paddingSize","spacing","paddingLeft","paddingRight","borderRadius","shape","roundnessLarge","buttonBaseStyle","css","undefined","fontStyle","createFontStyle","selector","typo","button2","button1","textMarginSize","textMarginStyle","marginLeft","marginRight","textStyle","textAlign","modifiedPressEffect","handlePress","Linking","canOpenURL","openURL"],"sources":["LegacyButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Linking, Text } from 'react-native';\nimport ButtonBase from '../ButtonBase';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { cloneElementSafely } from '../utils';\nimport type ButtonProps from './LegacyButtonProps';\nimport type { ButtonSize } from './LegacyButtonProps';\n\ntype IconSizes = { [n in ButtonSize]: number };\n\nconst iconSizes: IconSizes = {\n small: 20,\n medium: 24,\n};\n\nconst styles = StyleSheet.create({\n root: {\n flexDirection: 'row',\n justifyContent: 'center',\n alignItems: 'center',\n },\n fullWidth: {\n width: '100%',\n },\n medium: {\n minWidth: 104,\n height: 48,\n },\n small: {\n minWidth: 56,\n height: 32,\n },\n});\n\nexport default function Button(props: ButtonProps) {\n const {\n children,\n clipHorizontalSpacing = false,\n color = 'primary',\n disabled = false,\n endIcon: endIconProp,\n fullWidth = false,\n href,\n onPress,\n pressEffect,\n size = 'medium',\n startIcon: startIconProp,\n style: styleProp,\n variant = 'contained',\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const mainColor = theme.palette[color].main;\n\n const fontColor = variant === 'contained'\n ? theme.palette[color].contrastTextColor\n : theme.palette[color].main;\n\n const variantStyleMap = {\n contained: {\n backgroundColor: mainColor,\n },\n outlined: {\n backgroundColor: 'transparent',\n borderColor: mainColor,\n borderStyle: 'solid',\n borderWidth: 1,\n },\n text: {\n backgroundColor: 'transparent',\n },\n };\n\n const iconProps = {\n width: iconSizes[size],\n height: iconSizes[size],\n fill: fontColor,\n };\n\n const startIcon = cloneElementSafely(startIconProp, iconProps);\n const endIcon = cloneElementSafely(endIconProp, iconProps);\n\n const paddingSize = size === 'small' ? theme.spacing(3) : theme.spacing(4);\n const paddingLeft = startIcon ? paddingSize - theme.spacing(1) : paddingSize;\n const paddingRight = endIcon ? paddingSize - theme.spacing(1) : paddingSize;\n\n const borderRadius = theme.shape.roundnessLarge;\n const buttonBaseStyle = css([\n styles.root,\n variantStyleMap[variant],\n size === 'medium' ? styles.medium : styles.small,\n fullWidth ? styles.fullWidth : undefined,\n { borderRadius, color: fontColor },\n (variant === 'text' && clipHorizontalSpacing)\n ? { minWidth: 0 }\n : { paddingLeft, paddingRight },\n styleProp,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => size === 'small' ? typo.button2 : typo.button1,\n color: fontColor,\n });\n\n const textMarginSize = size === 'small' ? theme.spacing(1) : theme.spacing(2);\n const textMarginStyle = startIcon\n ? { marginLeft: textMarginSize }\n : endIcon\n ? { marginRight: textMarginSize }\n : undefined;\n\n const textStyle = css([\n fontStyle,\n textMarginStyle,\n { textAlign: 'center' },\n ]);\n\n const modifiedPressEffect = variant !== 'text' && !pressEffect\n ? 'scale'\n : pressEffect;\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n if (href) {\n if (await Linking.canOpenURL(href)) {\n await Linking.openURL(href);\n }\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={buttonBaseStyle}\n pressEffect={modifiedPressEffect}\n {...otherProps}\n >\n {startIcon}\n\n <Text\n children={children}\n style={textStyle}\n />\n\n {endIcon}\n </ButtonBase>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMA,MAAMA,SAAoB,GAAG;EACzBC,KAAK,EAAE,EADkB;EAEzBC,MAAM,EAAE;AAFiB,CAA7B;;AAKA,MAAMC,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IACFC,aAAa,EAAE,KADb;IAEFC,cAAc,EAAE,QAFd;IAGFC,UAAU,EAAE;EAHV,CADuB;EAM7BC,SAAS,EAAE;IACPC,KAAK,EAAE;EADA,CANkB;EAS7BT,MAAM,EAAE;IACJU,QAAQ,EAAE,GADN;IAEJC,MAAM,EAAE;EAFJ,CATqB;EAa7BZ,KAAK,EAAE;IACHW,QAAQ,EAAE,EADP;IAEHC,MAAM,EAAE;EAFL;AAbsB,CAAlB,CAAf;;AAmBe,SAASC,MAAT,CAAgBC,KAAhB,EAAoC;EAC/C,MAAM;IACFC,QADE;IAEFC,qBAAqB,GAAG,KAFtB;IAGFC,KAAK,GAAG,SAHN;IAIFC,QAAQ,GAAG,KAJT;IAKFC,OAAO,EAAEC,WALP;IAMF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AClBE,SADkB,EAElBO,eAFkB,EAGlB;IAAEI,SAAS,EAAE;EAAb,CAHkB,CAAJ,CAAlB;EAMA,MAAMC,mBAAmB,GAAG1C,OAAO,KAAK,MAAZ,IAAsB,CAACN,WAAvB,GACtB,OADsB,GAEtBA,WAFN;;EAIA,MAAMiD,WAAW,GAAG,YAAY;IAC5B,IAAItD,QAAJ,EAAc;MACV;IACH;;IACD,IAAII,OAAJ,EAAa;MACTA,OAAO;MACP;IACH;;IACD,IAAID,IAAJ,EAAU;MACN,IAAI,MAAMoD,oBAAA,CAAQC,UAAR,CAAmBrD,IAAnB,CAAV,EAAoC;QAChC,MAAMoD,oBAAA,CAAQE,OAAR,CAAgBtD,IAAhB,CAAN;MACH;IACJ;EACJ,CAbD;;EAeA,oBACI,6BAAC,mBAAD;IACI,QAAQ,EAAEH,QADd;IAEI,OAAO,EAAEsD,WAFb;IAGI,KAAK,EAAEhB,eAHX;IAII,WAAW,EAAEe;EAJjB,GAKQzC,UALR,GAOKL,SAPL,eASI,6BAAC,iBAAD;IACI,QAAQ,EAAEV,QADd;IAEI,KAAK,EAAEsD;EAFX,EATJ,EAcKlD,OAdL,CADJ;AAkBH;;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["LegacyButtonProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ButtonBaseProps } from '../ButtonBase';\nimport type { OverridableComponentProps, CommonComponentColor } from '../types';\n\nexport type ButtonColor = CommonComponentColor;\n\nexport type ButtonSize = 'small' | 'medium';\n\nexport type ButtonVariant = 'contained' | 'outlined' | 'text';\n\nexport default interface ButtonProps extends OverridableComponentProps<ButtonBaseProps, {\n /**\n * The content of the button.\n */\n children: string;\n\n /**\n * If `true`, remove horizontal padding and minimum width.\n * This prop only applied on `text` variant.\n * @default false\n */\n clipHorizontalSpacing?: boolean;\n\n /**\n * The color of the component. It supports those theme colors that make sense for this component.\n * @default 'primary'\n */\n color?: ButtonColor;\n\n /**\n * Element placed after the children.\n */\n endIcon?: React.ReactElement;\n\n /**\n * If `true`, the button will take up the full width of its container.\n * @default false\n */\n fullWidth?: boolean;\n\n /**\n * The URL to link to when the button is clicked.\n */\n href?: string;\n\n /**\n * The size of the button.\n * @default 'medium'\n */\n size?: ButtonSize;\n\n /**\n * Element placed before the children.\n */\n startIcon?: React.ReactElement;\n\n /**\n * The variant to use.\n * @default 'contained'\n */\n variant?: ButtonVariant;\n}> {}\n"],"mappings":""}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _LegacyButton.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _LegacyButton = _interopRequireDefault(require("./LegacyButton"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './LegacyButton';\nexport type { default as ButtonProps } from './LegacyButtonProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useVariantStyleMap;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _styles = require("@fountain-ui/styles");
|
|
11
|
+
|
|
12
|
+
var _styles2 = require("../styles");
|
|
13
|
+
|
|
14
|
+
function useVariantStyleMap(variant, color) {
|
|
15
|
+
const theme = (0, _styles2.useTheme)();
|
|
16
|
+
return (0, _react.useMemo)(() => {
|
|
17
|
+
const {
|
|
18
|
+
palette
|
|
19
|
+
} = theme;
|
|
20
|
+
const variantStyleMap = {
|
|
21
|
+
solid: {
|
|
22
|
+
accent: {
|
|
23
|
+
fillColor: palette.fill.accent,
|
|
24
|
+
labelColor: _styles.commonColors.static.strongInverse,
|
|
25
|
+
iconColor: _styles.commonColors.static.strongInverse
|
|
26
|
+
},
|
|
27
|
+
primary: {
|
|
28
|
+
fillColor: palette.fill.base,
|
|
29
|
+
labelColor: palette.text.strongInverse,
|
|
30
|
+
iconColor: palette.icon.strongInverse
|
|
31
|
+
},
|
|
32
|
+
danger: {
|
|
33
|
+
fillColor: palette.status.danger,
|
|
34
|
+
labelColor: _styles.commonColors.static.strongInverse,
|
|
35
|
+
iconColor: _styles.commonColors.static.strongInverse
|
|
36
|
+
},
|
|
37
|
+
disabled: {
|
|
38
|
+
fillColor: palette.status.disabled,
|
|
39
|
+
labelColor: palette.status.onDisabled,
|
|
40
|
+
iconColor: palette.status.onDisabled
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
outlined: {
|
|
44
|
+
accent: {
|
|
45
|
+
borderColor: palette.border.accent,
|
|
46
|
+
labelColor: palette.text.accent,
|
|
47
|
+
iconColor: palette.icon.accent
|
|
48
|
+
},
|
|
49
|
+
primary: {
|
|
50
|
+
borderColor: palette.border.base,
|
|
51
|
+
labelColor: palette.text.base,
|
|
52
|
+
iconColor: palette.icon.base
|
|
53
|
+
},
|
|
54
|
+
disabled: {
|
|
55
|
+
borderColor: palette.status.disabled,
|
|
56
|
+
labelColor: palette.status.disabledLabel,
|
|
57
|
+
iconColor: palette.status.disabledLabel
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
text: {
|
|
61
|
+
primary: {
|
|
62
|
+
labelColor: palette.text.strong,
|
|
63
|
+
iconColor: palette.icon.strong
|
|
64
|
+
},
|
|
65
|
+
secondary: {
|
|
66
|
+
labelColor: palette.text.base,
|
|
67
|
+
iconColor: palette.icon.base
|
|
68
|
+
},
|
|
69
|
+
accent: {
|
|
70
|
+
labelColor: palette.text.accent,
|
|
71
|
+
iconColor: palette.icon.accent
|
|
72
|
+
},
|
|
73
|
+
accentAlt: {
|
|
74
|
+
labelColor: palette.text.accentAlt,
|
|
75
|
+
iconColor: palette.icon.accentAlt
|
|
76
|
+
},
|
|
77
|
+
disabled: {
|
|
78
|
+
labelColor: palette.status.disabledLabel,
|
|
79
|
+
iconColor: palette.status.disabledLabel
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (variantStyleMap[variant][color]) {
|
|
85
|
+
return variantStyleMap[variant][color];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
89
|
+
console.warn('The selected color is not supported for the chosen variant.');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {};
|
|
93
|
+
}, [theme, variant, color]);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=useVariantStyleMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useVariantStyleMap","variant","color","theme","useTheme","useMemo","palette","variantStyleMap","solid","accent","fillColor","fill","labelColor","commonColors","static","strongInverse","iconColor","primary","base","text","icon","danger","status","disabled","onDisabled","outlined","borderColor","border","disabledLabel","strong","secondary","accentAlt","process","env","NODE_ENV","console","warn"],"sources":["useVariantStyleMap.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { commonColors } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport { ButtonColor, ButtonVariant } from './ButtonProps';\n\ntype UseVariantStyleMapReturns = {\n borderColor?: string;\n fillColor?: string;\n iconColor?: string;\n labelColor?: string;\n}\n\ntype VariantStyleMap = {\n [variant in ButtonVariant]: {\n [color in ButtonColor]?: UseVariantStyleMapReturns;\n }\n};\n\nexport default function useVariantStyleMap(variant: ButtonVariant, color: ButtonColor): UseVariantStyleMapReturns {\n const theme = useTheme();\n\n return useMemo(() => {\n const { palette } = theme;\n\n const variantStyleMap: VariantStyleMap = {\n solid: {\n accent: {\n fillColor: palette.fill.accent,\n labelColor: commonColors.static.strongInverse,\n iconColor: commonColors.static.strongInverse,\n },\n primary: {\n fillColor: palette.fill.base,\n labelColor: palette.text.strongInverse,\n iconColor: palette.icon.strongInverse,\n },\n danger: {\n fillColor: palette.status.danger,\n labelColor: commonColors.static.strongInverse,\n iconColor: commonColors.static.strongInverse,\n },\n disabled: {\n fillColor: palette.status.disabled,\n labelColor: palette.status.onDisabled,\n iconColor: palette.status.onDisabled,\n },\n },\n outlined: {\n accent: {\n borderColor: palette.border.accent,\n labelColor: palette.text.accent,\n iconColor: palette.icon.accent,\n },\n primary: {\n borderColor: palette.border.base,\n labelColor: palette.text.base,\n iconColor: palette.icon.base,\n },\n disabled: {\n borderColor: palette.status.disabled,\n labelColor: palette.status.disabledLabel,\n iconColor: palette.status.disabledLabel,\n },\n },\n text: {\n primary: {\n labelColor: palette.text.strong,\n iconColor: palette.icon.strong,\n },\n secondary: {\n labelColor: palette.text.base,\n iconColor: palette.icon.base,\n },\n accent: {\n labelColor: palette.text.accent,\n iconColor: palette.icon.accent,\n },\n accentAlt: {\n labelColor: palette.text.accentAlt,\n iconColor: palette.icon.accentAlt,\n },\n disabled: {\n labelColor: palette.status.disabledLabel,\n iconColor: palette.status.disabledLabel,\n },\n },\n };\n\n if (variantStyleMap[variant][color]) {\n return variantStyleMap[variant][color] as UseVariantStyleMapReturns;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n console.warn('The selected color is not supported for the chosen variant.');\n }\n\n return {};\n }, [theme, variant, color]);\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAgBe,SAASA,kBAAT,CAA4BC,OAA5B,EAAoDC,KAApD,EAAmG;EAC9G,MAAMC,KAAK,GAAG,IAAAC,iBAAA,GAAd;EAEA,OAAO,IAAAC,cAAA,EAAQ,MAAM;IACjB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@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ButtonSet;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
|
|
14
|
+
var _useVariantStyleMap = _interopRequireDefault(require("./useVariantStyleMap"));
|
|
15
|
+
|
|
16
|
+
var _styles = require("../styles");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
+
|
|
26
|
+
function ButtonSet(props) {
|
|
27
|
+
const {
|
|
28
|
+
children,
|
|
29
|
+
color = 'accent',
|
|
30
|
+
variant = 'horizontal',
|
|
31
|
+
style: styleProp,
|
|
32
|
+
...otherProps
|
|
33
|
+
} = props;
|
|
34
|
+
const {
|
|
35
|
+
containerStyle,
|
|
36
|
+
buttonStyleMap
|
|
37
|
+
} = (0, _useVariantStyleMap.default)(variant, color);
|
|
38
|
+
|
|
39
|
+
const buttons = _react.Children.map(children, (child, index) => {
|
|
40
|
+
const props = { ...buttonStyleMap[index],
|
|
41
|
+
...(variant === 'horizontal' ? {
|
|
42
|
+
style: {
|
|
43
|
+
flex: 1
|
|
44
|
+
}
|
|
45
|
+
} : {})
|
|
46
|
+
};
|
|
47
|
+
return (0, _utils.cloneElementSafely)(child, props);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({}, otherProps, {
|
|
51
|
+
style: (0, _styles.css)([containerStyle, styleProp])
|
|
52
|
+
}), buttons);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=ButtonSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ButtonSet","props","children","color","variant","style","styleProp","otherProps","containerStyle","buttonStyleMap","useVariantStyleMap","buttons","Children","map","child","index","flex","cloneElementSafely","css"],"sources":["ButtonSet.tsx"],"sourcesContent":["import React, { Children } from 'react';\nimport { View } from 'react-native';\nimport type { FalsyReactElement } from '../utils';\nimport { cloneElementSafely } from '../utils';\nimport type ButtonSetProps from './ButtonSetProps';\nimport type { ButtonSetColor, ButtonSetVariant } from './ButtonSetProps';\nimport useVariantStyleMap from './useVariantStyleMap';\nimport { css } from '../styles';\n\nexport default function ButtonSet(props: ButtonSetProps) {\n const {\n children,\n color = 'accent' as ButtonSetColor,\n variant = 'horizontal' as ButtonSetVariant,\n style: styleProp,\n ...otherProps\n } = props;\n\n const {\n containerStyle,\n buttonStyleMap,\n } = useVariantStyleMap(variant, color);\n\n const buttons = Children.map(children, (child, index) => {\n const props = {\n ...buttonStyleMap[index],\n ...(variant === 'horizontal' ? { style: { flex: 1 } } : {}),\n };\n return cloneElementSafely(child as FalsyReactElement, props);\n });\n\n return (\n <View\n {...otherProps}\n style={css([\n containerStyle,\n styleProp,\n ])}\n >\n {buttons}\n </View>\n );\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAGA;;AACA;;;;;;;;;;AAEe,SAASA,SAAT,CAAmBC,KAAnB,EAA0C;EACrD,MAAM;IACFC,QADE;IAEFC,KAAK,GAAG,QAFN;IAGFC,OAAO,GAAG,YAHR;IAIFC,KAAK,EAAEC,SAJL;IAKF,GAAGC;EALD,IAMFN,KANJ;EAQA,MAAM;IACFO,cADE;IAEFC;EAFE,IAGF,IAAAC,2BAAA,EAAmBN,OAAnB,EAA4BD,KAA5B,CAHJ;;EAKA,MAAMQ,OAAO,GAAGC,eAAA,CAASC,GAAT,CAAaX,QAAb,EAAuB,CAACY,KAAD,EAAQC,KAAR,KAAkB;IACrD,MAAMd,KAAK,GAAG,EACV,GAAGQ,cAAc,CAACM,KAAD,CADP;MAEV,IAAIX,OAAO,KAAK,YAAZ,GAA2B;QAAEC,KAAK,EAAE;UAAEW,IAAI,EAAE;QAAR;MAAT,CAA3B,GAAoD,EAAxD;IAFU,CAAd;IAIA,OAAO,IAAAC,yBAAA,EAAmBH,KAAnB,EAA+Cb,KAA/C,CAAP;EACH,CANe,CAAhB;;EAQA,oBACI,6BAAC,iBAAD,eACQM,UADR;IAEI,KAAK,EAAE,IAAAW,WAAA,EAAI,CACPV,cADO,EAEPF,SAFO,CAAJ;EAFX,IAOKK,OAPL,CADJ;AAWH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buttonSetVariants = exports.buttonSetColors = void 0;
|
|
7
|
+
const buttonSetColors = ['accent', 'danger', 'warning'];
|
|
8
|
+
exports.buttonSetColors = buttonSetColors;
|
|
9
|
+
const buttonSetVariants = ['horizontal', 'vertical'];
|
|
10
|
+
exports.buttonSetVariants = buttonSetVariants;
|
|
11
|
+
//# sourceMappingURL=ButtonSetProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["buttonSetColors","buttonSetVariants"],"sources":["ButtonSetProps.ts"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\n\nexport const buttonSetColors = [\n 'accent',\n 'danger',\n 'warning',\n] as const;\nexport type ButtonSetColor = typeof buttonSetColors[number];\n\nexport const buttonSetVariants = ['horizontal', 'vertical'] as const;\nexport type ButtonSetVariant = typeof buttonSetVariants[number];\n\nexport default interface ButtonSetProps extends OverridableComponentProps<PropsWithChildren<ViewProps>, {\n /**\n * Determines the base color of the button set that goes inside.\n * @default 'accent'\n */\n color?: ButtonSetColor;\n\n /**\n * Determines design variations of the component.\n * @default 'horizontal'\n */\n variant?: ButtonSetVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,eAAe,GAAG,CAC3B,QAD2B,EAE3B,QAF2B,EAG3B,SAH2B,CAAxB;;AAOA,MAAMC,iBAAiB,GAAG,CAAC,YAAD,EAAe,UAAf,CAA1B"}
|