@fluixi-css/core 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/base.css +4 -0
- package/components.css +1 -0
- package/dist/base.css +4 -0
- package/dist/components.css +1 -0
- package/dist/index.css +2 -0
- package/dist/package.json +139 -0
- package/dist/reset.css +168 -0
- package/dist/src/ast.d.ts +298 -0
- package/dist/src/ast.js +2240 -0
- package/dist/src/ast.js.map +1 -0
- package/dist/src/commons/constants.d.ts +1193 -0
- package/dist/src/commons/constants.js +1323 -0
- package/dist/src/commons/constants.js.map +1 -0
- package/dist/src/commons/helper.d.ts +1298 -0
- package/dist/src/commons/helper.js +1310 -0
- package/dist/src/commons/helper.js.map +1 -0
- package/dist/src/commons/index.d.ts +3 -0
- package/dist/src/commons/index.js +4 -0
- package/dist/src/commons/index.js.map +1 -0
- package/dist/src/commons/properties.d.ts +1431 -0
- package/dist/src/commons/properties.js +2855 -0
- package/dist/src/commons/properties.js.map +1 -0
- package/dist/src/commons/types.d.ts +359 -0
- package/dist/src/commons/types.js +4 -0
- package/dist/src/commons/types.js.map +1 -0
- package/dist/src/components/avatar/index.d.ts +19 -0
- package/dist/src/components/avatar/index.js +22 -0
- package/dist/src/components/avatar/index.js.map +1 -0
- package/dist/src/components/button/index.d.ts +48 -0
- package/dist/src/components/button/index.js +51 -0
- package/dist/src/components/button/index.js.map +1 -0
- package/dist/src/components/card/index.d.ts +44 -0
- package/dist/src/components/card/index.js +47 -0
- package/dist/src/components/card/index.js.map +1 -0
- package/dist/src/components/checkbox/index.d.ts +69 -0
- package/dist/src/components/checkbox/index.js +80 -0
- package/dist/src/components/checkbox/index.js.map +1 -0
- package/dist/src/components/daterangepicker/index.d.ts +147 -0
- package/dist/src/components/daterangepicker/index.js +150 -0
- package/dist/src/components/daterangepicker/index.js.map +1 -0
- package/dist/src/components/dialog/index.d.ts +71 -0
- package/dist/src/components/dialog/index.js +74 -0
- package/dist/src/components/dialog/index.js.map +1 -0
- package/dist/src/components/drawer/index.d.ts +26 -0
- package/dist/src/components/drawer/index.js +29 -0
- package/dist/src/components/drawer/index.js.map +1 -0
- package/dist/src/components/dropdown/index.d.ts +101 -0
- package/dist/src/components/dropdown/index.js +104 -0
- package/dist/src/components/dropdown/index.js.map +1 -0
- package/dist/src/components/forms/index.d.ts +58 -0
- package/dist/src/components/forms/index.js +62 -0
- package/dist/src/components/forms/index.js.map +1 -0
- package/dist/src/components/index.d.ts +1228 -0
- package/dist/src/components/index.js +64 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/layout/index.d.ts +28 -0
- package/dist/src/components/layout/index.js +33 -0
- package/dist/src/components/layout/index.js.map +1 -0
- package/dist/src/components/list/index.d.ts +65 -0
- package/dist/src/components/list/index.js +68 -0
- package/dist/src/components/list/index.js.map +1 -0
- package/dist/src/components/popover/index.d.ts +79 -0
- package/dist/src/components/popover/index.js +82 -0
- package/dist/src/components/popover/index.js.map +1 -0
- package/dist/src/components/radio/index.d.ts +77 -0
- package/dist/src/components/radio/index.js +80 -0
- package/dist/src/components/radio/index.js.map +1 -0
- package/dist/src/components/select/index.d.ts +102 -0
- package/dist/src/components/select/index.js +105 -0
- package/dist/src/components/select/index.js.map +1 -0
- package/dist/src/components/sidenav/index.d.ts +98 -0
- package/dist/src/components/sidenav/index.js +101 -0
- package/dist/src/components/sidenav/index.js.map +1 -0
- package/dist/src/components/table/index.d.ts +95 -0
- package/dist/src/components/table/index.js +98 -0
- package/dist/src/components/table/index.js.map +1 -0
- package/dist/src/constants.d.ts +3 -0
- package/dist/src/constants.js +29 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/css-ast.d.ts +48 -0
- package/dist/src/css-ast.js +2 -0
- package/dist/src/css-ast.js.map +1 -0
- package/dist/src/css-generator.d.ts +29 -0
- package/dist/src/css-generator.js +104 -0
- package/dist/src/css-generator.js.map +1 -0
- package/dist/src/css-helpers.d.ts +76 -0
- package/dist/src/css-helpers.js +272 -0
- package/dist/src/css-helpers.js.map +1 -0
- package/dist/src/css-lexer.d.ts +48 -0
- package/dist/src/css-lexer.js +255 -0
- package/dist/src/css-lexer.js.map +1 -0
- package/dist/src/css-parser.cjs +2047 -0
- package/dist/src/css-parser.cjs.map +1 -0
- package/dist/src/css-parser.d.ts +100 -0
- package/dist/src/css-parser.js +1098 -0
- package/dist/src/css-parser.js.map +1 -0
- package/dist/src/css-parser.mjs +2028 -0
- package/dist/src/css-parser.mjs.map +1 -0
- package/dist/src/design-system.d.ts +210 -0
- package/dist/src/design-system.js +1034 -0
- package/dist/src/design-system.js.map +1 -0
- package/dist/src/engine/ast.d.ts +44 -0
- package/dist/src/engine/ast.js +92 -0
- package/dist/src/engine/ast.js.map +1 -0
- package/dist/src/engine/atom.d.ts +74 -0
- package/dist/src/engine/atom.js +227 -0
- package/dist/src/engine/atom.js.map +1 -0
- package/dist/src/engine/compile.d.ts +5 -0
- package/dist/src/engine/compile.js +79 -0
- package/dist/src/engine/compile.js.map +1 -0
- package/dist/src/engine/defaults.d.ts +2 -0
- package/dist/src/engine/defaults.js +14 -0
- package/dist/src/engine/defaults.js.map +1 -0
- package/dist/src/engine/directives.d.ts +2 -0
- package/dist/src/engine/directives.js +191 -0
- package/dist/src/engine/directives.js.map +1 -0
- package/dist/src/engine/index.d.ts +41 -0
- package/dist/src/engine/index.js +88 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/registry.d.ts +46 -0
- package/dist/src/engine/registry.js +49 -0
- package/dist/src/engine/registry.js.map +1 -0
- package/dist/src/engine/scanner.d.ts +1 -0
- package/dist/src/engine/scanner.js +45 -0
- package/dist/src/engine/scanner.js.map +1 -0
- package/dist/src/engine/source.d.ts +12 -0
- package/dist/src/engine/source.js +81 -0
- package/dist/src/engine/source.js.map +1 -0
- package/dist/src/engine/theme-defaults.d.ts +2 -0
- package/dist/src/engine/theme-defaults.js +54 -0
- package/dist/src/engine/theme-defaults.js.map +1 -0
- package/dist/src/engine/theme-source.d.ts +5 -0
- package/dist/src/engine/theme-source.js +71 -0
- package/dist/src/engine/theme-source.js.map +1 -0
- package/dist/src/engine/theme.d.ts +10 -0
- package/dist/src/engine/theme.js +42 -0
- package/dist/src/engine/theme.js.map +1 -0
- package/dist/src/engine/transform.d.ts +25 -0
- package/dist/src/engine/transform.js +91 -0
- package/dist/src/engine/transform.js.map +1 -0
- package/dist/src/engine/ui-preset.d.ts +4 -0
- package/dist/src/engine/ui-preset.js +56 -0
- package/dist/src/engine/ui-preset.js.map +1 -0
- package/dist/src/engine/utilities/backgrounds.d.ts +2 -0
- package/dist/src/engine/utilities/backgrounds.js +32 -0
- package/dist/src/engine/utilities/backgrounds.js.map +1 -0
- package/dist/src/engine/utilities/borders.d.ts +2 -0
- package/dist/src/engine/utilities/borders.js +95 -0
- package/dist/src/engine/utilities/borders.js.map +1 -0
- package/dist/src/engine/utilities/effects.d.ts +2 -0
- package/dist/src/engine/utilities/effects.js +61 -0
- package/dist/src/engine/utilities/effects.js.map +1 -0
- package/dist/src/engine/utilities/flexgrid.d.ts +2 -0
- package/dist/src/engine/utilities/flexgrid.js +125 -0
- package/dist/src/engine/utilities/flexgrid.js.map +1 -0
- package/dist/src/engine/utilities/index.d.ts +3 -0
- package/dist/src/engine/utilities/index.js +20 -0
- package/dist/src/engine/utilities/index.js.map +1 -0
- package/dist/src/engine/utilities/layout.d.ts +2 -0
- package/dist/src/engine/utilities/layout.js +84 -0
- package/dist/src/engine/utilities/layout.js.map +1 -0
- package/dist/src/engine/utilities/sizing.d.ts +2 -0
- package/dist/src/engine/utilities/sizing.js +21 -0
- package/dist/src/engine/utilities/sizing.js.map +1 -0
- package/dist/src/engine/utilities/spacing.d.ts +2 -0
- package/dist/src/engine/utilities/spacing.js +39 -0
- package/dist/src/engine/utilities/spacing.js.map +1 -0
- package/dist/src/engine/utilities/typography.d.ts +2 -0
- package/dist/src/engine/utilities/typography.js +120 -0
- package/dist/src/engine/utilities/typography.js.map +1 -0
- package/dist/src/engine/utilities/values.d.ts +16 -0
- package/dist/src/engine/utilities/values.js +91 -0
- package/dist/src/engine/utilities/values.js.map +1 -0
- package/dist/src/engine/variants.d.ts +2 -0
- package/dist/src/engine/variants.js +99 -0
- package/dist/src/engine/variants.js.map +1 -0
- package/dist/src/extractor.d.ts +146 -0
- package/dist/src/extractor.js +3862 -0
- package/dist/src/extractor.js.map +1 -0
- package/dist/src/index.cjs +4518 -0
- package/dist/src/index.cjs.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/index.mjs +4480 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/keyframes.cjs +367 -0
- package/dist/src/keyframes.cjs.map +1 -0
- package/dist/src/keyframes.d.ts +27 -0
- package/dist/src/keyframes.js +188 -0
- package/dist/src/keyframes.js.map +1 -0
- package/dist/src/keyframes.mjs +362 -0
- package/dist/src/keyframes.mjs.map +1 -0
- package/dist/src/logger.d.ts +2 -0
- package/dist/src/logger.js +31 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/plugin.cjs +43 -0
- package/dist/src/plugin.cjs.map +1 -0
- package/dist/src/plugin.d.ts +12 -0
- package/dist/src/plugin.js +39 -0
- package/dist/src/plugin.js.map +1 -0
- package/dist/src/plugin.mjs +41 -0
- package/dist/src/plugin.mjs.map +1 -0
- package/dist/src/presets-plugins.cjs +99 -0
- package/dist/src/presets-plugins.cjs.map +1 -0
- package/dist/src/presets-plugins.d.ts +1 -0
- package/dist/src/presets-plugins.js +56 -0
- package/dist/src/presets-plugins.js.map +1 -0
- package/dist/src/presets-plugins.mjs +97 -0
- package/dist/src/presets-plugins.mjs.map +1 -0
- package/dist/src/state.d.ts +76 -0
- package/dist/src/state.js +314 -0
- package/dist/src/state.js.map +1 -0
- package/dist/src/theme/constants.d.ts +22 -0
- package/dist/src/theme/constants.js +17 -0
- package/dist/src/theme/constants.js.map +1 -0
- package/dist/src/theme/index.d.ts +2 -0
- package/dist/src/theme/index.js +48 -0
- package/dist/src/theme/index.js.map +1 -0
- package/dist/src/theme/types.d.ts +13 -0
- package/dist/src/theme/types.js +2 -0
- package/dist/src/theme/types.js.map +1 -0
- package/dist/src/types/ast.d.ts +23 -0
- package/dist/src/types/ast.js +2 -0
- package/dist/src/types/ast.js.map +1 -0
- package/dist/src/types/base-types.d.ts +53 -0
- package/dist/src/types/base-types.js +2 -0
- package/dist/src/types/base-types.js.map +1 -0
- package/dist/src/types/components-types.d.ts +28 -0
- package/dist/src/types/components-types.js +2 -0
- package/dist/src/types/components-types.js.map +1 -0
- package/dist/src/types/config.d.ts +90 -0
- package/dist/src/types/config.js +3 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/css-parser.d.ts +361 -0
- package/dist/src/types/css-parser.js +2 -0
- package/dist/src/types/css-parser.js.map +1 -0
- package/dist/src/types/keyframes-type.d.ts +47 -0
- package/dist/src/types/keyframes-type.js +2 -0
- package/dist/src/types/keyframes-type.js.map +1 -0
- package/dist/src/types/plugin.d.ts +10 -0
- package/dist/src/types/plugin.js +2 -0
- package/dist/src/types/plugin.js.map +1 -0
- package/dist/src/types/screens-types.d.ts +47 -0
- package/dist/src/types/screens-types.js +2 -0
- package/dist/src/types/screens-types.js.map +1 -0
- package/dist/src/types/utilities-types.d.ts +147 -0
- package/dist/src/types/utilities-types.js +2 -0
- package/dist/src/types/utilities-types.js.map +1 -0
- package/dist/src/types.d.ts +77 -0
- package/dist/src/types.js +12 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/units/constants.d.ts +35 -0
- package/dist/src/units/constants.js +9 -0
- package/dist/src/units/constants.js.map +1 -0
- package/dist/src/units/index.d.ts +15 -0
- package/dist/src/units/index.js +7 -0
- package/dist/src/units/index.js.map +1 -0
- package/dist/src/units/types.d.ts +9 -0
- package/dist/src/units/types.js +2 -0
- package/dist/src/units/types.js.map +1 -0
- package/dist/src/utilities/backgrounds/constants.d.ts +2810 -0
- package/dist/src/utilities/backgrounds/constants.js +119 -0
- package/dist/src/utilities/backgrounds/constants.js.map +1 -0
- package/dist/src/utilities/backgrounds/index.d.ts +1 -0
- package/dist/src/utilities/backgrounds/index.js +2 -0
- package/dist/src/utilities/backgrounds/index.js.map +1 -0
- package/dist/src/utilities/borders/constants.d.ts +10586 -0
- package/dist/src/utilities/borders/constants.js +309 -0
- package/dist/src/utilities/borders/constants.js.map +1 -0
- package/dist/src/utilities/borders/index.d.ts +1 -0
- package/dist/src/utilities/borders/index.js +2 -0
- package/dist/src/utilities/borders/index.js.map +1 -0
- package/dist/src/utilities/breakpoints/constants.d.ts +330 -0
- package/dist/src/utilities/breakpoints/constants.js +269 -0
- package/dist/src/utilities/breakpoints/constants.js.map +1 -0
- package/dist/src/utilities/breakpoints/index.d.ts +2 -0
- package/dist/src/utilities/breakpoints/index.js +3 -0
- package/dist/src/utilities/breakpoints/index.js.map +1 -0
- package/dist/src/utilities/breakpoints/types.d.ts +8 -0
- package/dist/src/utilities/breakpoints/types.js +2 -0
- package/dist/src/utilities/breakpoints/types.js.map +1 -0
- package/dist/src/utilities/colors/base.d.ts +778 -0
- package/dist/src/utilities/colors/base.js +872 -0
- package/dist/src/utilities/colors/base.js.map +1 -0
- package/dist/src/utilities/colors/color.d.ts +1122 -0
- package/dist/src/utilities/colors/color.js +957 -0
- package/dist/src/utilities/colors/color.js.map +1 -0
- package/dist/src/utilities/colors/constants.d.ts +1 -0
- package/dist/src/utilities/colors/constants.js +2 -0
- package/dist/src/utilities/colors/constants.js.map +1 -0
- package/dist/src/utilities/colors/index.d.ts +4 -0
- package/dist/src/utilities/colors/index.js +29 -0
- package/dist/src/utilities/colors/index.js.map +1 -0
- package/dist/src/utilities/colors/types.d.ts +3 -0
- package/dist/src/utilities/colors/types.js +2 -0
- package/dist/src/utilities/colors/types.js.map +1 -0
- package/dist/src/utilities/effects/constants.d.ts +641 -0
- package/dist/src/utilities/effects/constants.js +83 -0
- package/dist/src/utilities/effects/constants.js.map +1 -0
- package/dist/src/utilities/effects/index.d.ts +1 -0
- package/dist/src/utilities/effects/index.js +2 -0
- package/dist/src/utilities/effects/index.js.map +1 -0
- package/dist/src/utilities/filters/constants.d.ts +406 -0
- package/dist/src/utilities/filters/constants.js +206 -0
- package/dist/src/utilities/filters/constants.js.map +1 -0
- package/dist/src/utilities/filters/index.d.ts +1 -0
- package/dist/src/utilities/filters/index.js +2 -0
- package/dist/src/utilities/filters/index.js.map +1 -0
- package/dist/src/utilities/flex/constants.d.ts +934 -0
- package/dist/src/utilities/flex/constants.js +221 -0
- package/dist/src/utilities/flex/constants.js.map +1 -0
- package/dist/src/utilities/flex/index.d.ts +1 -0
- package/dist/src/utilities/flex/index.js +2 -0
- package/dist/src/utilities/flex/index.js.map +1 -0
- package/dist/src/utilities/flex/types.d.ts +0 -0
- package/dist/src/utilities/flex/types.js +4 -0
- package/dist/src/utilities/flex/types.js.map +1 -0
- package/dist/src/utilities/index.d.ts +31338 -0
- package/dist/src/utilities/index.js +333 -0
- package/dist/src/utilities/index.js.map +1 -0
- package/dist/src/utilities/interactivity/constants.d.ts +1244 -0
- package/dist/src/utilities/interactivity/constants.js +165 -0
- package/dist/src/utilities/interactivity/constants.js.map +1 -0
- package/dist/src/utilities/interactivity/index.d.ts +1 -0
- package/dist/src/utilities/interactivity/index.js +2 -0
- package/dist/src/utilities/interactivity/index.js.map +1 -0
- package/dist/src/utilities/layout/constants.d.ts +837 -0
- package/dist/src/utilities/layout/constants.js +159 -0
- package/dist/src/utilities/layout/constants.js.map +1 -0
- package/dist/src/utilities/layout/index.d.ts +1 -0
- package/dist/src/utilities/layout/index.js +2 -0
- package/dist/src/utilities/layout/index.js.map +1 -0
- package/dist/src/utilities/layout/types.d.ts +0 -0
- package/dist/src/utilities/layout/types.js +2 -0
- package/dist/src/utilities/layout/types.js.map +1 -0
- package/dist/src/utilities/sizing/constants.d.ts +989 -0
- package/dist/src/utilities/sizing/constants.js +53 -0
- package/dist/src/utilities/sizing/constants.js.map +1 -0
- package/dist/src/utilities/sizing/index.d.ts +2 -0
- package/dist/src/utilities/sizing/index.js +3 -0
- package/dist/src/utilities/sizing/index.js.map +1 -0
- package/dist/src/utilities/sizing/types.d.ts +10 -0
- package/dist/src/utilities/sizing/types.js +2 -0
- package/dist/src/utilities/sizing/types.js.map +1 -0
- package/dist/src/utilities/spacing/constants.d.ts +1779 -0
- package/dist/src/utilities/spacing/constants.js +142 -0
- package/dist/src/utilities/spacing/constants.js.map +1 -0
- package/dist/src/utilities/spacing/index.d.ts +2 -0
- package/dist/src/utilities/spacing/index.js +3 -0
- package/dist/src/utilities/spacing/index.js.map +1 -0
- package/dist/src/utilities/spacing/types.d.ts +15 -0
- package/dist/src/utilities/spacing/types.js +8 -0
- package/dist/src/utilities/spacing/types.js.map +1 -0
- package/dist/src/utilities/svg/constants.d.ts +1062 -0
- package/dist/src/utilities/svg/constants.js +34 -0
- package/dist/src/utilities/svg/constants.js.map +1 -0
- package/dist/src/utilities/transforms/constants.d.ts +247 -0
- package/dist/src/utilities/transforms/constants.js +74 -0
- package/dist/src/utilities/transforms/constants.js.map +1 -0
- package/dist/src/utilities/transforms/index.d.ts +1 -0
- package/dist/src/utilities/transforms/index.js +2 -0
- package/dist/src/utilities/transforms/index.js.map +1 -0
- package/dist/src/utilities/transitions/constants.d.ts +116 -0
- package/dist/src/utilities/transitions/constants.js +91 -0
- package/dist/src/utilities/transitions/constants.js.map +1 -0
- package/dist/src/utilities/transitions/index.d.ts +1 -0
- package/dist/src/utilities/transitions/index.js +2 -0
- package/dist/src/utilities/transitions/index.js.map +1 -0
- package/dist/src/utilities/typography/constants.d.ts +2401 -0
- package/dist/src/utilities/typography/constants.js +401 -0
- package/dist/src/utilities/typography/constants.js.map +1 -0
- package/dist/src/utilities/typography/index.d.ts +1 -0
- package/dist/src/utilities/typography/index.js +2 -0
- package/dist/src/utilities/typography/index.js.map +1 -0
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.js +282 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/watcher.d.ts +15 -0
- package/dist/src/watcher.js +62 -0
- package/dist/src/watcher.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utilities.css +1 -0
- package/index.css +2 -0
- package/package.json +139 -0
- package/reset.css +168 -0
- package/utilities.css +1 -0
|
@@ -0,0 +1,1310 @@
|
|
|
1
|
+
import { AutoMap, FullMap, GradientKeyMap, MinMaxFitMap, ScreenRemMap, ScreenVwMap, VhMap, VhVariantsMap, VwMap, VwVariantsMap, HTML_COLORS, StylePatterns } from "./constants.js";
|
|
2
|
+
/**
|
|
3
|
+
* The bool function is a helper function that returns the value of a boolean or
|
|
4
|
+
* if it's undefined, null, or not a boolean then it will return the defaultValue.
|
|
5
|
+
*
|
|
6
|
+
*
|
|
7
|
+
* @param value: boolean Check the type of value
|
|
8
|
+
* @param defaultValue: boolean Set a default value if the value is undefined or null
|
|
9
|
+
*
|
|
10
|
+
* @return A boolean value
|
|
11
|
+
*
|
|
12
|
+
* @docauthor Ibrahima Touré
|
|
13
|
+
*/
|
|
14
|
+
export const bool = (value, defaultValue = false) => {
|
|
15
|
+
if (typeof value === 'undefined' || value === null) {
|
|
16
|
+
return defaultValue;
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
export const toCamelCase = (_text) => {
|
|
21
|
+
let text = _text;
|
|
22
|
+
if (typeof text === "undefined") {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
if (isInt(text)) {
|
|
26
|
+
return text.toString();
|
|
27
|
+
}
|
|
28
|
+
text = text.toString();
|
|
29
|
+
if (isCapitalized(text)) {
|
|
30
|
+
return text.toLowerCase();
|
|
31
|
+
}
|
|
32
|
+
const reg = new RegExp(`((-|_)\\w)`, 'g');
|
|
33
|
+
return text.replace(reg, clearAndUpper);
|
|
34
|
+
};
|
|
35
|
+
export const isCapitalized = (str) => {
|
|
36
|
+
if (isInt(str)) {
|
|
37
|
+
return str;
|
|
38
|
+
}
|
|
39
|
+
if (typeof str === "undefined") {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return str === str.charAt(0).toUpperCase() + str.slice(1);
|
|
43
|
+
};
|
|
44
|
+
export const endsWithSpace = (str) => {
|
|
45
|
+
return /\s$/.test(str);
|
|
46
|
+
};
|
|
47
|
+
export const startsWithSpace = (str) => {
|
|
48
|
+
// return /^\s/.test(str);
|
|
49
|
+
return str.startsWith(' ');
|
|
50
|
+
};
|
|
51
|
+
export const TAG_DYNAMIC_REGEX = /<(&[^>]+)>/g;
|
|
52
|
+
export const PARENTHESES_DYNAMIC_REGEX = /{([^}]+)}/g;
|
|
53
|
+
export const SPACE_REGEX = "([^\\s\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
54
|
+
export const COLON_REGEX = "([^\:\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
55
|
+
export const DOUBLE_COLON_REGEX = "([^\:\:\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
56
|
+
export const COMMA_REGEX = "([^\,\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
57
|
+
export const TIRET_REGEX = "([^\-\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
58
|
+
export const SLASH_REGEX = "([^\/\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
59
|
+
export const POINT_REGEX = "([^\.\\[\\(\\{\\<]+|\\[.*?\\]|\\(.*?\\)|\\{.*?\\}|\".*?\"|\'.*?\'|\<.*?\>)+";
|
|
60
|
+
export const POINT_SPLIT_REGEX = /\.(?!(([^\[])*\]|\d)|(([^\(])*\)|\d)|(([^\{])*\}|\d)|(([^\<])*\>|\d))/g;
|
|
61
|
+
export const ACCOLADE_SPLIT_REGEX = /(\{[^}]*\})(?!(([^\[])*\]|\d)|(([^\(])*\)|\d)|(([^\{])*\}|\d)|(([^\<])*\>|\d))/g;
|
|
62
|
+
export const PARENTHESES_SPLIT_REGEX = /\([^)]*\)(?!(([^\[])*\]|\d)|(([^\(])*\)|\d)|(([^\{])*\}|\d)|(([^\<])*\>|\d))/g;
|
|
63
|
+
export const splitString = (spaces, regex = SPACE_REGEX, flag = 'g') => {
|
|
64
|
+
const match = spaces.match(new RegExp(regex, flag));
|
|
65
|
+
if (match) {
|
|
66
|
+
return match;
|
|
67
|
+
}
|
|
68
|
+
return regex === SPACE_REGEX ? [] : [spaces];
|
|
69
|
+
};
|
|
70
|
+
export const escapeAll = (classes, escape = true) => {
|
|
71
|
+
const exclude = [' ', '\xa0', '\xa0\xa0', '_space_'];
|
|
72
|
+
if (!escape || exclude.some(c => c === classes)) {
|
|
73
|
+
return classes;
|
|
74
|
+
}
|
|
75
|
+
const specialCharsRegExp = /[*]/g;
|
|
76
|
+
// Replace special characters with their escaped versions
|
|
77
|
+
return classes.replace(specialCharsRegExp, '\\$&');
|
|
78
|
+
};
|
|
79
|
+
export const escapeString = (classes, escape = true) => {
|
|
80
|
+
const exclude = [' ', '\xa0', '\xa0\xa0', '_space_'];
|
|
81
|
+
if (!escape || exclude.some(c => c === classes)) {
|
|
82
|
+
return classes;
|
|
83
|
+
}
|
|
84
|
+
const specialCharsRegExp = /[!"#$%&'()*+,./:;<=>?@\[\]\\^`{|}~]/g;
|
|
85
|
+
// Replace special characters with their escaped versions
|
|
86
|
+
return classes.replace(specialCharsRegExp, '\\$&');
|
|
87
|
+
};
|
|
88
|
+
export const replaceString = (originalString, valueToReplace, start = true, newValue = '') => {
|
|
89
|
+
const startValid = start && originalString && valueToReplace && originalString.startsWith(valueToReplace);
|
|
90
|
+
const endValid = !start && originalString && valueToReplace && originalString.endsWith(valueToReplace);
|
|
91
|
+
if (!startValid && !endValid) {
|
|
92
|
+
return originalString;
|
|
93
|
+
}
|
|
94
|
+
const regex = new RegExp(start ? '^' + escapeString(valueToReplace) : escapeString(valueToReplace) + '$');
|
|
95
|
+
return originalString.replace(regex, newValue);
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The camelToKebab function takes a string and converts it to kebab-case.
|
|
99
|
+
*
|
|
100
|
+
*
|
|
101
|
+
* @param text: string Pass in the string that will be converted to kebab case
|
|
102
|
+
*
|
|
103
|
+
* @return A string that is the same as the input, but with all capital letters replaced by a dash followed by their lowercase equivalent
|
|
104
|
+
*
|
|
105
|
+
* @docauthor Ibrahima Touré
|
|
106
|
+
*/
|
|
107
|
+
export const camelToKebab = (_str, separator = '-') => {
|
|
108
|
+
let str = _str;
|
|
109
|
+
if (isInt(str)) {
|
|
110
|
+
return str;
|
|
111
|
+
}
|
|
112
|
+
// const wordPattern = /([a-z]+|[A-Z][a-z]*|[A-Z]+(?=[A-Z][a-z])|((\d+)(.*?)(?!(?:[xl\|sm\|md\|lg\|xl\|xxl]|[\d\.\d]))))/g;
|
|
113
|
+
const wordPattern = /([a-z]+|[A-Z][a-z]*|[A-Z]+(?=[A-Z][a-z])|((\d+|\[(.*)\]|\/)(.*?)(?!(?:[xl\|sm\|md\|lg\|xl\|xxl]|\/|%|[\d\.\d]))))/g;
|
|
114
|
+
let result = '';
|
|
115
|
+
if (str.startsWith('-') && !str.startsWith('--')) {
|
|
116
|
+
result = `-${result}`;
|
|
117
|
+
str = replaceString(str, '-', true, '');
|
|
118
|
+
}
|
|
119
|
+
else if (str.startsWith('--')) {
|
|
120
|
+
result = `--${result}`;
|
|
121
|
+
str = replaceString(str, '--', true, '');
|
|
122
|
+
}
|
|
123
|
+
// const arr = str.split(separator);
|
|
124
|
+
const words = str.match(wordPattern) || []; // Extract words using regex
|
|
125
|
+
const kebabCase = words.map(word => word.toLowerCase()).join(`${separator}`); // Join words with hyphens
|
|
126
|
+
result += kebabCase.replace(new RegExp(`${separator.repeat(2)}`, 'g'), `\\${separator}`);
|
|
127
|
+
// if(result==='backgroundcolor'){
|
|
128
|
+
// console.log({_str, str, words})
|
|
129
|
+
// }
|
|
130
|
+
// for(const w in arr){
|
|
131
|
+
// }
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
134
|
+
export const unescapeString = (escapedStr) => {
|
|
135
|
+
return escapedStr
|
|
136
|
+
.replace(/\\n/g, '\n') // Replace newline escape
|
|
137
|
+
.replace(/\\t/g, '\t') // Replace tab escape
|
|
138
|
+
.replace(/\\r/g, '\r') // Replace carriage return
|
|
139
|
+
.replace(/\\"/g, '"') // Replace double quote escape
|
|
140
|
+
.replace(/\\'/g, "'") // Replace single quote escape
|
|
141
|
+
.replace(/\\\\/g, '\\') // Replace backslash escape
|
|
142
|
+
.replace(/\\/g, '') // Replace backslash escape
|
|
143
|
+
.replace(/\*/g, '*'); // Replace backslash escape
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The generateRange function takes in a start, stop and step value.
|
|
147
|
+
* It then returns an array of numbers from the start to the stop value with each number being incremented by the step amount.
|
|
148
|
+
* The type parameter is used to determine if you want a string or number returned for each item in the array.
|
|
149
|
+
|
|
150
|
+
*
|
|
151
|
+
* @param start: Min Set the starting point of the range
|
|
152
|
+
* @param stop: Max Set the maximum number of iterations
|
|
153
|
+
* @param step: Step Determine the step size of the iteration
|
|
154
|
+
* @param type: Type Determine the type of the array that is returned
|
|
155
|
+
*
|
|
156
|
+
* @return An array of numbers or strings
|
|
157
|
+
*
|
|
158
|
+
* @docauthor Ibrahima Touré
|
|
159
|
+
*/
|
|
160
|
+
export const generateRange = (start, stop, step, type = 'string') => {
|
|
161
|
+
const arrayData = Array.from({ length: (stop - start) / step + 1 }, (value, index) => start + index * step);
|
|
162
|
+
if (type === 'string') {
|
|
163
|
+
arrayData.flatMap(a => a.toString());
|
|
164
|
+
}
|
|
165
|
+
return arrayData;
|
|
166
|
+
};
|
|
167
|
+
export const PercentPropertyKeys = [
|
|
168
|
+
'1/2', '1/3', '1/4', '1/5', '1/6',
|
|
169
|
+
'2/3', '2/4', '2/5', '2/6',
|
|
170
|
+
'3/4', '3/5', '3/6',
|
|
171
|
+
'4/5', '4/6', '5/6',
|
|
172
|
+
'1/12', '2/12', '2/12', '4/12', '5/12',
|
|
173
|
+
'6/12', '7/12', '8/12', '9/12', '10/12', '11/12'
|
|
174
|
+
];
|
|
175
|
+
export const Pixel = ['px'];
|
|
176
|
+
export const Zero_4 = [
|
|
177
|
+
...generateRange(0, 4, 0.5)
|
|
178
|
+
];
|
|
179
|
+
export const Zero_12 = [
|
|
180
|
+
...generateRange(0, 12, 1)
|
|
181
|
+
];
|
|
182
|
+
export const Five_12 = [
|
|
183
|
+
...generateRange(5, 12, 1),
|
|
184
|
+
];
|
|
185
|
+
export const Fourteen_32 = [
|
|
186
|
+
...generateRange(14, 32, 2)
|
|
187
|
+
];
|
|
188
|
+
export const ThirtySix_100 = [
|
|
189
|
+
...generateRange(36, 100, 4)
|
|
190
|
+
];
|
|
191
|
+
export const NumericPropertyKeys = [
|
|
192
|
+
...Zero_4,
|
|
193
|
+
...Five_12,
|
|
194
|
+
...Fourteen_32,
|
|
195
|
+
...ThirtySix_100,
|
|
196
|
+
];
|
|
197
|
+
export const STATIC = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ 'invisible': 'hidden', "px": "1px", "col": "column", "col-reverse": "column-reverse", "evenly": "space-evenly", "around": "space-around", "between": "space-between" }, MinMaxFitMap), FullMap), AutoMap), VwMap), VhMap), VwVariantsMap), VhVariantsMap), ScreenVwMap), ScreenRemMap);
|
|
198
|
+
export const buildModelMap = (values, value = '', unit = '', keyMap = '', includeKeyMap = false, exclude_static = []) => {
|
|
199
|
+
const overflows = {};
|
|
200
|
+
const mapValue = (obj, key) => {
|
|
201
|
+
const object = obj;
|
|
202
|
+
let stat;
|
|
203
|
+
if (!exclude_static.includes(key.toString())) {
|
|
204
|
+
stat = Object.assign({}, STATIC)[key];
|
|
205
|
+
}
|
|
206
|
+
let v = key;
|
|
207
|
+
if (typeof stat !== 'undefined') {
|
|
208
|
+
v = stat;
|
|
209
|
+
}
|
|
210
|
+
else if (value === '') {
|
|
211
|
+
if (includeKeyMap) {
|
|
212
|
+
v = `${keyMap.toString().replace('-', '')} ${v}`;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
if (v.toString() !== '0') {
|
|
216
|
+
v = `${v}${unit}`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else if (value === 'percent') {
|
|
221
|
+
const sp = key.split('/');
|
|
222
|
+
v = `${Number((parseFloat(sp[0]) / parseFloat(sp[1])) * 100)}%`;
|
|
223
|
+
}
|
|
224
|
+
else if (typeof value === 'number') {
|
|
225
|
+
if (key === 'px') {
|
|
226
|
+
// console.log('is nan', {key, value})
|
|
227
|
+
v = `1px`;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
v = `${Number((parseFloat(key) * value))}`;
|
|
231
|
+
if (v.toString() !== '0') {
|
|
232
|
+
v = `${v}${unit}`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
v = `${value}${unit}`;
|
|
238
|
+
}
|
|
239
|
+
if (v.toString() === '0rem' || v.toString() === '0px' || v.toString() === '0em') {
|
|
240
|
+
v = '0';
|
|
241
|
+
}
|
|
242
|
+
object[key] = v;
|
|
243
|
+
return object;
|
|
244
|
+
};
|
|
245
|
+
// return (values as any).flatMap(o=>overflows[o] = o && overflows).pop() as {[k in ToArray<T, typeof values>[number]]: k};
|
|
246
|
+
return Object.assign({}, values.flatMap((o) => mapValue(overflows, o)).pop());
|
|
247
|
+
// if(keyMap){
|
|
248
|
+
// }else{
|
|
249
|
+
// }
|
|
250
|
+
};
|
|
251
|
+
export const v1 = 0.125;
|
|
252
|
+
export const Zero_4_Map = Object.assign({}, buildModelMap([...Zero_4, ...Pixel], v1, ''));
|
|
253
|
+
export const Zero_12_Map = Object.assign({}, buildModelMap([...Zero_12, ...Pixel], v1, ''));
|
|
254
|
+
export const Five_12_Map = Object.assign({}, buildModelMap([...Five_12], (v1 * 2)));
|
|
255
|
+
export const Fourteen_32_Map = Object.assign({}, buildModelMap([...Fourteen_32], (v1 * 2)));
|
|
256
|
+
export const ThirtySix_100_Map = Object.assign({}, buildModelMap([...ThirtySix_100], (v1 * 2)));
|
|
257
|
+
export const Zero_100_Map = Object.assign(Object.assign(Object.assign(Object.assign({}, Zero_4_Map), Five_12_Map), Fourteen_32_Map), ThirtySix_100_Map);
|
|
258
|
+
export const OpacityMap = Object.assign({}, buildModelMap(generateRange(0, 100, 5), 0.01, '', '', false, ["100"]));
|
|
259
|
+
export const Zero_4_Map_Rem = {
|
|
260
|
+
'0': '0px',
|
|
261
|
+
'0.5': '0.125rem',
|
|
262
|
+
'px': '1px',
|
|
263
|
+
'1': '0.25rem',
|
|
264
|
+
'1.5': '0.375rem',
|
|
265
|
+
'2': '0.5rem',
|
|
266
|
+
'2.5': '0.625rem',
|
|
267
|
+
'3': '0.75rem',
|
|
268
|
+
'3.5': '0.875rem',
|
|
269
|
+
'4': '1rem',
|
|
270
|
+
};
|
|
271
|
+
//{...buildModelMap([...Zero_4, ...Pixel], v1, 'rem')} as const;
|
|
272
|
+
export const Zero_12_Map_Rem = Object.assign({}, buildModelMap([...Zero_12, ...Pixel], v1, 'rem'));
|
|
273
|
+
export const Five_12_Map_Rem = Object.assign({}, buildModelMap([...Five_12], (v1 * 2), 'rem'));
|
|
274
|
+
export const Fourteen_32_Map_Rem = Object.assign({}, buildModelMap([...Fourteen_32], (v1 * 2), 'rem'));
|
|
275
|
+
export const ThirtySix_100_Map_Rem = Object.assign({}, buildModelMap([...ThirtySix_100], (v1 * 2), 'rem'));
|
|
276
|
+
export const Zero_100_Map_Rem = Object.assign(Object.assign(Object.assign(Object.assign({}, Zero_4_Map_Rem), Five_12_Map_Rem), Fourteen_32_Map_Rem), ThirtySix_100_Map_Rem);
|
|
277
|
+
export const PercentMap = Object.assign({}, buildModelMap([...PercentPropertyKeys], 'percent'));
|
|
278
|
+
export const Zero_4_Map_Px = Object.assign({}, buildModelMap([...generateRange(0, 4, 1)], (v1 * 8), 'px'));
|
|
279
|
+
export const Zero_8_Map_Px = Object.assign({}, buildModelMap([...generateRange(0, 8, 1)], (v1 * 8), 'px'));
|
|
280
|
+
export const Five_12_Map_Px = Object.assign({}, buildModelMap([...Five_12], (v1 * 8), 'px'));
|
|
281
|
+
export const Fourteen_32_Map_Px = Object.assign({}, buildModelMap([...Fourteen_32], (v1 * 8), 'px'));
|
|
282
|
+
export const ThirtySix_100_Map_Px = Object.assign({}, buildModelMap([...ThirtySix_100], (v1 * 8), 'px'));
|
|
283
|
+
export const Zero_100_Map_Px = Object.assign(Object.assign(Object.assign(Object.assign({}, Zero_4_Map_Px), Five_12_Map_Px), Fourteen_32_Map_Px), ThirtySix_100_Map_Px);
|
|
284
|
+
// export const ScaleMap = {...buildModelMap(generateRange(0, 155, 5), 0.01, '', '', false, ["100"])} as const;
|
|
285
|
+
export const ScaleMap = {
|
|
286
|
+
'0': '0',
|
|
287
|
+
'50': '.5',
|
|
288
|
+
'75': '.75',
|
|
289
|
+
'90': '.9',
|
|
290
|
+
'95': '.95',
|
|
291
|
+
'100': '1',
|
|
292
|
+
'105': '1.05',
|
|
293
|
+
'110': '1.1',
|
|
294
|
+
'115': '1.15',
|
|
295
|
+
'120': '1.2',
|
|
296
|
+
'125': '1.25',
|
|
297
|
+
'150': '1.5'
|
|
298
|
+
};
|
|
299
|
+
export const OpacityDefaultMap = Object.assign({}, buildModelMap(generateRange(0, 225, 25), 0.01, '', '', false, ["100"]));
|
|
300
|
+
export const RotateMap = Object.assign({ "0": "0deg", "1": "1deg", "2": "2deg", "3": "3deg", "4": "4deg", "6": "6deg", "8": "8deg", "10": "10deg", "12": "12deg", "14": "14deg", "16": "16deg", "18": "18deg", "20": "20deg" }, buildModelMap(generateRange(25, 185, 5), 1, 'deg', '', false, ["100"]));
|
|
301
|
+
export const SkewMap = {
|
|
302
|
+
"0": "0",
|
|
303
|
+
"1": "1",
|
|
304
|
+
"2": "2",
|
|
305
|
+
"3": "3",
|
|
306
|
+
"4": "4",
|
|
307
|
+
"6": "6",
|
|
308
|
+
"12": "12",
|
|
309
|
+
};
|
|
310
|
+
export const TranslateMap = Object.assign(Object.assign(Object.assign({}, Zero_100_Map_Rem), PercentMap), { full: '100%' });
|
|
311
|
+
export const POSITIONING_MAP = {
|
|
312
|
+
"top-left": "top left",
|
|
313
|
+
"top-right": "top right",
|
|
314
|
+
"bottom-left": "bottom left",
|
|
315
|
+
"bottom-right": "bottom right",
|
|
316
|
+
"center": "center",
|
|
317
|
+
"top": "top",
|
|
318
|
+
"right": "right",
|
|
319
|
+
"bottom": "left",
|
|
320
|
+
"left": "left",
|
|
321
|
+
"tl": "top left",
|
|
322
|
+
"tr": "top right",
|
|
323
|
+
"bl": "bottom left",
|
|
324
|
+
"br": "bottom right",
|
|
325
|
+
"l": "left",
|
|
326
|
+
"r": "right",
|
|
327
|
+
"center-top": "center top",
|
|
328
|
+
"center-bottom": "center bottom",
|
|
329
|
+
"left-top": "left top",
|
|
330
|
+
"left-bottom": "left bottom",
|
|
331
|
+
"right-top": "right top",
|
|
332
|
+
"right-bottom": "right bottom",
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* The clearAndUpper function takes a string and returns it with all underscores
|
|
336
|
+
* and dashes removed, and the remaining characters converted to uppercase.
|
|
337
|
+
|
|
338
|
+
*
|
|
339
|
+
* @param text:string Specify the type of data that will be passed into the function
|
|
340
|
+
*
|
|
341
|
+
* @return A string, so the type of clearandupper is a function that takes a string and returns a string
|
|
342
|
+
*
|
|
343
|
+
* @docauthor Ibrahima Touré
|
|
344
|
+
*/
|
|
345
|
+
export const clearAndUpper = (text) => {
|
|
346
|
+
return text.replace(/_|-/, "").toUpperCase();
|
|
347
|
+
};
|
|
348
|
+
export const assignKey = (object, key, value) => {
|
|
349
|
+
let dict = object;
|
|
350
|
+
if (isUndefinedOrNull(dict)) {
|
|
351
|
+
dict = { [key]: value };
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
dict[key] = value;
|
|
355
|
+
}
|
|
356
|
+
return dict;
|
|
357
|
+
};
|
|
358
|
+
function isObject(item) {
|
|
359
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
360
|
+
}
|
|
361
|
+
function isArray(item) {
|
|
362
|
+
return Array.isArray(item);
|
|
363
|
+
}
|
|
364
|
+
export function mergeNestedObjects(target, source) {
|
|
365
|
+
if (isObject(target) && isObject(source)) {
|
|
366
|
+
for (const key in source) {
|
|
367
|
+
if (isObject(source[key])) {
|
|
368
|
+
if (typeof target[key] === "undefined")
|
|
369
|
+
Object.assign(target, { [key]: {} });
|
|
370
|
+
mergeNestedObjects(target[key], source[key]);
|
|
371
|
+
}
|
|
372
|
+
else if (isArray(source[key])) {
|
|
373
|
+
if (typeof target[key] === "undefined")
|
|
374
|
+
Object.assign(target, { [key]: [] });
|
|
375
|
+
if (isArray(target[key])) {
|
|
376
|
+
target[key] = [...new Set([...target[key], ...source[key]])];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
if (typeof target[key] === 'undefined' || typeof target[key] === typeof source[key]) {
|
|
381
|
+
Object.assign(target, { [key]: source[key] });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return target;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* The keys function returns an array of the keys in a given object.
|
|
390
|
+
*
|
|
391
|
+
*
|
|
392
|
+
* @param object: T Type the object that is passed in
|
|
393
|
+
*
|
|
394
|
+
* @return An array of the keys in an object
|
|
395
|
+
*
|
|
396
|
+
* @docauthor Ibrahima Touré
|
|
397
|
+
*/
|
|
398
|
+
export const objectKeys = (object) => {
|
|
399
|
+
let obj = Object.assign({}, object);
|
|
400
|
+
return Object.keys(obj);
|
|
401
|
+
// .flatMap(k=>{
|
|
402
|
+
// if(typeof obj[k] === 'object'){
|
|
403
|
+
// result = {...result, ...obj[k]}
|
|
404
|
+
// }
|
|
405
|
+
// })
|
|
406
|
+
};
|
|
407
|
+
export const isEqual = (compare1, compare2, keys) => {
|
|
408
|
+
if (compare1 === undefined || compare2 === undefined)
|
|
409
|
+
return false;
|
|
410
|
+
if (compare1 === null || compare2 === null)
|
|
411
|
+
return compare1 === compare2;
|
|
412
|
+
if (Array.isArray(compare1) && Array.isArray(compare2)) {
|
|
413
|
+
if (compare1.length !== compare2.length)
|
|
414
|
+
return false;
|
|
415
|
+
return compare1.every((v, i) => isEqual(v, compare2[i]));
|
|
416
|
+
}
|
|
417
|
+
if (keys && keys.length > 0) {
|
|
418
|
+
return keys.every(k => compare1[k] === compare2[k]);
|
|
419
|
+
}
|
|
420
|
+
if (typeof compare1 === 'object' && typeof compare2 === 'object') {
|
|
421
|
+
const obj1Keys = keys || Object.keys(compare1).sort();
|
|
422
|
+
const obj2Keys = keys || Object.keys(compare2).sort();
|
|
423
|
+
if (obj1Keys.length !== obj2Keys.length)
|
|
424
|
+
return false;
|
|
425
|
+
return obj1Keys.every(key => compare1[key] === compare2[key]);
|
|
426
|
+
}
|
|
427
|
+
return compare1 === compare2;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* The checkType function is a helper function that checks the type of a value.
|
|
431
|
+
*
|
|
432
|
+
*
|
|
433
|
+
* @param value: any Pass in any value to the function
|
|
434
|
+
*
|
|
435
|
+
* @return An object with properties
|
|
436
|
+
*
|
|
437
|
+
* @docauthor Ibrahima Touré
|
|
438
|
+
*/
|
|
439
|
+
export const checkType = (value) => {
|
|
440
|
+
let is_undefined = false;
|
|
441
|
+
let is_null = false;
|
|
442
|
+
let is_array = false;
|
|
443
|
+
let is_object = false;
|
|
444
|
+
let is_string = false;
|
|
445
|
+
let is_number = false;
|
|
446
|
+
let typeOf = typeof value;
|
|
447
|
+
if (value === null || value === 'null') {
|
|
448
|
+
is_null = true;
|
|
449
|
+
}
|
|
450
|
+
else if (typeOf === 'undefined') {
|
|
451
|
+
is_undefined = true;
|
|
452
|
+
}
|
|
453
|
+
else if (typeOf === 'string') {
|
|
454
|
+
is_string = true;
|
|
455
|
+
}
|
|
456
|
+
else if (typeOf === 'number') {
|
|
457
|
+
is_number = true;
|
|
458
|
+
}
|
|
459
|
+
else if (Array.isArray(value)) {
|
|
460
|
+
is_array = true;
|
|
461
|
+
}
|
|
462
|
+
else if (typeOf === 'object') {
|
|
463
|
+
is_object = true;
|
|
464
|
+
}
|
|
465
|
+
return { is_undefined, is_null, is_string, is_number, is_array, is_object, typeOf, keys: is_object ? objectKeys(value) : [] };
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* The uniq function takes an array of strings and returns a new array with duplicate values removed.
|
|
469
|
+
*
|
|
470
|
+
*
|
|
471
|
+
* @param arrays: T[] Pass in an array of type t
|
|
472
|
+
*
|
|
473
|
+
* @return An array of unique elements
|
|
474
|
+
*
|
|
475
|
+
* @docauthor Ibrahima Touré
|
|
476
|
+
*/
|
|
477
|
+
export const uniq = (arrays) => {
|
|
478
|
+
const find = (value, index, array) => {
|
|
479
|
+
if (typeof value === 'object') {
|
|
480
|
+
return array.findIndex(a => isEqual(a, value)) === index;
|
|
481
|
+
}
|
|
482
|
+
return array.indexOf(value) === index;
|
|
483
|
+
};
|
|
484
|
+
return arrays.slice().filter(find).slice();
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* The omitFilter function takes two arrays as arguments. The first array is the values to be filtered, and the second array is a list of keys that should be omitted from the first argument.
|
|
488
|
+
*
|
|
489
|
+
*
|
|
490
|
+
* @param values: T Specify the type of values that will be passed to the function
|
|
491
|
+
* @param keys: U Specify the keys to be omitted from the values: t parameter
|
|
492
|
+
*
|
|
493
|
+
* @return An array of values that are not in the keys array
|
|
494
|
+
*
|
|
495
|
+
* @docauthor Ibrahima Touré
|
|
496
|
+
*/
|
|
497
|
+
export const omitFilter = (values, keys) => values.filter((el) => !keys.includes(el));
|
|
498
|
+
/**
|
|
499
|
+
* The omit function takes an object and a list of keys to omit from the object.
|
|
500
|
+
* It returns a new object with all the keys omitted.
|
|
501
|
+
*
|
|
502
|
+
*
|
|
503
|
+
* @param object: T Define the type of object that will be passed in
|
|
504
|
+
* @param keys: U[] Specify the keys that we want to omit from the object
|
|
505
|
+
*
|
|
506
|
+
* @return A new object without the keys that are in the second argument
|
|
507
|
+
*
|
|
508
|
+
* @docauthor Ibrahima Touré
|
|
509
|
+
*/
|
|
510
|
+
export const omit = (object, keys) => {
|
|
511
|
+
const obj = Object.assign({}, object);
|
|
512
|
+
let result = {};
|
|
513
|
+
for (const objkey in obj) {
|
|
514
|
+
if ((obj.hasOwnProperty(objkey) || obj.hasOwnProperty(getObjKey(objkey))) && !keys.some(k => k === objkey || k === getObjKey(objkey))) {
|
|
515
|
+
if (result === undefined) {
|
|
516
|
+
result = { [objkey]: obj[objkey] };
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
result[objkey] = obj[objkey];
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return result;
|
|
524
|
+
// OmitLitteralArrayString<T extends any ? typeof object: T, U extends any ? typeof keys[number]: U>;
|
|
525
|
+
};
|
|
526
|
+
export const omitArray = (arr, keys) => {
|
|
527
|
+
return [...arr].filter(a => ![...keys].some(b => a.toString() === b.toString()));
|
|
528
|
+
// OmitLitteralArrayString<T extends any ? typeof object: T, U extends any ? typeof keys[number]: U>;
|
|
529
|
+
};
|
|
530
|
+
export const pickArray = (arr, keys) => {
|
|
531
|
+
if (keys.length > 0) {
|
|
532
|
+
return [...arr].filter(a => [...keys].some(b => a.toString() === b.toString())).flatMap(o => getObjKey(o));
|
|
533
|
+
}
|
|
534
|
+
return [...arr].flatMap(o => getObjKey(o));
|
|
535
|
+
// OmitLitteralArrayString<T extends any ? typeof object: T, U extends any ? typeof keys[number]: U>;
|
|
536
|
+
};
|
|
537
|
+
// type PickType<T extends any, U extends Props<T>> = {[k in U]: k extends keyof T ? T[k] : never}
|
|
538
|
+
export const pick = (object, keys) => {
|
|
539
|
+
if (!checkType(object).is_object) {
|
|
540
|
+
return object;
|
|
541
|
+
}
|
|
542
|
+
const obj = Object.assign({}, object);
|
|
543
|
+
let result = {};
|
|
544
|
+
for (const objkey of keys) {
|
|
545
|
+
if (obj.hasOwnProperty(objkey) || obj.hasOwnProperty(getObjKey(objkey))) {
|
|
546
|
+
result = Object.assign(Object.assign({}, result), { [objkey]: obj[objkey] });
|
|
547
|
+
// if(keys.some(k=>k===objkey || getObjKey(objkey)===k)){
|
|
548
|
+
// }
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return result;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* The flattenObject function takes an object and returns a new object with all the keys flattened.
|
|
555
|
+
*
|
|
556
|
+
*
|
|
557
|
+
* @param object:T Define the type of object that will be passed in
|
|
558
|
+
* @param objKeys: K[] Specify the keys of the object to be flattened
|
|
559
|
+
*
|
|
560
|
+
* @return An object with the keys of the original object and their values
|
|
561
|
+
*
|
|
562
|
+
* @docauthor Ibrahima Touré
|
|
563
|
+
*/
|
|
564
|
+
export const flattenObject = (object, camel = true, objKeys = objectKeys(object), _omitKeys = objectKeys(object)) => {
|
|
565
|
+
if (!checkType(object).is_object) {
|
|
566
|
+
return object;
|
|
567
|
+
}
|
|
568
|
+
const obj = Object.assign({}, object);
|
|
569
|
+
const omitKeys = [];
|
|
570
|
+
if (_omitKeys) {
|
|
571
|
+
omitKeys.push(...[..._omitKeys]);
|
|
572
|
+
}
|
|
573
|
+
let result = {};
|
|
574
|
+
for (let o in obj) {
|
|
575
|
+
if (obj.hasOwnProperty(o) && [...objKeys].some(ok => ok === o)) {
|
|
576
|
+
if (checkType(obj[o]).is_object) {
|
|
577
|
+
for (const kk in obj[o]) {
|
|
578
|
+
if (obj[o].hasOwnProperty(kk)) {
|
|
579
|
+
result = Object.assign(Object.assign({}, result), { [camel === true ? toCamelCase(`${o}-${kk}`) : `${o}-${kk}`]: obj[o][kk] });
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
result = Object.assign(Object.assign({}, result), { [o]: obj[o] });
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return result;
|
|
589
|
+
};
|
|
590
|
+
// type ReturnType<T> = T extends (...args: any[]) => infer R ? R : any;
|
|
591
|
+
export const memoizeFn = (fn) => {
|
|
592
|
+
let cache = new Map();
|
|
593
|
+
return (...args) => {
|
|
594
|
+
const key = JSON.stringify(args);
|
|
595
|
+
// const n = args[0];
|
|
596
|
+
if (cache.has(key)) {
|
|
597
|
+
// console.log('Fetching from cache', {name: fn.name});
|
|
598
|
+
return cache.get(key);
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
// console.log('Calculating result');
|
|
602
|
+
let result = fn(...args);
|
|
603
|
+
// cache[key as any] = result;
|
|
604
|
+
cache.set(key, result);
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* The flattenObjectValue function takes an object and a key, then returns a new object with the same keys as the original but with values that are equal to the value of each key in its corresponding sub-object.
|
|
611
|
+
*
|
|
612
|
+
*
|
|
613
|
+
* @param object: T Specify the type of object that will be passed in
|
|
614
|
+
* @param key: K Specify the key of the object that we want to extract
|
|
615
|
+
*
|
|
616
|
+
* @return An object with the same keys as the original, but each value is flattened to a single value
|
|
617
|
+
*
|
|
618
|
+
* @docauthor Ibrahima Touré
|
|
619
|
+
*/
|
|
620
|
+
export const flattenObjectValue = (object, key) => {
|
|
621
|
+
if (!checkType(object).is_object) {
|
|
622
|
+
return object;
|
|
623
|
+
}
|
|
624
|
+
let result = {};
|
|
625
|
+
const obj = Object.assign({}, object);
|
|
626
|
+
Object.keys(obj).forEach(o => {
|
|
627
|
+
const typeObject = checkType(obj[o]);
|
|
628
|
+
if (typeObject.is_object) {
|
|
629
|
+
if (!checkType(obj[o][key]).is_undefined) {
|
|
630
|
+
result = Object.assign(Object.assign({}, result), { [o]: obj[o][key] });
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
result = Object.assign(Object.assign({}, result), { [o]: flattenObjectValue(obj[o], key) });
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
return result;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* The prefixObjectKeys function takes an object and a value, then prefixes the keys of the object with that value.
|
|
641
|
+
*
|
|
642
|
+
*
|
|
643
|
+
* @param object: T Type the object that is passed in
|
|
644
|
+
* @param value: V Prefix or suffix the keys in the object
|
|
645
|
+
* @param isSuffix: S Determine whether the value is a prefix or suffix
|
|
646
|
+
* @param objectKeys: K[] Specify the keys of the object that should be prefixed or suffixed
|
|
647
|
+
*
|
|
648
|
+
* @return An object with the keys prefixed by a string
|
|
649
|
+
*
|
|
650
|
+
* @docauthor Ibrahima Touré
|
|
651
|
+
*/
|
|
652
|
+
export const KeyCorrection = {
|
|
653
|
+
'bg-repeat-repeat': 'bg-repeat',
|
|
654
|
+
'bg-repeat-no': 'bg-no-repeat',
|
|
655
|
+
'overflow-xhidden': 'overflow-x-hidden',
|
|
656
|
+
'overflow-xscroll': 'overflow-x-scroll',
|
|
657
|
+
'overflow-xauto': 'overflow-x-auto',
|
|
658
|
+
'overflow-xvisible': 'overflow-x-visible',
|
|
659
|
+
'overflow-yhidden': 'overflow-y-hidden',
|
|
660
|
+
'overflow-yscroll': 'overflow-y-scroll',
|
|
661
|
+
'overflow-yauto': 'overflow-y-auto',
|
|
662
|
+
'overflow-yvisible': 'overflow-y-visible',
|
|
663
|
+
};
|
|
664
|
+
export const isImportantFn = (str) => {
|
|
665
|
+
if (typeof str === 'string') {
|
|
666
|
+
let marker = '!';
|
|
667
|
+
if (str.startsWith(marker)) {
|
|
668
|
+
const replaced = replaceString(str, marker, true, '');
|
|
669
|
+
if (replaced.length > 0) {
|
|
670
|
+
return { str: replaced, marker: marker };
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
marker = '!important';
|
|
674
|
+
if (str.endsWith(marker)) {
|
|
675
|
+
const replaced = replaceString(str, marker, false, '');
|
|
676
|
+
if (replaced.length > 0) {
|
|
677
|
+
return { str: replaced, marker: marker };
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
const marker = '!important';
|
|
683
|
+
if (str.slice().pop() === marker) {
|
|
684
|
+
const newArray = str.slice();
|
|
685
|
+
newArray.pop();
|
|
686
|
+
if (newArray.length > 0) {
|
|
687
|
+
return { str: newArray, marker };
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return null;
|
|
692
|
+
};
|
|
693
|
+
export const getCorrectKey = (_input, _correction = KeyCorrection) => {
|
|
694
|
+
let input = _input;
|
|
695
|
+
const correction = Object.assign({}, _correction);
|
|
696
|
+
if (typeof input === 'string') {
|
|
697
|
+
const keb = input;
|
|
698
|
+
if (typeof correction[keb] !== "undefined") {
|
|
699
|
+
return correction[keb];
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return input;
|
|
703
|
+
};
|
|
704
|
+
export const prefixObjectKeys = (object, value, isSuffix = false, camel = true, separator = "-", _objectKeys = objectKeys(object), _correction = KeyCorrection) => {
|
|
705
|
+
if (!checkType(object).is_object) {
|
|
706
|
+
return object;
|
|
707
|
+
}
|
|
708
|
+
let result = {};
|
|
709
|
+
const obj = Object.assign({}, object);
|
|
710
|
+
for (let o in obj) {
|
|
711
|
+
if (obj.hasOwnProperty(o)) {
|
|
712
|
+
if (_objectKeys.some(ok => ok === o)) {
|
|
713
|
+
let key1 = `${o}`;
|
|
714
|
+
let key2 = `${o}`;
|
|
715
|
+
let key = key1;
|
|
716
|
+
let other;
|
|
717
|
+
if ('DEFAULT' === o.toString().toUpperCase()) {
|
|
718
|
+
key = value;
|
|
719
|
+
}
|
|
720
|
+
else if (value.length > 0) {
|
|
721
|
+
if (o !== value) {
|
|
722
|
+
key1 = getCorrectKey(`${o}${separator}${value}`, _correction);
|
|
723
|
+
key2 = getCorrectKey(`${value}${separator}${o}`, _correction);
|
|
724
|
+
}
|
|
725
|
+
// if(value==="bg-repeat"){
|
|
726
|
+
// console.log('k1', key1)
|
|
727
|
+
// console.log('k2', key2)
|
|
728
|
+
// }
|
|
729
|
+
if (isSuffix) {
|
|
730
|
+
if (camel) {
|
|
731
|
+
key = toCamelCase(key1);
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
key = key1;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (!isSuffix) {
|
|
738
|
+
if (camel) {
|
|
739
|
+
key = toCamelCase(key2);
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
key = key2;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
if (camel) {
|
|
748
|
+
key = toCamelCase(key);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (![..._objectKeys].some(ok => ok === "DEFAULT") && key.endsWith('500')) {
|
|
752
|
+
let otherkey = `${key.replace('500', '')}`;
|
|
753
|
+
if (otherkey.endsWith('-')) {
|
|
754
|
+
const otherArr = otherkey.split('-');
|
|
755
|
+
otherArr.pop();
|
|
756
|
+
otherkey = otherArr.join('-');
|
|
757
|
+
}
|
|
758
|
+
other = { [otherkey]: obj[o] };
|
|
759
|
+
}
|
|
760
|
+
result = Object.assign(Object.assign(Object.assign({}, result), { [key]: obj[o] }), (other ? other : {}));
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
// [..._objectKeys as any].forEach(o=>{
|
|
765
|
+
// // return result;
|
|
766
|
+
// })
|
|
767
|
+
return result;
|
|
768
|
+
};
|
|
769
|
+
export const getValueDeep = (obj, keys, init = false) => {
|
|
770
|
+
return keys.reduce((acc, key) => acc && acc[key], obj);
|
|
771
|
+
};
|
|
772
|
+
export const updateValueDeep = (obj, keysArray, newValue) => {
|
|
773
|
+
if (!checkType(obj).is_object) {
|
|
774
|
+
return obj;
|
|
775
|
+
}
|
|
776
|
+
const lastKeyIndex = keysArray.length - 1;
|
|
777
|
+
return { [keysArray[lastKeyIndex]]: keysArray.reduce((acc, key, currentIndex) => {
|
|
778
|
+
if (currentIndex === lastKeyIndex) {
|
|
779
|
+
if (typeof acc[key] === "object") {
|
|
780
|
+
acc[key] = Object.assign(Object.assign({}, acc[key]), newValue); // Update value when last key is reached
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
acc[key] = newValue; // Update value when last key is reached
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
acc[key] = acc[key] || {};
|
|
788
|
+
}
|
|
789
|
+
return acc[key]; // Return the nested object for the next iteration
|
|
790
|
+
}, obj) };
|
|
791
|
+
};
|
|
792
|
+
export const setObjectValue = (obj, path, value, separator = ".") => {
|
|
793
|
+
const keys = path.split(separator);
|
|
794
|
+
let current = obj;
|
|
795
|
+
keys.forEach(key => {
|
|
796
|
+
if (!current[key]) {
|
|
797
|
+
// If the key does not exist, create an empty object
|
|
798
|
+
current[key] = {};
|
|
799
|
+
}
|
|
800
|
+
// Move to the next nested level
|
|
801
|
+
current = current[key];
|
|
802
|
+
});
|
|
803
|
+
// Set the value at the final key
|
|
804
|
+
current[keys[keys.length - 1]] = value;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* The createMutable function takes an object and returns a mutable version of it.
|
|
808
|
+
* This is useful for when you want to create a new object that has the same properties as another, but you don't want to change the original.
|
|
809
|
+
*
|
|
810
|
+
*
|
|
811
|
+
* @param object: T Create a new object with the same properties as the original
|
|
812
|
+
*
|
|
813
|
+
* @return An object with the same properties as the passed in object, but all of them are mutable
|
|
814
|
+
*
|
|
815
|
+
* @docauthor Ibrahima Touré
|
|
816
|
+
*/
|
|
817
|
+
export const createMutable = (object) => {
|
|
818
|
+
return Object.assign({}, object);
|
|
819
|
+
};
|
|
820
|
+
/**
|
|
821
|
+
* The formatObject function takes in a value and key, and returns an object with the key as the property name.
|
|
822
|
+
*
|
|
823
|
+
*
|
|
824
|
+
* @param value: V Pass in the value of the object
|
|
825
|
+
* @param key: K Allow the user to specify a key for the object
|
|
826
|
+
* @param includeKey: I Determine whether or not the key should be included in the result
|
|
827
|
+
*
|
|
828
|
+
* @return An object with a key and value
|
|
829
|
+
*
|
|
830
|
+
* @docauthor Ibrahima Touré
|
|
831
|
+
*/
|
|
832
|
+
export const formatObject = (value, key, includeKey = true) => {
|
|
833
|
+
let result = {};
|
|
834
|
+
if (checkType(value).is_object) {
|
|
835
|
+
if (includeKey) {
|
|
836
|
+
result = Object.assign(Object.assign({}, result), { [key]: Object.assign({}, value) });
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
result = Object.assign(Object.assign({}, result), value);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
else {
|
|
843
|
+
result = Object.assign(Object.assign({}, result), { [key]: value });
|
|
844
|
+
}
|
|
845
|
+
return Object.assign({}, result);
|
|
846
|
+
};
|
|
847
|
+
const getObjKey = (k, convert = false) => {
|
|
848
|
+
var _c;
|
|
849
|
+
let r = k;
|
|
850
|
+
if (isInt(r) && convert) {
|
|
851
|
+
return (_c = toNumber(r)) === null || _c === void 0 ? void 0 : _c.value;
|
|
852
|
+
}
|
|
853
|
+
return r;
|
|
854
|
+
};
|
|
855
|
+
/**
|
|
856
|
+
* The _dynamicPick function is a recursive function that allows you to pick any number of keys from an object.
|
|
857
|
+
* It also allows you to include or exclude the key names in the resulting object.
|
|
858
|
+
* @param values: T Pass the object to be picked from
|
|
859
|
+
* @param keys: U[] Specify the keys to be picked from the object
|
|
860
|
+
* @param includeKeys: IK Determine whether the keys should be included in the result or not
|
|
861
|
+
* @param includeKeys1: IU Determine whether to include the keys in the object or not
|
|
862
|
+
* @param keys1: V[] Pick the keys of the second level
|
|
863
|
+
* @param includeKeys2: IW Determine whether or not to include the keys2 array in the result
|
|
864
|
+
* @param keys2: W[] Pick the keys of the second level of an object
|
|
865
|
+
* @param includeKeys3: IX Determine whether to include the keys3 in the final result or not
|
|
866
|
+
* @param keys3: X[] Pick the keys of the third level of an object
|
|
867
|
+
* @param includeKeys4: IZ Determine whether to include the keys4 in the result or not
|
|
868
|
+
* @param keys4: Z[] Specify the keys of the 4th level nested object
|
|
869
|
+
* @return This type
|
|
870
|
+
*
|
|
871
|
+
* @docauthor Ibrahima Touré
|
|
872
|
+
*/
|
|
873
|
+
const _dynamicPick = (values, keys = Object.keys(Object.assign({}, values)), includeKeys = true, includeKeys1 = true, keys1 = [], includeKeys2 = true, keys2 = [], includeKeys3 = true, keys3 = [], includeKeys4 = true, keys4 = []) => {
|
|
874
|
+
const object = Object.assign({}, values);
|
|
875
|
+
let result = {};
|
|
876
|
+
const objKeys = [...keys].length > 0 ? pickArray(Object.keys(Object.assign({}, object)), keys) : Object.keys(Object.assign({}, object));
|
|
877
|
+
for (let i = 0; i < objKeys.length; i++) {
|
|
878
|
+
let _k = objKeys[i];
|
|
879
|
+
const k = getObjKey(_k);
|
|
880
|
+
const o = Object.assign({}, object)[k];
|
|
881
|
+
let local1 = {};
|
|
882
|
+
if (checkType(o).is_object) {
|
|
883
|
+
const objKeys1 = ([...keys1].length > 0 ? pickArray(Object.keys(o), keys1) : Object.keys(Object.assign({}, o)));
|
|
884
|
+
for (let i = 0; i < objKeys1.length; i++) {
|
|
885
|
+
let _k1 = objKeys1[i];
|
|
886
|
+
const k1 = getObjKey(_k1);
|
|
887
|
+
const o1 = Object.assign({}, o)[k1];
|
|
888
|
+
if (checkType(o1).is_object) {
|
|
889
|
+
let local2 = {};
|
|
890
|
+
local1 = Object.assign(Object.assign({}, local1), formatObject(Object.assign({}, ([...keys2].length > 0 ? pickArray(Object.keys(o1), keys2) : Object.keys(Object.assign({}, o1))).flatMap(_k2 => {
|
|
891
|
+
const k2 = getObjKey(_k2);
|
|
892
|
+
const o2 = Object.assign({}, o1)[k2];
|
|
893
|
+
if (checkType(o2).is_object) {
|
|
894
|
+
let local3 = {};
|
|
895
|
+
local2 = Object.assign(Object.assign({}, local2), formatObject(Object.assign({}, ([...keys3].length > 0 ? pickArray(Object.keys(o2), keys3) : Object.keys(Object.assign({}, o2))).flatMap(_k3 => {
|
|
896
|
+
const k3 = getObjKey(_k3);
|
|
897
|
+
const o3 = Object.assign({}, o2)[k3];
|
|
898
|
+
if (checkType(o3).is_object) {
|
|
899
|
+
let local4 = {};
|
|
900
|
+
// local3 = {...local3, ...formatObject(buildObject(object[k][k1][k2][k3],keys4, includeKeys4), k3, includeKeys3)}
|
|
901
|
+
let pk = pickArray(Object.keys(o3), keys4);
|
|
902
|
+
if (pk.length === 0) {
|
|
903
|
+
pk = Object.keys(o3);
|
|
904
|
+
}
|
|
905
|
+
local3 = Object.assign(Object.assign({}, local3), formatObject(pk.flatMap(_k4 => {
|
|
906
|
+
const k4 = getObjKey(_k4);
|
|
907
|
+
const o4 = Object.assign({}, o3)[k4];
|
|
908
|
+
local4 = Object.assign(Object.assign({}, local4), formatObject(o4, k4, includeKeys4));
|
|
909
|
+
return local4;
|
|
910
|
+
}).pop(), k3, includeKeys3));
|
|
911
|
+
// console.log('l', local3)
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
local3 = Object.assign(Object.assign({}, local3), formatObject(o3, k3, includeKeys3));
|
|
915
|
+
}
|
|
916
|
+
return local3;
|
|
917
|
+
}).pop()), k2, includeKeys2));
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
local2 = Object.assign(Object.assign({}, local2), formatObject(o2, k2, includeKeys2));
|
|
921
|
+
}
|
|
922
|
+
return local2;
|
|
923
|
+
}).pop()), k1, includeKeys1));
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
local1 = Object.assign(Object.assign({}, local1), formatObject(o1, k1, includeKeys1));
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
result = Object.assign(Object.assign({}, result), formatObject(Object.assign({}, local1), k, includeKeys));
|
|
930
|
+
}
|
|
931
|
+
else {
|
|
932
|
+
result = Object.assign(Object.assign({}, result), formatObject(o, k, includeKeys));
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return result;
|
|
936
|
+
};
|
|
937
|
+
export const narrowIt = (values, keys = objectKeys(values), keys1 = [], ik = true, ik1 = true, keys3 = [], ik2 = true) => {
|
|
938
|
+
let result = {};
|
|
939
|
+
const object = Object.assign({}, values);
|
|
940
|
+
([...keys].length > 0 ? pickArray(Object.keys(Object.assign({}, object)), keys) : Object.keys(Object.assign({}, object))).forEach((k) => {
|
|
941
|
+
const picked = dynamicPick(object[k], [...keys1], ik, ik1, [...keys3], ik2);
|
|
942
|
+
result = Object.assign(Object.assign({}, result), { [k]: picked });
|
|
943
|
+
});
|
|
944
|
+
return result;
|
|
945
|
+
};
|
|
946
|
+
export const objectSubKeys = (object) => {
|
|
947
|
+
let result = {};
|
|
948
|
+
const obj = Object.assign({}, object);
|
|
949
|
+
return Object.values(Object.keys(obj).flatMap((k) => {
|
|
950
|
+
if (checkType(obj[k]).is_object) {
|
|
951
|
+
result = Object.assign(Object.assign({}, result), { [k]: Object.keys(obj[k]) });
|
|
952
|
+
}
|
|
953
|
+
return result;
|
|
954
|
+
}).pop()).flatMap(e => e);
|
|
955
|
+
};
|
|
956
|
+
export const pickSub = (_object) => {
|
|
957
|
+
// const sub = objectSubKeys(obj)
|
|
958
|
+
const object = Object.assign({}, _object);
|
|
959
|
+
let result = {};
|
|
960
|
+
const keys = Object.keys(object);
|
|
961
|
+
for (let i = 0; i < keys.length; i++) {
|
|
962
|
+
if (checkType(Object.assign({}, object)[keys[i]]).is_object) {
|
|
963
|
+
result = Object.assign(Object.assign({}, result), Object.assign({}, object)[keys[i]]);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
// let wk = new Map();
|
|
967
|
+
return result;
|
|
968
|
+
};
|
|
969
|
+
const getValue = (value, _key, valueToReplace = 'xxx') => {
|
|
970
|
+
let key = _key;
|
|
971
|
+
if (value) {
|
|
972
|
+
if (GradientKeyMap[_key]) {
|
|
973
|
+
key = GradientKeyMap[_key];
|
|
974
|
+
}
|
|
975
|
+
return value.replace(new RegExp(valueToReplace, 'g'), key);
|
|
976
|
+
}
|
|
977
|
+
return key;
|
|
978
|
+
};
|
|
979
|
+
const d = [...Zero_12];
|
|
980
|
+
export const generateDynamicTemplateProperty = (value = '', prefix = '', ranges = [...Zero_12]) => {
|
|
981
|
+
let r = {};
|
|
982
|
+
return Object.assign({}, [...ranges].flatMap(c => {
|
|
983
|
+
r = Object.assign(Object.assign({}, r), { [`${prefix}${c}`]: getValue(value, c) });
|
|
984
|
+
return r;
|
|
985
|
+
}).pop());
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* The dynamicPick function is a function that allows you to pick values from an object.
|
|
989
|
+
* It can be used to pick values from the first level of an object, or it can be used to
|
|
990
|
+
* pick values from multiple levels deep in an object. The dynamicPick function takes in
|
|
991
|
+
* two arguments: the first argument is the data that you want to extract data out of, and
|
|
992
|
+
* the second argument is a list of keys that you want extracted out of your data. If there are no keys provided as arguments then all keys will be returned by default. You may also provide additional parameters for picking nested objects within your original
|
|
993
|
+
*
|
|
994
|
+
* @param values: T Type the object that will be returned
|
|
995
|
+
* @param keys: U[] Specify the keys to pick from the object
|
|
996
|
+
* @param includeKeys: IK Determine if the keys array should be included in the returned object
|
|
997
|
+
* @param includeKeys1: IU Determine if the keys in the second level of properties should be included or not
|
|
998
|
+
* @param keys1: V[] Specify the keys of the second level of object
|
|
999
|
+
* @param includeKeys2: IW Determine if the keys2 array should be included in the returned object
|
|
1000
|
+
* @param keys2: W[] Specify the keys of the second level of properties to pick
|
|
1001
|
+
* @param includeKeys3: IX Include or not the keys3 in the result
|
|
1002
|
+
* @param keys3: X[] Specify the keys of the third level of nested objects
|
|
1003
|
+
* @param includeKeys4: IZ Determine if the keys4 parameter should be used or not
|
|
1004
|
+
* @param keys4: Z[] Specify the keys of the 4th level of nesting in a type
|
|
1005
|
+
*
|
|
1006
|
+
* @return An object with the same keys as the values parameter
|
|
1007
|
+
*
|
|
1008
|
+
* @docauthor Ibrahima Touré
|
|
1009
|
+
*/
|
|
1010
|
+
export const dynamicPick = (values, keys = Object.keys(Object.assign({}, values)), includeKeys = true, includeKeys1 = true, keys1 = [], includeKeys2 = true, keys2 = [], includeKeys3 = true, keys3 = [], includeKeys4 = true, keys4 = []) => {
|
|
1011
|
+
// @ts-ignore L'expression produit un type union trop complexe à représenter.ts(2590)
|
|
1012
|
+
return Object.assign({}, _dynamicPick(values, keys, includeKeys, includeKeys1, keys1, includeKeys2, keys2, includeKeys3, keys3, includeKeys4, keys4));
|
|
1013
|
+
};
|
|
1014
|
+
/**
|
|
1015
|
+
* The isUndefinedOrNull function checks if a value is undefined or null.
|
|
1016
|
+
*
|
|
1017
|
+
*
|
|
1018
|
+
* @param element: any Tell the function that it can accept any type of parameter
|
|
1019
|
+
*
|
|
1020
|
+
* @return True if the element is undefined or null
|
|
1021
|
+
*
|
|
1022
|
+
* @docauthor Ibrahima Touré
|
|
1023
|
+
*/
|
|
1024
|
+
export const isUndefinedOrNull = (element) => {
|
|
1025
|
+
return element === undefined || element === null;
|
|
1026
|
+
};
|
|
1027
|
+
/**
|
|
1028
|
+
* The capitalizeArrayString function takes an array of strings and returns a new array with each string capitalized.
|
|
1029
|
+
*
|
|
1030
|
+
*
|
|
1031
|
+
* @param values: T Specify the type of values that will be passed into the function
|
|
1032
|
+
*
|
|
1033
|
+
* @return An array of strings
|
|
1034
|
+
*
|
|
1035
|
+
* @docauthor Ibrahima Touré
|
|
1036
|
+
*/
|
|
1037
|
+
export const capitalizeArrayString = (values) => {
|
|
1038
|
+
return [...values].flatMap(v => capitalize(v));
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* The camelArrayString function takes an array of strings and returns a new array with the same values, but in camelCase.
|
|
1042
|
+
*
|
|
1043
|
+
*
|
|
1044
|
+
* @param values: T Infer the type of values
|
|
1045
|
+
*
|
|
1046
|
+
* @return A string array with the first letter capitalized
|
|
1047
|
+
*
|
|
1048
|
+
* @docauthor Ibrahima Touré
|
|
1049
|
+
*/
|
|
1050
|
+
export const camelArrayString = (values) => {
|
|
1051
|
+
return [...values].flatMap(v => toCamelCase(v));
|
|
1052
|
+
};
|
|
1053
|
+
export const kebabArrayString = (values) => {
|
|
1054
|
+
const result = [];
|
|
1055
|
+
for (let i = 0; i < values.length; i++) {
|
|
1056
|
+
result.push(camelToKebab(values[i]));
|
|
1057
|
+
}
|
|
1058
|
+
return result;
|
|
1059
|
+
};
|
|
1060
|
+
export const valueToArray = (object, key) => {
|
|
1061
|
+
const obj = Object.assign({}, object);
|
|
1062
|
+
let result = {};
|
|
1063
|
+
Object.keys(obj).forEach(k => {
|
|
1064
|
+
result = Object.assign(Object.assign({}, result), { [k]: [key] });
|
|
1065
|
+
});
|
|
1066
|
+
return result;
|
|
1067
|
+
};
|
|
1068
|
+
export const kebabObjectKeys = (values, _keys = [], _excludedKeys = []) => {
|
|
1069
|
+
const obj = Object.assign({}, values);
|
|
1070
|
+
let result = {};
|
|
1071
|
+
const excludedKeys = uniq(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', ..._excludedKeys]);
|
|
1072
|
+
const keys = Object.keys(obj);
|
|
1073
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1074
|
+
const v = keys[i];
|
|
1075
|
+
let key = v;
|
|
1076
|
+
if (v !== v.toUpperCase()) {
|
|
1077
|
+
if (v.length > 0) {
|
|
1078
|
+
if (!v.includes(':')) {
|
|
1079
|
+
key = camelToKebab(v);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
if (checkType(obj[v]).is_object && Object.keys(obj[v]).length > 0) {
|
|
1084
|
+
if (excludedKeys.some(ek => ek === v) || (_keys.length > 0 && !_keys.some(ek => ek === v))) {
|
|
1085
|
+
key = v;
|
|
1086
|
+
}
|
|
1087
|
+
result = Object.assign(Object.assign({}, result), { [key]: kebabObjectKeys(obj[v]) });
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
result = Object.assign(Object.assign({}, result), { [key]: obj[v] });
|
|
1091
|
+
}
|
|
1092
|
+
// if(obj.hasOwnProperty(v)){
|
|
1093
|
+
// // console.log('kebab', {ob: obj[v], v})
|
|
1094
|
+
// }
|
|
1095
|
+
}
|
|
1096
|
+
// Object.keys(obj).forEach(v=>{
|
|
1097
|
+
// // console.log('r', result)
|
|
1098
|
+
// })
|
|
1099
|
+
return result;
|
|
1100
|
+
};
|
|
1101
|
+
/**
|
|
1102
|
+
* The capitalize function takes a string and returns the same string with the first letter capitalized.
|
|
1103
|
+
*
|
|
1104
|
+
*
|
|
1105
|
+
* @param word: T Define the type of the word parameter
|
|
1106
|
+
*
|
|
1107
|
+
* @return A string that is the same as the input except for the first letter, which is capitalized
|
|
1108
|
+
*
|
|
1109
|
+
* @docauthor Ibrahima Touré
|
|
1110
|
+
*/
|
|
1111
|
+
export const capitalize = (word) => {
|
|
1112
|
+
if (isCapitalized(word)) {
|
|
1113
|
+
return word;
|
|
1114
|
+
}
|
|
1115
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
1116
|
+
};
|
|
1117
|
+
export const arrayToObject = (arr) => {
|
|
1118
|
+
return [...arr].reduce((accum, currentValue) => {
|
|
1119
|
+
let acc = Object.assign(Object.assign({}, accum), currentValue);
|
|
1120
|
+
return acc;
|
|
1121
|
+
}, {});
|
|
1122
|
+
};
|
|
1123
|
+
export const mapObjects = (object, object2) => {
|
|
1124
|
+
return Object.assign(Object.assign({}, object), object2);
|
|
1125
|
+
};
|
|
1126
|
+
const valueOrDefault = (value, defaultValue) => {
|
|
1127
|
+
if (typeof value !== "undefined") {
|
|
1128
|
+
return value;
|
|
1129
|
+
}
|
|
1130
|
+
return defaultValue;
|
|
1131
|
+
};
|
|
1132
|
+
export const arrayToRgba = (value) => {
|
|
1133
|
+
const alpha = valueOrDefault(value[3], 1);
|
|
1134
|
+
let a;
|
|
1135
|
+
let separator = ',';
|
|
1136
|
+
if (alpha.toString().includes('var')) {
|
|
1137
|
+
a = alpha;
|
|
1138
|
+
}
|
|
1139
|
+
else {
|
|
1140
|
+
const num = toNumber(alpha);
|
|
1141
|
+
if (num && num.value !== 1) {
|
|
1142
|
+
a = num.value;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
if (a) {
|
|
1146
|
+
separator = ' ';
|
|
1147
|
+
}
|
|
1148
|
+
return `rgb(${valueOrDefault(value[0], 0)}${separator}${valueOrDefault(value[1], 0)}${separator}${valueOrDefault(value[2], 0)}${a ? `${separator + '/' + separator}` + a : ''})`;
|
|
1149
|
+
};
|
|
1150
|
+
export const toNumber = (val) => {
|
|
1151
|
+
if (typeof val === 'string' || typeof val === 'number') {
|
|
1152
|
+
const float = parseFloat(val.toString());
|
|
1153
|
+
const int = parseInt(val.toString());
|
|
1154
|
+
if (!Number.isNaN(float) && !Number.isNaN(int)) {
|
|
1155
|
+
return { int, float, value: float === int ? int : float };
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
return null;
|
|
1159
|
+
};
|
|
1160
|
+
export const formatRgba = (r, g, b, _a = 1) => {
|
|
1161
|
+
if (!isInt(r)) {
|
|
1162
|
+
return r;
|
|
1163
|
+
}
|
|
1164
|
+
let a;
|
|
1165
|
+
let separator = ',';
|
|
1166
|
+
if (_a.toString().includes('var')) {
|
|
1167
|
+
a = _a;
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
const num = toNumber(_a);
|
|
1171
|
+
if (num && num.value !== 1) {
|
|
1172
|
+
a = _a;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
if (a) {
|
|
1176
|
+
separator = ' ';
|
|
1177
|
+
}
|
|
1178
|
+
return `rgb(${r}${separator}${g}${separator}${b}${a ? `${separator + '/' + separator}` + a : ''})`;
|
|
1179
|
+
};
|
|
1180
|
+
const hexToRgba = (hex_color) => {
|
|
1181
|
+
const hexRegEx = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{0,2})$/i;
|
|
1182
|
+
const result = hexRegEx.exec(hex_color);
|
|
1183
|
+
if (result === null) {
|
|
1184
|
+
throw new Error('Invalid hex value.');
|
|
1185
|
+
}
|
|
1186
|
+
const alpha = parseInt(result[4] || 'ff', 16) / 255;
|
|
1187
|
+
return result ? [parseInt(result[1], 16), parseInt(result[2] || '00', 16), parseInt(result[3] || '00', 16), alpha] : [];
|
|
1188
|
+
};
|
|
1189
|
+
export const extractRgbaAttr = (_r, _g, _b, _a = 1) => {
|
|
1190
|
+
var _c, _d, _e, _f;
|
|
1191
|
+
let r = _r;
|
|
1192
|
+
let g = _g;
|
|
1193
|
+
let b = _b;
|
|
1194
|
+
let a = _a;
|
|
1195
|
+
if (r.startsWith('var')) {
|
|
1196
|
+
return null;
|
|
1197
|
+
}
|
|
1198
|
+
const find = HTML_COLORS.slice().find(c => c.name.toLowerCase() === r);
|
|
1199
|
+
if (r.startsWith('#')) {
|
|
1200
|
+
const rgbaArr = hexToRgba(r);
|
|
1201
|
+
if (rgbaArr.length > 0) {
|
|
1202
|
+
r = rgbaArr[0] || 0;
|
|
1203
|
+
g = rgbaArr[1] || 0;
|
|
1204
|
+
b = rgbaArr[2] || 0;
|
|
1205
|
+
a = rgbaArr[3] || 1;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
else if (r.toString().startsWith('rgb') || find) {
|
|
1209
|
+
let rp = 'rgb';
|
|
1210
|
+
let str = '';
|
|
1211
|
+
if (find) {
|
|
1212
|
+
str = find.rgb.toLowerCase().replace(`${rp}(`, "").replace(")", "");
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
if (r.startsWith('rgba')) {
|
|
1216
|
+
rp = 'rgba';
|
|
1217
|
+
}
|
|
1218
|
+
str = r.toLowerCase().replace(`${rp}(`, "").replace(")", "");
|
|
1219
|
+
}
|
|
1220
|
+
str = str.trim();
|
|
1221
|
+
if (str.split("/").length === 2) {
|
|
1222
|
+
let rep = str.split('/');
|
|
1223
|
+
let d = rep[0].trim().split(' ');
|
|
1224
|
+
if (d.length < 3) {
|
|
1225
|
+
d = rep[0].trim().split(',');
|
|
1226
|
+
}
|
|
1227
|
+
if (d.length === 3) {
|
|
1228
|
+
r = d[0] ? d[0].toString().trim() : 0;
|
|
1229
|
+
g = d[1] ? d[1].toString().trim() : 0;
|
|
1230
|
+
b = d[2] ? d[2].toString().trim() : 0;
|
|
1231
|
+
a = rep[1] ? rep[1].toString().trim() : 1;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
let rep = str.split(",");
|
|
1236
|
+
if (rep.length < 3) {
|
|
1237
|
+
rep = str.split(" ");
|
|
1238
|
+
}
|
|
1239
|
+
r = rep[0] || 0;
|
|
1240
|
+
g = rep[1] || 0;
|
|
1241
|
+
b = rep[2] || 0;
|
|
1242
|
+
a = rep[3] || 1;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
if (!g || !b) {
|
|
1246
|
+
return null;
|
|
1247
|
+
}
|
|
1248
|
+
r = (_c = toNumber(r.toString().trim())) === null || _c === void 0 ? void 0 : _c.value;
|
|
1249
|
+
g = (_d = toNumber(g.toString().trim())) === null || _d === void 0 ? void 0 : _d.value;
|
|
1250
|
+
b = (_e = toNumber(b.toString().trim())) === null || _e === void 0 ? void 0 : _e.value;
|
|
1251
|
+
a = (_f = toNumber(a.toString().trim())) === null || _f === void 0 ? void 0 : _f.value;
|
|
1252
|
+
const result = { r, g, b, a, array: [r, g, b, a] };
|
|
1253
|
+
return result;
|
|
1254
|
+
};
|
|
1255
|
+
export const asInt = (values) => {
|
|
1256
|
+
if (!Number.isNaN(parseInt(values))) {
|
|
1257
|
+
if (parseInt(values.toString()).toString() === values.toString() || parseFloat(values.toString()).toString() === values.toString()) {
|
|
1258
|
+
if (parseFloat(values.toString()).toString() === values.toString()) {
|
|
1259
|
+
return parseFloat(values.toString());
|
|
1260
|
+
}
|
|
1261
|
+
return parseInt(values.toString());
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
return values;
|
|
1265
|
+
};
|
|
1266
|
+
export const isInt = (values) => {
|
|
1267
|
+
if (!Number.isNaN(parseInt(values))) {
|
|
1268
|
+
if (parseInt(values.toString()).toString() === values.toString()) {
|
|
1269
|
+
return true;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
return false;
|
|
1273
|
+
};
|
|
1274
|
+
export const assignKeys = (keys, value, kebab = false) => {
|
|
1275
|
+
let result = {};
|
|
1276
|
+
const val = value;
|
|
1277
|
+
const valType = checkType(val);
|
|
1278
|
+
const _keys = [...keys];
|
|
1279
|
+
for (const k of _keys) {
|
|
1280
|
+
// let k = _keys[i]
|
|
1281
|
+
if (valType.is_object) {
|
|
1282
|
+
const vO = checkType(val[k]);
|
|
1283
|
+
if (vO.is_undefined) {
|
|
1284
|
+
result = Object.assign(Object.assign({}, result), { [!kebab ? k : camelToKebab(k)]: val });
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
result = Object.assign(Object.assign({}, result), { [!kebab ? k : camelToKebab(k)]: val[k] });
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
result = Object.assign(Object.assign({}, result), { [!kebab ? k : camelToKebab(k)]: val });
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return result;
|
|
1295
|
+
};
|
|
1296
|
+
export const projectKeys = (object, key, key1, key2 = null, key3 = null) => {
|
|
1297
|
+
let result = {};
|
|
1298
|
+
const obj = Object.assign({}, object);
|
|
1299
|
+
const projected = Object.assign({}, Object.keys(obj).flatMap(k => {
|
|
1300
|
+
const v = obj[k];
|
|
1301
|
+
const t = checkType(v);
|
|
1302
|
+
if (t.is_array) {
|
|
1303
|
+
result = Object.assign(Object.assign({}, result), { [k]: Object.assign(Object.assign(Object.assign(Object.assign({}, (!checkType(v[0]).is_undefined ? { [key]: v[0] } : {})), (!checkType(v[1]).is_undefined ? { [key1]: v[1] } : {})), (!checkType(v[2]).is_undefined ? { [key2]: v[2] } : {})), (!checkType(v[3]).is_undefined ? { [key3]: v[3] } : {})) });
|
|
1304
|
+
}
|
|
1305
|
+
return result;
|
|
1306
|
+
}).pop());
|
|
1307
|
+
return projected;
|
|
1308
|
+
};
|
|
1309
|
+
export const StylePatternsFlattened = pickSub(Object.assign({}, StylePatterns));
|
|
1310
|
+
//# sourceMappingURL=helper.js.map
|