@contember/utilities 1.2.7 → 1.3.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/assert-types/AssertionError.cjs +9 -0
- package/dist/development/assert-types/AssertionError.cjs.map +1 -0
- package/dist/development/assert-types/AssertionError.js.map +1 -1
- package/dist/development/assert-types/Predicates.cjs +7 -0
- package/dist/development/assert-types/Predicates.cjs.map +1 -0
- package/dist/development/assert-types/Predicates.js +2 -103
- package/dist/development/assert-types/Predicates.js.map +1 -1
- package/dist/development/assert-types/assert.cjs +10 -0
- package/dist/development/assert-types/assert.cjs.map +1 -0
- package/dist/development/assert-types/assertNever.cjs +7 -0
- package/dist/development/assert-types/assertNever.cjs.map +1 -0
- package/dist/development/class-name/colorSchemeClassName.cjs +12 -0
- package/dist/development/class-name/colorSchemeClassName.cjs.map +1 -0
- package/dist/development/class-name/colorSchemeClassName.js +1 -5
- package/dist/development/class-name/colorSchemeClassName.js.map +1 -1
- package/dist/development/class-name/constants.cjs +7 -0
- package/dist/development/class-name/constants.cjs.map +1 -0
- package/dist/development/class-name/constants.js +1 -1
- package/dist/development/class-name/constants.js.map +1 -1
- package/dist/development/class-name/deduplicateClassName.cjs +7 -0
- package/dist/development/class-name/deduplicateClassName.cjs.map +1 -0
- package/dist/development/class-name/filterThemedClassName.cjs +46 -0
- package/dist/development/class-name/filterThemedClassName.cjs.map +1 -0
- package/dist/development/class-name/filterThemedClassName.js +8 -30
- package/dist/development/class-name/filterThemedClassName.js.map +1 -1
- package/dist/development/class-name/flatClassNameList.cjs +16 -0
- package/dist/development/class-name/flatClassNameList.cjs.map +1 -0
- package/dist/development/class-name/listClassName.cjs +9 -0
- package/dist/development/class-name/listClassName.cjs.map +1 -0
- package/dist/development/class-name/themeClassName.cjs +18 -0
- package/dist/development/class-name/themeClassName.cjs.map +1 -0
- package/dist/development/class-name/themeClassName.js +7 -7
- package/dist/development/class-name/themeClassName.js.map +1 -1
- package/dist/development/css-utilities/px.cjs +7 -0
- package/dist/development/css-utilities/px.cjs.map +1 -0
- package/dist/development/css-utilities/px.js.map +1 -1
- package/dist/development/data-utilities/dateToStringWithoutTimezone.cjs +20 -0
- package/dist/development/data-utilities/dateToStringWithoutTimezone.cjs.map +1 -0
- package/dist/development/data-utilities/dateToStringWithoutTimezone.js +20 -0
- package/dist/development/data-utilities/dateToStringWithoutTimezone.js.map +1 -0
- package/dist/development/deprecate/deprecate.cjs +6 -0
- package/dist/development/deprecate/deprecate.cjs.map +1 -0
- package/dist/development/deprecate/deprecate.js.map +1 -1
- package/dist/development/dom/dataAttribute.cjs +13 -0
- package/dist/development/dom/dataAttribute.cjs.map +1 -0
- package/dist/development/dom/getElementDimensions.cjs +22 -0
- package/dist/development/dom/getElementDimensions.cjs.map +1 -0
- package/dist/development/dom/getSizeFromResizeObserverEntry.cjs +24 -0
- package/dist/development/dom/getSizeFromResizeObserverEntry.cjs.map +1 -0
- package/dist/development/dom/shouldCancelStart.cjs +29 -0
- package/dist/development/dom/shouldCancelStart.cjs.map +1 -0
- package/dist/development/dom/shouldCancelStart.js +29 -0
- package/dist/development/dom/shouldCancelStart.js.map +1 -0
- package/dist/development/dom/stateDataAttributes.cjs +11 -0
- package/dist/development/dom/stateDataAttributes.cjs.map +1 -0
- package/dist/development/dom/stateDataAttributes.js.map +1 -1
- package/dist/development/dom/svgSizeProps.cjs +15 -0
- package/dist/development/dom/svgSizeProps.cjs.map +1 -0
- package/dist/development/dom/svgSizeProps.js.map +1 -1
- package/dist/development/functional/omit.cjs +15 -0
- package/dist/development/functional/omit.cjs.map +1 -0
- package/dist/development/functional/omit.js.map +1 -1
- package/dist/development/functional/pick.cjs +15 -0
- package/dist/development/functional/pick.cjs.map +1 -0
- package/dist/development/functional/pick.js.map +1 -1
- package/dist/development/functional/range.cjs +7 -0
- package/dist/development/functional/range.cjs.map +1 -0
- package/dist/development/index.cjs +56 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +6 -44
- package/dist/development/index.js.map +1 -1
- package/dist/development/string-utilities/kebabCase.cjs +8 -0
- package/dist/development/string-utilities/kebabCase.cjs.map +1 -0
- package/dist/production/assert-types/AssertionError.cjs +9 -0
- package/dist/production/assert-types/AssertionError.cjs.map +1 -0
- package/dist/production/assert-types/AssertionError.js.map +1 -1
- package/dist/production/assert-types/Predicates.cjs +7 -0
- package/dist/production/assert-types/Predicates.cjs.map +1 -0
- package/dist/production/assert-types/Predicates.js +2 -103
- package/dist/production/assert-types/Predicates.js.map +1 -1
- package/dist/production/assert-types/assert.cjs +10 -0
- package/dist/production/assert-types/assert.cjs.map +1 -0
- package/dist/production/assert-types/assertNever.cjs +7 -0
- package/dist/production/assert-types/assertNever.cjs.map +1 -0
- package/dist/production/class-name/colorSchemeClassName.cjs +12 -0
- package/dist/production/class-name/colorSchemeClassName.cjs.map +1 -0
- package/dist/production/class-name/colorSchemeClassName.js +1 -5
- package/dist/production/class-name/colorSchemeClassName.js.map +1 -1
- package/dist/production/class-name/constants.cjs +7 -0
- package/dist/production/class-name/constants.cjs.map +1 -0
- package/dist/production/class-name/constants.js +1 -1
- package/dist/production/class-name/constants.js.map +1 -1
- package/dist/production/class-name/deduplicateClassName.cjs +7 -0
- package/dist/production/class-name/deduplicateClassName.cjs.map +1 -0
- package/dist/production/class-name/filterThemedClassName.cjs +46 -0
- package/dist/production/class-name/filterThemedClassName.cjs.map +1 -0
- package/dist/production/class-name/filterThemedClassName.js +8 -30
- package/dist/production/class-name/filterThemedClassName.js.map +1 -1
- package/dist/production/class-name/flatClassNameList.cjs +16 -0
- package/dist/production/class-name/flatClassNameList.cjs.map +1 -0
- package/dist/production/class-name/listClassName.cjs +9 -0
- package/dist/production/class-name/listClassName.cjs.map +1 -0
- package/dist/production/class-name/themeClassName.cjs +18 -0
- package/dist/production/class-name/themeClassName.cjs.map +1 -0
- package/dist/production/class-name/themeClassName.js +7 -7
- package/dist/production/class-name/themeClassName.js.map +1 -1
- package/dist/production/css-utilities/px.cjs +7 -0
- package/dist/production/css-utilities/px.cjs.map +1 -0
- package/dist/production/css-utilities/px.js.map +1 -1
- package/dist/production/data-utilities/dateToStringWithoutTimezone.cjs +20 -0
- package/dist/production/data-utilities/dateToStringWithoutTimezone.cjs.map +1 -0
- package/dist/production/data-utilities/dateToStringWithoutTimezone.js +20 -0
- package/dist/production/data-utilities/dateToStringWithoutTimezone.js.map +1 -0
- package/dist/production/deprecate/deprecate.cjs +6 -0
- package/dist/production/deprecate/deprecate.cjs.map +1 -0
- package/dist/production/deprecate/deprecate.js.map +1 -1
- package/dist/production/dom/dataAttribute.cjs +13 -0
- package/dist/production/dom/dataAttribute.cjs.map +1 -0
- package/dist/production/dom/getElementDimensions.cjs +22 -0
- package/dist/production/dom/getElementDimensions.cjs.map +1 -0
- package/dist/production/dom/getSizeFromResizeObserverEntry.cjs +24 -0
- package/dist/production/dom/getSizeFromResizeObserverEntry.cjs.map +1 -0
- package/dist/production/dom/shouldCancelStart.cjs +29 -0
- package/dist/production/dom/shouldCancelStart.cjs.map +1 -0
- package/dist/production/dom/shouldCancelStart.js +29 -0
- package/dist/production/dom/shouldCancelStart.js.map +1 -0
- package/dist/production/dom/stateDataAttributes.cjs +11 -0
- package/dist/production/dom/stateDataAttributes.cjs.map +1 -0
- package/dist/production/dom/stateDataAttributes.js.map +1 -1
- package/dist/production/dom/svgSizeProps.cjs +15 -0
- package/dist/production/dom/svgSizeProps.cjs.map +1 -0
- package/dist/production/dom/svgSizeProps.js.map +1 -1
- package/dist/production/functional/omit.cjs +15 -0
- package/dist/production/functional/omit.cjs.map +1 -0
- package/dist/production/functional/omit.js.map +1 -1
- package/dist/production/functional/pick.cjs +15 -0
- package/dist/production/functional/pick.cjs.map +1 -0
- package/dist/production/functional/pick.js.map +1 -1
- package/dist/production/functional/range.cjs +7 -0
- package/dist/production/functional/range.cjs.map +1 -0
- package/dist/production/index.cjs +56 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +6 -44
- package/dist/production/index.js.map +1 -1
- package/dist/production/string-utilities/kebabCase.cjs +8 -0
- package/dist/production/string-utilities/kebabCase.cjs.map +1 -0
- package/dist/types/assert-types/Predicates.d.ts +0 -25
- package/dist/types/assert-types/Predicates.d.ts.map +1 -1
- package/dist/types/assert-types/types.d.ts +0 -3
- package/dist/types/assert-types/types.d.ts.map +1 -1
- package/dist/types/class-name/colorSchemeClassName.d.ts +3 -6
- package/dist/types/class-name/colorSchemeClassName.d.ts.map +1 -1
- package/dist/types/class-name/constants.d.ts +0 -18
- package/dist/types/class-name/constants.d.ts.map +1 -1
- package/dist/types/class-name/filterThemedClassName.d.ts +2 -2
- package/dist/types/class-name/filterThemedClassName.d.ts.map +1 -1
- package/dist/types/class-name/index.d.ts +0 -1
- package/dist/types/class-name/index.d.ts.map +1 -1
- package/dist/types/class-name/themeClassName.d.ts +6 -15
- package/dist/types/class-name/themeClassName.d.ts.map +1 -1
- package/dist/types/class-name/types.d.ts +0 -4
- package/dist/types/class-name/types.d.ts.map +1 -1
- package/dist/types/css-utilities/px.d.ts +6 -4
- package/dist/types/css-utilities/px.d.ts.map +1 -1
- package/dist/types/data-utilities/dateToStringWithoutTimezone.d.ts +4 -0
- package/dist/types/data-utilities/dateToStringWithoutTimezone.d.ts.map +1 -0
- package/dist/types/data-utilities/index.d.ts +2 -0
- package/dist/types/data-utilities/index.d.ts.map +1 -0
- package/dist/types/deprecate/index.d.ts +0 -1
- package/dist/types/deprecate/index.d.ts.map +1 -1
- package/dist/types/dom/index.d.ts +1 -3
- package/dist/types/dom/index.d.ts.map +1 -1
- package/dist/types/dom/shouldCancelStart.d.ts +4 -0
- package/dist/types/dom/shouldCancelStart.d.ts.map +1 -0
- package/dist/types/functional/index.d.ts +0 -2
- package/dist/types/functional/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/string-utilities/index.d.ts +0 -2
- package/dist/types/string-utilities/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/Narrow.d.ts +1 -2
- package/dist/types/types/Narrow.d.ts.map +1 -1
- package/dist/types/types/PolymorphicRefs.d.ts +2 -1
- package/dist/types/types/PolymorphicRefs.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +0 -9
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/assert-types/Predicates.ts +1 -86
- package/src/assert-types/types.ts +0 -4
- package/src/class-name/colorSchemeClassName.ts +5 -12
- package/src/class-name/constants.ts +1 -19
- package/src/class-name/filterThemedClassName.ts +14 -41
- package/src/class-name/index.ts +0 -1
- package/src/class-name/themeClassName.ts +11 -37
- package/src/class-name/types.ts +0 -10
- package/src/css-utilities/px.ts +0 -7
- package/src/data-utilities/dateToStringWithoutTimezone.ts +18 -0
- package/src/data-utilities/index.ts +1 -0
- package/src/deprecate/deprecate.ts +1 -1
- package/src/deprecate/index.ts +0 -1
- package/src/dom/index.ts +1 -3
- package/src/dom/shouldCancelStart.ts +32 -0
- package/src/functional/index.ts +0 -2
- package/src/index.ts +1 -0
- package/src/string-utilities/index.ts +0 -2
- package/src/types/Narrow.ts +1 -3
- package/src/types/PolymorphicRefs.ts +3 -1
- package/src/types/index.ts +0 -21
- package/dist/development/class-name/stateClassName.js +0 -11
- package/dist/development/class-name/stateClassName.js.map +0 -1
- package/dist/development/deprecate/fallback.js +0 -11
- package/dist/development/deprecate/fallback.js.map +0 -1
- package/dist/development/dom/getMatchingParentElement.js +0 -17
- package/dist/development/dom/getMatchingParentElement.js.map +0 -1
- package/dist/development/dom/isScrollable.js +0 -22
- package/dist/development/dom/isScrollable.js.map +0 -1
- package/dist/development/dom/parseTransformMatrix.js +0 -29
- package/dist/development/dom/parseTransformMatrix.js.map +0 -1
- package/dist/development/functional/extend.js +0 -33
- package/dist/development/functional/extend.js.map +0 -1
- package/dist/development/functional/setHasOneOf.js +0 -7
- package/dist/development/functional/setHasOneOf.js.map +0 -1
- package/dist/development/string-utilities/capitalize.js +0 -7
- package/dist/development/string-utilities/capitalize.js.map +0 -1
- package/dist/development/string-utilities/trimString.js +0 -8
- package/dist/development/string-utilities/trimString.js.map +0 -1
- package/dist/production/class-name/stateClassName.js +0 -11
- package/dist/production/class-name/stateClassName.js.map +0 -1
- package/dist/production/deprecate/fallback.js +0 -11
- package/dist/production/deprecate/fallback.js.map +0 -1
- package/dist/production/dom/getMatchingParentElement.js +0 -17
- package/dist/production/dom/getMatchingParentElement.js.map +0 -1
- package/dist/production/dom/isScrollable.js +0 -22
- package/dist/production/dom/isScrollable.js.map +0 -1
- package/dist/production/dom/parseTransformMatrix.js +0 -29
- package/dist/production/dom/parseTransformMatrix.js.map +0 -1
- package/dist/production/functional/extend.js +0 -33
- package/dist/production/functional/extend.js.map +0 -1
- package/dist/production/functional/setHasOneOf.js +0 -7
- package/dist/production/functional/setHasOneOf.js.map +0 -1
- package/dist/production/string-utilities/capitalize.js +0 -7
- package/dist/production/string-utilities/capitalize.js.map +0 -1
- package/dist/production/string-utilities/trimString.js +0 -8
- package/dist/production/string-utilities/trimString.js.map +0 -1
- package/dist/types/class-name/stateClassName.d.ts +0 -19
- package/dist/types/class-name/stateClassName.d.ts.map +0 -1
- package/dist/types/deprecate/fallback.d.ts +0 -2
- package/dist/types/deprecate/fallback.d.ts.map +0 -1
- package/dist/types/dom/getMatchingParentElement.d.ts +0 -2
- package/dist/types/dom/getMatchingParentElement.d.ts.map +0 -1
- package/dist/types/dom/isScrollable.d.ts +0 -7
- package/dist/types/dom/isScrollable.d.ts.map +0 -1
- package/dist/types/dom/parseTransformMatrix.d.ts +0 -15
- package/dist/types/dom/parseTransformMatrix.d.ts.map +0 -1
- package/dist/types/functional/extend.d.ts +0 -5
- package/dist/types/functional/extend.d.ts.map +0 -1
- package/dist/types/functional/setHasOneOf.d.ts +0 -2
- package/dist/types/functional/setHasOneOf.d.ts.map +0 -1
- package/dist/types/string-utilities/capitalize.d.ts +0 -2
- package/dist/types/string-utilities/capitalize.d.ts.map +0 -1
- package/dist/types/string-utilities/trimString.d.ts +0 -9
- package/dist/types/string-utilities/trimString.d.ts.map +0 -1
- package/dist/types/types/Any.d.ts +0 -4
- package/dist/types/types/Any.d.ts.map +0 -1
- package/dist/types/types/DeepPartial.d.ts +0 -4
- package/dist/types/types/DeepPartial.d.ts.map +0 -1
- package/dist/types/types/NonNullableRequired.d.ts +0 -4
- package/dist/types/types/NonNullableRequired.d.ts.map +0 -1
- package/dist/types/types/ObjectKeyValue.d.ts +0 -4
- package/dist/types/types/ObjectKeyValue.d.ts.map +0 -1
- package/dist/types/types/Primitive.d.ts +0 -2
- package/dist/types/types/Primitive.d.ts.map +0 -1
- package/dist/types/types/RequiredDeepPlainObject.d.ts +0 -4
- package/dist/types/types/RequiredDeepPlainObject.d.ts.map +0 -1
- package/dist/types/types/Try.d.ts +0 -2
- package/dist/types/types/Try.d.ts.map +0 -1
- package/dist/types/types/TypeofStringLiteral.d.ts +0 -2
- package/dist/types/types/TypeofStringLiteral.d.ts.map +0 -1
- package/src/class-name/stateClassName.ts +0 -32
- package/src/deprecate/fallback.ts +0 -7
- package/src/dom/getMatchingParentElement.ts +0 -13
- package/src/dom/isScrollable.ts +0 -24
- package/src/dom/parseTransformMatrix.ts +0 -35
- package/src/functional/extend.ts +0 -37
- package/src/functional/setHasOneOf.ts +0 -3
- package/src/string-utilities/capitalize.ts +0 -3
- package/src/string-utilities/trimString.ts +0 -12
- package/src/types/Any.ts +0 -3
- package/src/types/DeepPartial.ts +0 -7
- package/src/types/NonNullableRequired.ts +0 -1
- package/src/types/ObjectKeyValue.ts +0 -1
- package/src/types/Primitive.ts +0 -1
- package/src/types/RequiredDeepPlainObject.ts +0 -3
- package/src/types/Try.ts +0 -4
- package/src/types/TypeofStringLiteral.ts +0 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { KebabCase } from 'type-fest'
|
|
2
1
|
import { isColorSchemeClassName } from './colorSchemeClassName'
|
|
3
2
|
import { THEME_CLASS_NAME_REG_EXP } from './constants'
|
|
4
3
|
import { flatClassNameList } from './flatClassNameList'
|
|
5
4
|
import { contentThemeClassName, controlsThemeClassName } from './themeClassName'
|
|
6
|
-
import {
|
|
5
|
+
import { NestedClassName } from './types'
|
|
7
6
|
|
|
8
7
|
export type ThemeConfig = { content: string | undefined, controls: string | undefined }
|
|
9
8
|
|
|
10
9
|
export function filterThemedClassName(
|
|
11
10
|
nestedClassName: NestedClassName,
|
|
12
|
-
defaultColorSchemeContext:
|
|
11
|
+
defaultColorSchemeContext: string,
|
|
13
12
|
) {
|
|
14
13
|
const theme: ThemeConfig = { content: undefined, controls: undefined }
|
|
15
|
-
|
|
16
|
-
let colorScheme: ColorSchemeClassName | undefined = undefined
|
|
14
|
+
let colorScheme: string | undefined = undefined
|
|
17
15
|
|
|
18
16
|
const flatClassName = flatClassNameList(nestedClassName).map(className => {
|
|
19
17
|
if (isColorSchemeClassName(className)) {
|
|
@@ -24,34 +22,18 @@ export function filterThemedClassName(
|
|
|
24
22
|
const match = className.match(THEME_CLASS_NAME_REG_EXP)
|
|
25
23
|
|
|
26
24
|
if (match) {
|
|
27
|
-
const name = match.groups!.name
|
|
28
|
-
const scope = match.groups!.scope
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} else if (scope === 'content') {
|
|
38
|
-
stateThemes[state].content = name
|
|
39
|
-
} else if (scope === 'controls') {
|
|
40
|
-
stateThemes[state].controls = name
|
|
41
|
-
} else {
|
|
42
|
-
throw new Error(`Unknown theme scope: ${scope}`)
|
|
43
|
-
}
|
|
25
|
+
const name = match.groups!.name
|
|
26
|
+
const scope = match.groups!.scope
|
|
27
|
+
|
|
28
|
+
if (!scope) {
|
|
29
|
+
theme.content = name
|
|
30
|
+
theme.controls = name
|
|
31
|
+
} else if (scope === 'content') {
|
|
32
|
+
theme.content = name
|
|
33
|
+
} else if (scope === 'controls') {
|
|
34
|
+
theme.controls = name
|
|
44
35
|
} else {
|
|
45
|
-
|
|
46
|
-
theme.content = name
|
|
47
|
-
theme.controls = name
|
|
48
|
-
} else if (scope === 'content') {
|
|
49
|
-
theme.content = name
|
|
50
|
-
} else if (scope === 'controls') {
|
|
51
|
-
theme.controls = name
|
|
52
|
-
} else {
|
|
53
|
-
throw new Error(`Unknown theme scope: ${scope}`)
|
|
54
|
-
}
|
|
36
|
+
throw new Error(`Unknown theme scope: ${scope}`)
|
|
55
37
|
}
|
|
56
38
|
|
|
57
39
|
return undefined
|
|
@@ -67,15 +49,6 @@ export function filterThemedClassName(
|
|
|
67
49
|
|
|
68
50
|
themeClassNames.push(content, controls)
|
|
69
51
|
|
|
70
|
-
for (const state in stateThemes) {
|
|
71
|
-
const { content, controls } = stateThemes[state]
|
|
72
|
-
|
|
73
|
-
const contentClassName = contentThemeClassName(content, state as `:${KebabCase<string>}`)
|
|
74
|
-
const controlsClassName = controlsThemeClassName(controls, state as `:${KebabCase<string>}`)
|
|
75
|
-
|
|
76
|
-
themeClassNames.push(contentClassName, controlsClassName)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
52
|
const flatThemedClassName = flatClassNameList(themeClassNames)
|
|
80
53
|
|
|
81
54
|
if (flatThemedClassName.length > 0 || colorScheme) {
|
package/src/class-name/index.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { KebabCase } from 'type-fest'
|
|
2
|
-
import { ThemeContentClassName, ThemeControlsClassName } from './types'
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Returns a string with a content theme class name, prefixed with `theme-` and suffixed with `-content`
|
|
6
3
|
*
|
|
7
4
|
* IMPORTANT: Make sure to use color scheme class in combination with theme class names.
|
|
8
5
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param state - State of the theme starting with a ":", e.g. `":hover"`, `":focus"`, `":active"`, `":focus-visible"`
|
|
6
|
+
* @param theme - Theme name basis for content
|
|
11
7
|
* @returns A content theme class name
|
|
12
8
|
*
|
|
13
9
|
* @see {@link controlsThemeClassName}
|
|
@@ -18,9 +14,7 @@ import { ThemeContentClassName, ThemeControlsClassName } from './types'
|
|
|
18
14
|
* const colorScheme = colorSchemeClassName('system')
|
|
19
15
|
* // ^ 'scheme-system'
|
|
20
16
|
* const contentThemeClassName = contentThemeClassName('default')
|
|
21
|
-
* // ^ 'theme-default-content
|
|
22
|
-
* const dangerOnMouseOverTheme = controlsThemeClassName('danger', ':hover')
|
|
23
|
-
* // ^ 'theme-danger-controls:hover'
|
|
17
|
+
* // ^ 'theme-default-content'
|
|
24
18
|
*
|
|
25
19
|
* return (
|
|
26
20
|
* <div className={`${colorScheme} ${contentThemeClassName}`}>
|
|
@@ -29,14 +23,8 @@ import { ThemeContentClassName, ThemeControlsClassName } from './types'
|
|
|
29
23
|
* )
|
|
30
24
|
* ```
|
|
31
25
|
*/
|
|
32
|
-
export function contentThemeClassName
|
|
33
|
-
|
|
34
|
-
State extends `:${KebabCase<string>}` | null | undefined = undefined,
|
|
35
|
-
>(
|
|
36
|
-
theme: ContentTheme | null | undefined,
|
|
37
|
-
state?: State | null | undefined,
|
|
38
|
-
) {
|
|
39
|
-
return theme ? `theme-${theme}-content${state ?? ''}` as ThemeContentClassName<ContentTheme, State> : undefined
|
|
26
|
+
export function contentThemeClassName(theme: string | null | undefined): string | undefined {
|
|
27
|
+
return theme ? `theme-${theme}-content` : undefined
|
|
40
28
|
}
|
|
41
29
|
|
|
42
30
|
/**
|
|
@@ -45,7 +33,6 @@ export function contentThemeClassName<
|
|
|
45
33
|
* IMPORTANT: Make sure to use color scheme class in combination with theme class names.
|
|
46
34
|
*
|
|
47
35
|
* @param theme - Theme name basis for controls
|
|
48
|
-
* @param state - State of the theme starting with a ":", e.g. `":hover"`, `":focus"`, `":active"`, `":focus-visible"`
|
|
49
36
|
* @returns A controls theme class name
|
|
50
37
|
*
|
|
51
38
|
* @see {@link contentThemeClassName}
|
|
@@ -56,9 +43,7 @@ export function contentThemeClassName<
|
|
|
56
43
|
* const colorScheme = colorSchemeClassName('system')
|
|
57
44
|
* // ^ 'scheme-system'
|
|
58
45
|
* const contentThemeClassName = contentThemeClassName('default')
|
|
59
|
-
* // ^ 'theme-default-content
|
|
60
|
-
* const dangerOnMouseOverTheme = controlsThemeClassName('danger', ':hover')
|
|
61
|
-
* // ^ 'theme-danger-controls:hover'
|
|
46
|
+
* // ^ 'theme-default-content'
|
|
62
47
|
*
|
|
63
48
|
* return (
|
|
64
49
|
* <div className={`${colorScheme} ${contentThemeClassName}`}>
|
|
@@ -67,14 +52,8 @@ export function contentThemeClassName<
|
|
|
67
52
|
* )
|
|
68
53
|
* ```
|
|
69
54
|
*/
|
|
70
|
-
export function controlsThemeClassName
|
|
71
|
-
|
|
72
|
-
State extends `:${KebabCase<string>}` | null | undefined = undefined,
|
|
73
|
-
>(
|
|
74
|
-
theme: ControlsTheme | null | undefined,
|
|
75
|
-
state?: State | null | undefined,
|
|
76
|
-
) {
|
|
77
|
-
return theme ? `theme-${theme}-controls${state ?? ''}` as ThemeControlsClassName<ControlsTheme, State> : undefined
|
|
55
|
+
export function controlsThemeClassName(theme: string | null | undefined): string | undefined {
|
|
56
|
+
return theme ? `theme-${theme}-controls` : undefined
|
|
78
57
|
}
|
|
79
58
|
|
|
80
59
|
/**
|
|
@@ -83,7 +62,6 @@ export function controlsThemeClassName<
|
|
|
83
62
|
* IMPORTANT: Make sure to use color scheme class in combination with theme class names.
|
|
84
63
|
*
|
|
85
64
|
* @param theme - Theme name basis for content and controls
|
|
86
|
-
* @param state - State of the theme starting with a ":", e.g. `":hover"`, `":focus"`, `":active"`, `":focus-visible"`
|
|
87
65
|
* @returns A tuple with a content theme class name and a controls theme class name
|
|
88
66
|
*
|
|
89
67
|
* @see {@link contentThemeClassName}
|
|
@@ -102,15 +80,11 @@ export function controlsThemeClassName<
|
|
|
102
80
|
* )
|
|
103
81
|
* ```
|
|
104
82
|
*/
|
|
105
|
-
export function themeClassName
|
|
106
|
-
|
|
107
|
-
State extends `:${KebabCase<string>}` | null | undefined = undefined,
|
|
108
|
-
>(
|
|
109
|
-
theme: Theme | null | undefined,
|
|
110
|
-
state?: State | null | undefined,
|
|
83
|
+
export function themeClassName(
|
|
84
|
+
theme: string | null | undefined,
|
|
111
85
|
) {
|
|
112
86
|
return [
|
|
113
|
-
contentThemeClassName(theme
|
|
114
|
-
controlsThemeClassName(theme
|
|
87
|
+
contentThemeClassName(theme),
|
|
88
|
+
controlsThemeClassName(theme),
|
|
115
89
|
] as const
|
|
116
90
|
}
|
package/src/class-name/types.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { KebabCase } from 'type-fest'
|
|
2
|
-
|
|
3
1
|
export type NestedClassName = string | false | null | undefined | (string | false | null | undefined)[] | NestedClassName[]
|
|
4
2
|
export type ClassNameStateMap = { [key: string]: string | number | boolean | null | undefined }
|
|
5
3
|
|
|
@@ -7,11 +5,3 @@ export interface ComponentClassNameProps {
|
|
|
7
5
|
className?: NestedClassName;
|
|
8
6
|
componentClassName?: string | string[];
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
export type ColorSchemeClassName<T extends KebabCase<string> = KebabCase<string>> = `scheme-${T}`
|
|
12
|
-
export type ThemeContentClassName<T extends KebabCase<string> = KebabCase<string>, S extends `:${KebabCase<string>}` | null | undefined = undefined> = S extends string
|
|
13
|
-
? `theme-${T}-content${S}`
|
|
14
|
-
: `theme-${T}-content`
|
|
15
|
-
export type ThemeControlsClassName<T extends KebabCase<string> = KebabCase<string>, S extends `:${KebabCase<string>}` | null | undefined = undefined> = S extends string
|
|
16
|
-
? `theme-${T}-controls${S}`
|
|
17
|
-
: `theme-${T}-controls`
|
package/src/css-utilities/px.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export function px<V extends number>(value: V): `${V}px`;
|
|
2
|
-
export function px<V extends false>(value: V): '';
|
|
3
|
-
export function px<V extends null>(value: V): '';
|
|
4
|
-
export function px<V extends undefined>(value: V): '';
|
|
5
|
-
// NOTE: Next overload fixes:
|
|
6
|
-
// The call would have succeeded against this implementation, but implementation signatures of overloads are not externally visible.
|
|
7
|
-
export function px<V extends number | false | null | undefined>(value?: V): string;
|
|
8
1
|
/**
|
|
9
2
|
* Converts a value to a string in the format '10px'
|
|
10
3
|
*
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const dateToStringWithoutTimezone = (date: Date, { includeTime }: { includeTime?: boolean } = {}): string => {
|
|
2
|
+
const [year, month, day] = [
|
|
3
|
+
date.getFullYear(),
|
|
4
|
+
(date.getMonth() + 1).toFixed(0).padStart(2, '0'),
|
|
5
|
+
date.getDate().toFixed(0).padStart(2, '0'),
|
|
6
|
+
]
|
|
7
|
+
let serialized = `${year}-${month}-${day}`
|
|
8
|
+
|
|
9
|
+
if (includeTime) {
|
|
10
|
+
const [hours, minutes] = [
|
|
11
|
+
date.getHours().toFixed(0).padStart(2, '0'),
|
|
12
|
+
date.getMinutes().toFixed(0).padStart(2, '0'),
|
|
13
|
+
]
|
|
14
|
+
serialized += ` ${hours}:${minutes}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return serialized
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dateToStringWithoutTimezone'
|
|
@@ -24,7 +24,7 @@ export function deprecate(removal: SemverString, condition: boolean, deprecated:
|
|
|
24
24
|
if (shouldThrow) {
|
|
25
25
|
throw new Error(`Support for ${deprecated} was planned to be removed in the ${removal} release.${replacement ? ` Replace it with ${replacement} instead.` : 'Remove it.'}`)
|
|
26
26
|
} else {
|
|
27
|
-
console.warn(`Use of ${deprecated} is deprecated and might be removed in the next release.${replacement ? ` Use ${replacement} instead.` : 'There is no replacement.'}`)
|
|
27
|
+
console.warn(`Use of ${deprecated} is deprecated and might be removed in the next release.${replacement ? ` Use ${replacement} instead.` : ' There is no replacement.'}`)
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
package/src/deprecate/index.ts
CHANGED
package/src/dom/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from './dataAttribute'
|
|
2
2
|
export * from './getElementDimensions'
|
|
3
|
-
export * from './getMatchingParentElement'
|
|
4
3
|
export * from './getSizeFromResizeObserverEntry'
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './parseTransformMatrix'
|
|
4
|
+
export * from './shouldCancelStart'
|
|
7
5
|
export * from './stateDataAttributes'
|
|
8
6
|
export * from './svgSizeProps'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const interactiveElements = new Set(['INPUT', 'TEXTAREA', 'SELECT', 'OPTION', 'BUTTON'])
|
|
2
|
+
|
|
3
|
+
// This is almost completely copied from the defaultShouldCancelStart.js from react-sortable-hoc.
|
|
4
|
+
// We just needed to add support for slate void elements as well as some additional checks.
|
|
5
|
+
export const shouldCancelStart = (event: {target?: unknown}): boolean => {
|
|
6
|
+
// Cancel sorting if the event target is an `input`, `textarea`, `select` or `option`
|
|
7
|
+
if (!(event.target instanceof Element)) {
|
|
8
|
+
return true
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let el: Node | null = event.target
|
|
12
|
+
|
|
13
|
+
while (el) {
|
|
14
|
+
if (el instanceof Element) {
|
|
15
|
+
if (interactiveElements.has(el.tagName)) {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
if ((el as any).sortableHandle === true) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
if (el.getAttribute('data-slate-void') === 'true') {
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
if (el instanceof HTMLElement && el.contentEditable === 'true') {
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
el = el.parentNode
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return false
|
|
32
|
+
}
|
package/src/functional/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/types/Narrow.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Try } from './Try'
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Describes types that can be narrowed
|
|
5
3
|
*/
|
|
@@ -18,4 +16,4 @@ type NarrowRaw<A> =
|
|
|
18
16
|
: NarrowRaw<A[K]> })
|
|
19
17
|
|
|
20
18
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
21
|
-
export type Narrow<A extends any> =
|
|
19
|
+
export type Narrow<A extends any> = A extends [] ? A : NarrowRaw<A>
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// Source: https://github.com/emotion-js/emotion/blob/master/packages/styled-base/types/helper.d.ts
|
|
4
4
|
// A more precise version of just React.ComponentPropsWithoutRef on its own
|
|
5
|
+
import { ReactNode } from 'react'
|
|
6
|
+
|
|
5
7
|
export type PropsOf<
|
|
6
8
|
C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
|
|
7
9
|
> = JSX.LibraryManagedAttributes<C, React.ComponentPropsWithoutRef<C>>
|
|
@@ -64,5 +66,5 @@ export type PolymorphicComponentPropsWithRef<
|
|
|
64
66
|
* that the component accepts.
|
|
65
67
|
*/
|
|
66
68
|
export type PolymorphicComponent<T extends React.ElementType, P = {}> =
|
|
67
|
-
& (<C extends React.ElementType = T>(props: PolymorphicComponentPropsWithRef<C, P>) =>
|
|
69
|
+
& (<C extends React.ElementType = T>(props: PolymorphicComponentPropsWithRef<C, P>) => ReactNode)
|
|
68
70
|
& { displayName?: string | undefined }
|
package/src/types/index.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
CamelCase,
|
|
3
|
-
DelimiterCase,
|
|
4
|
-
KebabCase,
|
|
5
|
-
LiteralToPrimitiveDeep,
|
|
6
|
-
MergeExclusive,
|
|
7
|
-
Opaque,
|
|
8
|
-
PascalCase,
|
|
9
|
-
Replace,
|
|
10
|
-
Simplify,
|
|
11
|
-
UnionToIntersection,
|
|
12
|
-
UnwrapOpaque,
|
|
13
|
-
} from 'type-fest'
|
|
14
|
-
export * from './Any'
|
|
15
|
-
export * from './DeepPartial'
|
|
16
1
|
export * from './Narrow'
|
|
17
|
-
export * from './NonNullableRequired'
|
|
18
2
|
export * from './NonOptional'
|
|
19
|
-
export * from './ObjectKeyValue'
|
|
20
3
|
export * from './PolymorphicRefs'
|
|
21
|
-
export * from './Primitive'
|
|
22
|
-
export * from './RequiredDeepPlainObject'
|
|
23
|
-
export * from './Try'
|
|
24
|
-
export * from './TypeofStringLiteral'
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { toKebabCase } from "../string-utilities/kebabCase.js";
|
|
2
|
-
function stateClassName(state = null, { glue = "-", removeFalsy = true } = {}) {
|
|
3
|
-
const entries = Object.entries(state ?? []).map(
|
|
4
|
-
([className, value]) => value || value === 0 || !removeFalsy ? value === true ? toKebabCase(className) : `${toKebabCase(className)}${glue}${value}` : ""
|
|
5
|
-
).filter(Boolean);
|
|
6
|
-
return entries;
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
stateClassName
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=stateClassName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateClassName.js","sources":["../../../src/class-name/stateClassName.ts"],"sourcesContent":["import { toKebabCase } from '../string-utilities'\nimport { ClassNameStateMap } from './types'\n\nexport interface StateClassNameOptions {\n\tglue?: string;\n\tremoveFalsy?: boolean;\n}\n\n/**\n * Combines a state map of class names into a single string\n *\n * @example\n * stateClassName({ foo: true, bar: false, baz: 1 }) // => 'foo baz-1'\n *\n * @param state - State map object with class names as keys and literals as values.\n * @param options - Options object\n * @param options.glue - Glue to use between the class name and the value, default is '-'. Set to '' to disable.\n * @param options.removeFalsy - Whether to remove falsy class names, default is true.\n * @returns Combined class names as string\n */\nexport function stateClassName(\n\tstate: ClassNameStateMap | null = null,\n\t{ glue = '-', removeFalsy = true }: StateClassNameOptions = {},\n): string[] {\n\tconst entries = Object.entries(state ?? []).map(\n\t\t([className, value]) => value || value === 0 || !removeFalsy\n\t\t\t? (value === true ? toKebabCase(className) : `${toKebabCase(className)}${glue}${value}`)\n\t\t\t: '',\n\t).filter(Boolean)\n\n\treturn entries\n}\n"],"names":[],"mappings":";AAoBgB,SAAA,eACf,QAAkC,MAClC,EAAE,OAAO,KAAK,cAAc,KAAgC,IAAA,IACjD;AACX,QAAM,UAAU,OAAO,QAAQ,SAAS,CAAA,CAAE,EAAE;AAAA,IAC3C,CAAC,CAAC,WAAW,KAAK,MAAM,SAAS,UAAU,KAAK,CAAC,cAC7C,UAAU,OAAO,YAAY,SAAS,IAAI,GAAG,YAAY,SAAS,IAAI,OAAO,UAC9E;AAAA,EAAA,EACF,OAAO,OAAO;AAET,SAAA;AACR;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.js","sources":["../../../src/deprecate/fallback.ts"],"sourcesContent":["export function fallback<R>(current: R, condition: boolean, mapped: R): R {\n\tif (condition === true) {\n\t\treturn mapped\n\t} else {\n\t\treturn current\n\t}\n}\n"],"names":[],"mappings":"AAAgB,SAAA,SAAY,SAAY,WAAoB,QAAc;AACzE,MAAI,cAAc,MAAM;AAChB,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
function getMatchingParentElement(element, predicate) {
|
|
2
|
-
if (!element || !element.parentElement) {
|
|
3
|
-
if (document.scrollingElement instanceof HTMLElement) {
|
|
4
|
-
return document.scrollingElement;
|
|
5
|
-
} else {
|
|
6
|
-
return document.body;
|
|
7
|
-
}
|
|
8
|
-
} else if (predicate(element.parentElement)) {
|
|
9
|
-
return element.parentElement;
|
|
10
|
-
} else {
|
|
11
|
-
return getMatchingParentElement(element.parentElement, predicate);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
getMatchingParentElement
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=getMatchingParentElement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMatchingParentElement.js","sources":["../../../src/dom/getMatchingParentElement.ts"],"sourcesContent":["export function getMatchingParentElement(element: HTMLElement | null, predicate: (element: HTMLElement | null) => boolean | Promise<boolean>): HTMLElement {\n if (!element || !element.parentElement) {\n if (document.scrollingElement instanceof HTMLElement) {\n return document.scrollingElement\n } else {\n return document.body\n }\n } else if (predicate(element.parentElement)) {\n return element.parentElement\n } else {\n return getMatchingParentElement(element.parentElement, predicate)\n }\n}\n"],"names":[],"mappings":"AAAgB,SAAA,yBAAyB,SAA6B,WAAqF;AACzJ,MAAI,CAAC,WAAW,CAAC,QAAQ,eAAe;AAClC,QAAA,SAAS,4BAA4B,aAAa;AACpD,aAAO,SAAS;AAAA,IAAA,OACX;AACL,aAAO,SAAS;AAAA,IAClB;AAAA,EACS,WAAA,UAAU,QAAQ,aAAa,GAAG;AAC3C,WAAO,QAAQ;AAAA,EAAA,OACV;AACE,WAAA,yBAAyB,QAAQ,eAAe,SAAS;AAAA,EAClE;AACF;"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
function isScrollable(element) {
|
|
2
|
-
if (element === document.scrollingElement) {
|
|
3
|
-
return true;
|
|
4
|
-
} else if (element instanceof HTMLElement) {
|
|
5
|
-
const contentOverflows = element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
|
|
6
|
-
if (contentOverflows) {
|
|
7
|
-
if (getComputedStyle(element).overflow === "hidden") {
|
|
8
|
-
return false;
|
|
9
|
-
} else {
|
|
10
|
-
return contentOverflows;
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
} else {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
isScrollable
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=isScrollable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isScrollable.js","sources":["../../../src/dom/isScrollable.ts"],"sourcesContent":["/**\n * Checks if an element is scrollable\n * @param element - Element to check\n * @returns Boolean indicating if the element is scrollable\n */\nexport function isScrollable(element: HTMLElement | null) {\n\tif (element === document.scrollingElement) {\n\t\treturn true\n\t} else if (element instanceof HTMLElement) {\n\t\tconst contentOverflows = element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth\n\n\t\tif (contentOverflows) {\n\t\t\tif ((getComputedStyle(element)).overflow === 'hidden') {\n\t\t\t\treturn false\n\t\t\t} else {\n\t\t\t\treturn contentOverflows\n\t\t\t}\n\t\t} else {\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\treturn false\n\t}\n}\n"],"names":[],"mappings":"AAKO,SAAS,aAAa,SAA6B;AACrD,MAAA,YAAY,SAAS,kBAAkB;AACnC,WAAA;AAAA,EAAA,WACG,mBAAmB,aAAa;AAC1C,UAAM,mBAAmB,QAAQ,eAAe,QAAQ,gBAAgB,QAAQ,cAAc,QAAQ;AAEtG,QAAI,kBAAkB;AACrB,UAAK,iBAAiB,OAAO,EAAG,aAAa,UAAU;AAC/C,eAAA;AAAA,MAAA,OACD;AACC,eAAA;AAAA,MACR;AAAA,IAAA,OACM;AACC,aAAA;AAAA,IACR;AAAA,EAAA,OACM;AACC,WAAA;AAAA,EACR;AACD;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { assert } from "../assert-types/assert.js";
|
|
2
|
-
import { isNumber } from "../assert-types/Predicates.js";
|
|
3
|
-
const MATRIX_REG_EXP = /^matrix\((.+)\)/;
|
|
4
|
-
function isTransformMatrixTuple(value) {
|
|
5
|
-
if (Array.isArray(value) && value.length === 6 && value.filter(isNumber).length === 6) {
|
|
6
|
-
return true;
|
|
7
|
-
} else {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function parseTransformMatrix(transform = "") {
|
|
12
|
-
let matches = null;
|
|
13
|
-
if (matches = transform.match(MATRIX_REG_EXP)) {
|
|
14
|
-
const vector = matches[1].split(",").map((value) => parseFloat(value));
|
|
15
|
-
assert("transform matrix is tuple of six numbers", vector, isTransformMatrixTuple);
|
|
16
|
-
return {
|
|
17
|
-
scaleX: vector[0],
|
|
18
|
-
skewY: vector[1],
|
|
19
|
-
skewX: vector[2],
|
|
20
|
-
scaleY: vector[3],
|
|
21
|
-
translateX: vector[4],
|
|
22
|
-
translateY: vector[5]
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
parseTransformMatrix
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=parseTransformMatrix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseTransformMatrix.js","sources":["../../../src/dom/parseTransformMatrix.ts"],"sourcesContent":["import { assert, isNumber } from '../assert-types'\n\nconst MATRIX_REG_EXP = /^matrix\\((.+)\\)/\n\nfunction isTransformMatrixTuple(value: unknown): value is [number, number, number, number, number, number] {\n\tif (Array.isArray(value) && value.length === 6 && value.filter(isNumber).length === 6) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n}\n\n/**\n * Parses a CSS transform matrix string into an object.\n *\n * @param transform - CSS transform matrix string.\n * @returns Object with the transform matrix values or undefined.\n */\nexport function parseTransformMatrix(transform = '') {\n\tlet matches: RegExpMatchArray | null = null\n\n\tif (matches = transform.match(MATRIX_REG_EXP)) {\n\t\tconst vector = matches[1].split(',').map(value => parseFloat(value))\n\t\tassert('transform matrix is tuple of six numbers', vector, isTransformMatrixTuple)\n\n\t\treturn {\n\t\t\tscaleX: vector[0],\n\t\t\tskewY: vector[1],\n\t\t\tskewX: vector[2],\n\t\t\tscaleY: vector[3],\n\t\t\ttranslateX: vector[4],\n\t\t\ttranslateY: vector[5],\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AAEA,MAAM,iBAAiB;AAEvB,SAAS,uBAAuB,OAA2E;AAC1G,MAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,KAAK,MAAM,OAAO,QAAQ,EAAE,WAAW,GAAG;AAC/E,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACR;AACD;AAQgB,SAAA,qBAAqB,YAAY,IAAI;AACpD,MAAI,UAAmC;AAEvC,MAAI,UAAU,UAAU,MAAM,cAAc,GAAG;AACxC,UAAA,SAAS,QAAQ,CAAC,EAAE,MAAM,GAAG,EAAE,IAAI,CAAA,UAAS,WAAW,KAAK,CAAC;AAC5D,WAAA,4CAA4C,QAAQ,sBAAsB;AAE1E,WAAA;AAAA,MACN,QAAQ,OAAO,CAAC;AAAA,MAChB,OAAO,OAAO,CAAC;AAAA,MACf,OAAO,OAAO,CAAC;AAAA,MACf,QAAQ,OAAO,CAAC;AAAA,MAChB,YAAY,OAAO,CAAC;AAAA,MACpB,YAAY,OAAO,CAAC;AAAA,IAAA;AAAA,EAEtB;AACD;"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function extend(base, extension) {
|
|
2
|
-
base = Object.freeze(base);
|
|
3
|
-
extension = Object.freeze(extension);
|
|
4
|
-
if (typeof base !== typeof extension) {
|
|
5
|
-
return extension === void 0 ? base : extension;
|
|
6
|
-
} else {
|
|
7
|
-
if (typeof base === "object" && typeof extension === "object") {
|
|
8
|
-
if (Array.isArray(base) && Array.isArray(extension)) {
|
|
9
|
-
return Object.freeze([...base, ...extension]);
|
|
10
|
-
} else if (base && extension) {
|
|
11
|
-
if ("$$typeof" in extension) {
|
|
12
|
-
return extension;
|
|
13
|
-
}
|
|
14
|
-
const keys = [.../* @__PURE__ */ new Set([
|
|
15
|
-
...Object.keys(base),
|
|
16
|
-
...Object.keys(extension)
|
|
17
|
-
])];
|
|
18
|
-
const entries = keys.map(
|
|
19
|
-
(key) => [key, extend(base[key], extension[key])]
|
|
20
|
-
);
|
|
21
|
-
return Object.freeze(Object.fromEntries(entries));
|
|
22
|
-
} else {
|
|
23
|
-
return extension;
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
return extension;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
extend
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=extend.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extend.js","sources":["../../../src/functional/extend.ts"],"sourcesContent":["/** @internal */\nexport function extend<B, E>(\n\tbase: B,\n\textension: E,\n) {\n\tbase = Object.freeze(base)\n\textension = Object.freeze(extension)\n\n\tif (typeof base !== typeof extension) {\n\t\treturn extension === undefined ? base : extension\n\t} else {\n\t\tif (typeof base === 'object' && typeof extension === 'object') {\n\t\t\tif (Array.isArray(base) && Array.isArray(extension)) {\n\t\t\t\treturn Object.freeze([...base, ...extension])\n\t\t\t} else if (base && extension) {\n\t\t\t\tif ('$$typeof' in extension) {\n\t\t\t\t\treturn extension\n\t\t\t\t}\n\n\t\t\t\tconst keys = [...new Set([\n\t\t\t\t\t...Object.keys(base),\n\t\t\t\t\t...Object.keys(extension),\n\t\t\t\t])]\n\n\t\t\t\tconst entries: [string, unknown][] = keys.map(\n\t\t\t\t\tkey => [key, extend((base as Record<string, unknown>)[key], (extension as Record<string, unknown>)[key])],\n\t\t\t\t)\n\n\t\t\t\treturn Object.freeze(Object.fromEntries(entries))\n\t\t\t} else {\n\t\t\t\treturn extension\n\t\t\t}\n\t\t} else {\n\t\t\treturn extension\n\t\t}\n\t}\n}\n"],"names":[],"mappings":"AACgB,SAAA,OACf,MACA,WACC;AACM,SAAA,OAAO,OAAO,IAAI;AACb,cAAA,OAAO,OAAO,SAAS;AAE/B,MAAA,OAAO,SAAS,OAAO,WAAW;AAC9B,WAAA,cAAc,SAAY,OAAO;AAAA,EAAA,OAClC;AACN,QAAI,OAAO,SAAS,YAAY,OAAO,cAAc,UAAU;AAC9D,UAAI,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,SAAS,GAAG;AACpD,eAAO,OAAO,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;AAAA,MAAA,WAClC,QAAQ,WAAW;AAC7B,YAAI,cAAc,WAAW;AACrB,iBAAA;AAAA,QACR;AAEA,cAAM,OAAO,CAAC,GAAG,oBAAI,IAAI;AAAA,UACxB,GAAG,OAAO,KAAK,IAAI;AAAA,UACnB,GAAG,OAAO,KAAK,SAAS;AAAA,QACxB,CAAA,CAAC;AAEF,cAAM,UAA+B,KAAK;AAAA,UACzC,CAAA,QAAO,CAAC,KAAK,OAAQ,KAAiC,GAAG,GAAI,UAAsC,GAAG,CAAC,CAAC;AAAA,QAAA;AAGzG,eAAO,OAAO,OAAO,OAAO,YAAY,OAAO,CAAC;AAAA,MAAA,OAC1C;AACC,eAAA;AAAA,MACR;AAAA,IAAA,OACM;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setHasOneOf.js","sources":["../../../src/functional/setHasOneOf.ts"],"sourcesContent":["export function setHasOneOf<T>(set: Set<T>, values: T[]): boolean {\n return values.some(value => set.has(value))\n}\n"],"names":[],"mappings":"AAAgB,SAAA,YAAe,KAAa,QAAsB;AAChE,SAAO,OAAO,KAAK,CAAA,UAAS,IAAI,IAAI,KAAK,CAAC;AAC5C;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"capitalize.js","sources":["../../../src/string-utilities/capitalize.ts"],"sourcesContent":["export function capitalize(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1)\n}\n"],"names":[],"mappings":"AAAO,SAAS,WAAW,KAAa;AAC/B,SAAA,IAAI,OAAO,CAAC,EAAE,gBAAgB,IAAI,MAAM,CAAC;AAClD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trimString.js","sources":["../../../src/string-utilities/trimString.ts"],"sourcesContent":["/**\n * Trims the provided string of any characters in the provided set.\n *\n * @param value - The string to trim.\n * @param characters - The characters to remove.\n * @returns\tThe trimmed string.\n */\nexport function trimString(value: string, characters: string) {\n\tconst regExp = new RegExp(`^[${characters}]*|[${characters}]*$`, 'g')\n\n\treturn value.replace(regExp, '')\n}\n"],"names":[],"mappings":"AAOgB,SAAA,WAAW,OAAe,YAAoB;AAC7D,QAAM,SAAS,IAAI,OAAO,KAAK,iBAAiB,iBAAiB,GAAG;AAE7D,SAAA,MAAM,QAAQ,QAAQ,EAAE;AAChC;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { toKebabCase } from "../string-utilities/kebabCase.js";
|
|
2
|
-
function stateClassName(state = null, { glue = "-", removeFalsy = true } = {}) {
|
|
3
|
-
const entries = Object.entries(state ?? []).map(
|
|
4
|
-
([className, value]) => value || value === 0 || !removeFalsy ? value === true ? toKebabCase(className) : `${toKebabCase(className)}${glue}${value}` : ""
|
|
5
|
-
).filter(Boolean);
|
|
6
|
-
return entries;
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
stateClassName
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=stateClassName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stateClassName.js","sources":["../../../src/class-name/stateClassName.ts"],"sourcesContent":["import { toKebabCase } from '../string-utilities'\nimport { ClassNameStateMap } from './types'\n\nexport interface StateClassNameOptions {\n\tglue?: string;\n\tremoveFalsy?: boolean;\n}\n\n/**\n * Combines a state map of class names into a single string\n *\n * @example\n * stateClassName({ foo: true, bar: false, baz: 1 }) // => 'foo baz-1'\n *\n * @param state - State map object with class names as keys and literals as values.\n * @param options - Options object\n * @param options.glue - Glue to use between the class name and the value, default is '-'. Set to '' to disable.\n * @param options.removeFalsy - Whether to remove falsy class names, default is true.\n * @returns Combined class names as string\n */\nexport function stateClassName(\n\tstate: ClassNameStateMap | null = null,\n\t{ glue = '-', removeFalsy = true }: StateClassNameOptions = {},\n): string[] {\n\tconst entries = Object.entries(state ?? []).map(\n\t\t([className, value]) => value || value === 0 || !removeFalsy\n\t\t\t? (value === true ? toKebabCase(className) : `${toKebabCase(className)}${glue}${value}`)\n\t\t\t: '',\n\t).filter(Boolean)\n\n\treturn entries\n}\n"],"names":[],"mappings":";AAoBgB,SAAA,eACf,QAAkC,MAClC,EAAE,OAAO,KAAK,cAAc,KAAgC,IAAA,IACjD;AACX,QAAM,UAAU,OAAO,QAAQ,SAAS,CAAA,CAAE,EAAE;AAAA,IAC3C,CAAC,CAAC,WAAW,KAAK,MAAM,SAAS,UAAU,KAAK,CAAC,cAC7C,UAAU,OAAO,YAAY,SAAS,IAAI,GAAG,YAAY,SAAS,IAAI,OAAO,UAC9E;AAAA,EAAA,EACF,OAAO,OAAO;AAET,SAAA;AACR;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fallback.js","sources":["../../../src/deprecate/fallback.ts"],"sourcesContent":["export function fallback<R>(current: R, condition: boolean, mapped: R): R {\n\tif (condition === true) {\n\t\treturn mapped\n\t} else {\n\t\treturn current\n\t}\n}\n"],"names":[],"mappings":"AAAgB,SAAA,SAAY,SAAY,WAAoB,QAAc;AACzE,MAAI,cAAc,MAAM;AAChB,WAAA;AAAA,EAAA,OACD;AACC,WAAA;AAAA,EACR;AACD;"}
|