@mittwald/flow-react-components 0.2.0-alpha.158 → 0.2.0-alpha.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/assets/doc-properties.json +4 -4
- package/dist/js/components/src/lib/hooks/useProps.mjs +16 -10
- package/dist/js/components/src/lib/hooks/useProps.mjs.map +1 -1
- package/dist/js/components/src/lib/react/areChildrenEmpty.mjs +23 -0
- package/dist/js/components/src/lib/react/areChildrenEmpty.mjs.map +1 -0
- package/dist/types/lib/hooks/useProps.d.ts.map +1 -1
- package/dist/types/lib/hooks/useProps.test.d.ts.map +1 -0
- package/dist/types/lib/react/areChildrenEmpty.d.ts +3 -0
- package/dist/types/lib/react/areChildrenEmpty.d.ts.map +1 -0
- package/package.json +4 -4
- package/dist/types/lib/propsContext/useProps.test.d.ts.map +0 -1
- /package/dist/types/lib/{propsContext → hooks}/useProps.test.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.2.0-alpha.159](https://github.com/mittwald/flow/compare/0.2.0-alpha.158...0.2.0-alpha.159) (2025-04-25)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* allow context-overwrite of nullish React children ([#1403](https://github.com/mittwald/flow/issues/1403)) ([5ae6675](https://github.com/mittwald/flow/commit/5ae667568e6e8099fe4b689a95048431904cdbbf))
|
|
11
|
+
|
|
6
12
|
# [0.2.0-alpha.158](https://github.com/mittwald/flow/compare/0.2.0-alpha.157...0.2.0-alpha.158) (2025-04-24)
|
|
7
13
|
|
|
8
14
|
### Features
|
|
@@ -159832,9 +159832,9 @@
|
|
|
159832
159832
|
"flr-generate": "all",
|
|
159833
159833
|
"flr-clear-props-context": ""
|
|
159834
159834
|
},
|
|
159835
|
-
"filePath": "/home/runner/work/flow/flow/packages/components/src/components/
|
|
159835
|
+
"filePath": "/home/runner/work/flow/flow/packages/components/src/components/Checkbox/Checkbox.tsx",
|
|
159836
159836
|
"description": "",
|
|
159837
|
-
"displayName": "
|
|
159837
|
+
"displayName": "Checkbox",
|
|
159838
159838
|
"methods": [],
|
|
159839
159839
|
"props": {
|
|
159840
159840
|
"onFocus": {
|
|
@@ -160564,9 +160564,9 @@
|
|
|
160564
160564
|
"flr-generate": "all",
|
|
160565
160565
|
"flr-clear-props-context": ""
|
|
160566
160566
|
},
|
|
160567
|
-
"filePath": "/home/runner/work/flow/flow/packages/components/src/components/
|
|
160567
|
+
"filePath": "/home/runner/work/flow/flow/packages/components/src/components/CheckboxButton/CheckboxButton.tsx",
|
|
160568
160568
|
"description": "",
|
|
160569
|
-
"displayName": "
|
|
160569
|
+
"displayName": "CheckboxButton",
|
|
160570
160570
|
"methods": [],
|
|
160571
160571
|
"props": {
|
|
160572
160572
|
"onFocus": {
|
|
@@ -7,22 +7,28 @@ import { useContextProps } from '../propsContext/propsContext.mjs';
|
|
|
7
7
|
import { wrapChildrenWithNestedPropsContext } from '../propsContext/nestedPropsContext/wrapChildrenWithNestedPropsContext.mjs';
|
|
8
8
|
import { omitBy } from 'remeda';
|
|
9
9
|
import { isDynamicProp } from '../propsContext/dynamicProps/isDynamicProp.mjs';
|
|
10
|
+
import { areChildrenEmpty } from '../react/areChildrenEmpty.mjs';
|
|
10
11
|
|
|
11
12
|
const useProps = (component, localProps) => {
|
|
13
|
+
if ("children" in localProps) {
|
|
14
|
+
if (areChildrenEmpty(localProps.children)) {
|
|
15
|
+
localProps = { ...localProps };
|
|
16
|
+
delete localProps["children"];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
const propsContext = useContextProps();
|
|
13
20
|
const contextProps = propsContext[component];
|
|
14
|
-
const
|
|
15
|
-
const
|
|
21
|
+
const withResolvedDynamicProps = contextProps ? resolveDynamicProps(contextProps, localProps) : void 0;
|
|
22
|
+
const withNestedPropsContextProvider = contextProps ? wrapChildrenWithNestedPropsContext(contextProps, localProps) : void 0;
|
|
23
|
+
const withoutNestedAndDynamicProps = contextProps ? omitBy(
|
|
24
|
+
contextProps,
|
|
25
|
+
(value, key) => propsContextSupportingComponents.includes(key) || isDynamicProp(value)
|
|
26
|
+
) : void 0;
|
|
16
27
|
return mergeProps(
|
|
17
|
-
|
|
18
|
-
contextProps,
|
|
19
|
-
(value, key) => propsContextSupportingComponents.includes(
|
|
20
|
-
key
|
|
21
|
-
) || isDynamicProp(value)
|
|
22
|
-
) : contextProps,
|
|
28
|
+
withoutNestedAndDynamicProps,
|
|
23
29
|
localProps,
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
withResolvedDynamicProps,
|
|
31
|
+
withNestedPropsContextProvider
|
|
26
32
|
);
|
|
27
33
|
};
|
|
28
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProps.mjs","sources":["../../../../../../src/lib/hooks/useProps.ts"],"sourcesContent":["import type {\n FlowComponentName,\n FlowComponentProps,\n} from \"@/components/propTypes\";\nimport { propsContextSupportingComponents } from \"@/components/propTypes\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport { resolveDynamicProps } from \"@/lib/propsContext/dynamicProps/resolveDynamicProps\";\nimport { useContextProps } from \"@/lib/propsContext/propsContext\";\nimport wrapChildrenWithNestedPropsContext from \"@/lib/propsContext/nestedPropsContext/wrapChildrenWithNestedPropsContext\";\nimport { omitBy } from \"remeda\";\nimport type { PropsContext } from \"@/lib/propsContext/types\";\nimport isDynamicProp from \"@/lib/propsContext/dynamicProps/isDynamicProp\";\n\nexport const useProps = <C extends FlowComponentName>(\n component: C,\n localProps: FlowComponentProps<C>,\n): FlowComponentProps<C> => {\n const propsContext = useContextProps();\n\n const contextProps = propsContext[component] as FlowComponentProps<C>
|
|
1
|
+
{"version":3,"file":"useProps.mjs","sources":["../../../../../../src/lib/hooks/useProps.ts"],"sourcesContent":["import type {\n FlowComponentName,\n FlowComponentProps,\n} from \"@/components/propTypes\";\nimport { propsContextSupportingComponents } from \"@/components/propTypes\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport { resolveDynamicProps } from \"@/lib/propsContext/dynamicProps/resolveDynamicProps\";\nimport { useContextProps } from \"@/lib/propsContext/propsContext\";\nimport wrapChildrenWithNestedPropsContext from \"@/lib/propsContext/nestedPropsContext/wrapChildrenWithNestedPropsContext\";\nimport { omitBy } from \"remeda\";\nimport type { PropsContext } from \"@/lib/propsContext/types\";\nimport isDynamicProp from \"@/lib/propsContext/dynamicProps/isDynamicProp\";\nimport { areChildrenEmpty } from \"@/lib/react/areChildrenEmpty\";\n\nexport const useProps = <C extends FlowComponentName>(\n component: C,\n localProps: FlowComponentProps<C>,\n): FlowComponentProps<C> => {\n if (\"children\" in localProps) {\n if (areChildrenEmpty(localProps.children)) {\n localProps = { ...localProps };\n delete localProps[\"children\"];\n }\n }\n\n const propsContext = useContextProps();\n\n const contextProps = propsContext[component] as\n | (FlowComponentProps<C> & PropsContext)\n | undefined;\n\n const withResolvedDynamicProps = contextProps\n ? resolveDynamicProps(contextProps, localProps)\n : undefined;\n\n const withNestedPropsContextProvider = contextProps\n ? wrapChildrenWithNestedPropsContext(contextProps, localProps)\n : undefined;\n\n const withoutNestedAndDynamicProps = contextProps\n ? omitBy<FlowComponentProps<C>>(\n contextProps,\n (value, key) =>\n propsContextSupportingComponents.includes(key as FlowComponentName) ||\n isDynamicProp(value),\n )\n : undefined;\n\n return mergeProps(\n withoutNestedAndDynamicProps,\n localProps,\n withResolvedDynamicProps,\n withNestedPropsContextProvider,\n ) as FlowComponentProps<C>;\n};\n\nexport default useProps;\n"],"names":[],"mappings":";;;;;;;;;AAca,MAAA,QAAA,GAAW,CACtB,SAAA,EACA,UAC0B,KAAA;AAC1B,EAAA,IAAI,cAAc,UAAY,EAAA;AAC5B,IAAI,IAAA,gBAAA,CAAiB,UAAW,CAAA,QAAQ,CAAG,EAAA;AACzC,MAAa,UAAA,GAAA,EAAE,GAAG,UAAW,EAAA;AAC7B,MAAA,OAAO,WAAW,UAAU,CAAA;AAAA;AAC9B;AAGF,EAAA,MAAM,eAAe,eAAgB,EAAA;AAErC,EAAM,MAAA,YAAA,GAAe,aAAa,SAAS,CAAA;AAI3C,EAAA,MAAM,wBAA2B,GAAA,YAAA,GAC7B,mBAAoB,CAAA,YAAA,EAAc,UAAU,CAC5C,GAAA,MAAA;AAEJ,EAAA,MAAM,8BAAiC,GAAA,YAAA,GACnC,kCAAmC,CAAA,YAAA,EAAc,UAAU,CAC3D,GAAA,MAAA;AAEJ,EAAA,MAAM,+BAA+B,YACjC,GAAA,MAAA;AAAA,IACE,YAAA;AAAA,IACA,CAAC,OAAO,GACN,KAAA,gCAAA,CAAiC,SAAS,GAAwB,CAAA,IAClE,cAAc,KAAK;AAAA,GAEvB,GAAA,MAAA;AAEJ,EAAO,OAAA,UAAA;AAAA,IACL,4BAAA;AAAA,IACA,UAAA;AAAA,IACA,wBAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
/* */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
const isNullish = (children) => children === null || children === void 0 || children === false;
|
|
6
|
+
const areChildrenEmpty = (children) => {
|
|
7
|
+
if (isNullish(children)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (Array.isArray(children)) {
|
|
11
|
+
return children.length === 0 || children.every(isNullish);
|
|
12
|
+
}
|
|
13
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (React.isValidElement(children)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { areChildrenEmpty };
|
|
23
|
+
//# sourceMappingURL=areChildrenEmpty.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areChildrenEmpty.mjs","sources":["../../../../../../src/lib/react/areChildrenEmpty.ts"],"sourcesContent":["import React from \"react\";\n\nconst isNullish = (children: React.ReactNode) =>\n children === null || children === undefined || children === false;\n\nexport const areChildrenEmpty = (children: React.ReactNode): boolean => {\n if (isNullish(children)) {\n return true;\n }\n\n if (Array.isArray(children)) {\n return children.length === 0 || children.every(isNullish);\n }\n\n if (typeof children === \"string\" || typeof children === \"number\") {\n return false;\n }\n\n if (React.isValidElement(children)) {\n return false;\n }\n\n return true;\n};\n"],"names":[],"mappings":";;AAEA,MAAM,YAAY,CAAC,QAAA,KACjB,aAAa,IAAQ,IAAA,QAAA,KAAa,UAAa,QAAa,KAAA,KAAA;AAEjD,MAAA,gBAAA,GAAmB,CAAC,QAAuC,KAAA;AACtE,EAAI,IAAA,SAAA,CAAU,QAAQ,CAAG,EAAA;AACvB,IAAO,OAAA,IAAA;AAAA;AAGT,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,QAAQ,CAAG,EAAA;AAC3B,IAAA,OAAO,QAAS,CAAA,MAAA,KAAW,CAAK,IAAA,QAAA,CAAS,MAAM,SAAS,CAAA;AAAA;AAG1D,EAAA,IAAI,OAAO,QAAA,KAAa,QAAY,IAAA,OAAO,aAAa,QAAU,EAAA;AAChE,IAAO,OAAA,KAAA;AAAA;AAGT,EAAI,IAAA,KAAA,CAAM,cAAe,CAAA,QAAQ,CAAG,EAAA;AAClC,IAAO,OAAA,KAAA;AAAA;AAGT,EAAO,OAAA,IAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProps.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/useProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"useProps.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/useProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAWhC,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,iBAAiB,EAClD,WAAW,CAAC,EACZ,YAAY,kBAAkB,CAAC,CAAC,CAAC,KAChC,kBAAkB,CAAC,CAAC,CAqCtB,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useProps.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/useProps.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"areChildrenEmpty.d.ts","sourceRoot":"","sources":["../../../../src/lib/react/areChildrenEmpty.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,gBAAgB,GAAI,UAAU,KAAK,CAAC,SAAS,KAAG,OAkB5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.159",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@chakra-ui/live-region": "^2.1.0",
|
|
55
55
|
"@internationalized/string-compiler": "^3.2.6",
|
|
56
|
-
"@mittwald/react-tunnel": "0.2.0-alpha.
|
|
56
|
+
"@mittwald/react-tunnel": "0.2.0-alpha.159",
|
|
57
57
|
"@mittwald/react-use-promise": "^3.0.4",
|
|
58
58
|
"@react-aria/form": "^3.0.14",
|
|
59
59
|
"@react-aria/utils": "^3.28.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@faker-js/faker": "^9.6.0",
|
|
94
94
|
"@internationalized/date": "^3.7.0",
|
|
95
|
-
"@mittwald/flow-design-tokens": "0.2.0-alpha.
|
|
95
|
+
"@mittwald/flow-design-tokens": "0.2.0-alpha.159",
|
|
96
96
|
"@mittwald/react-use-promise": "^2.6.0",
|
|
97
97
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.3",
|
|
98
98
|
"@mittwald/typescript-config": "",
|
|
@@ -173,5 +173,5 @@
|
|
|
173
173
|
"optional": true
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "7ec2170b59dd7e302dda62fc269aadcb2c410033"
|
|
177
177
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useProps.test.d.ts","sourceRoot":"","sources":["../../../../src/lib/propsContext/useProps.test.tsx"],"names":[],"mappings":""}
|
|
File without changes
|