@mittwald/flow-react-components 1.6.0-next.22 → 1.6.0-next.23
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/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/js/packages/components/src/components/DeprecationWarningProvider/DeprecationWarningProvider.mjs +40 -8
- package/dist/js/packages/components/src/components/DeprecationWarningProvider/DeprecationWarningProvider.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1,33 +1,65 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { createContext, useCallback, useContext, useEffect, useRef } from "react";
|
|
3
|
+
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/DeprecationWarningProvider/DeprecationWarningProvider.tsx
|
|
6
6
|
var DeprecationWarningContext = createContext(void 0);
|
|
7
|
+
/**
|
|
8
|
+
* Messages a provider has passed to its `onWarning`. Held by the provider, not
|
|
9
|
+
* keyed by the handler: an inline `onWarning` is a new function on every
|
|
10
|
+
* render.
|
|
11
|
+
*/
|
|
12
|
+
var ReportedWarningsContext = createContext(void 0);
|
|
13
|
+
/** Messages already written to `console.warn`, across all providers. */
|
|
14
|
+
var consoleReportedWarnings = /* @__PURE__ */ new Set();
|
|
15
|
+
/**
|
|
16
|
+
* Fallback for a bare `DeprecationWarningContext.Provider`, which has no
|
|
17
|
+
* provider-held set.
|
|
18
|
+
*/
|
|
19
|
+
var reportedWarningsByHandler = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
var getHandlerReportedWarnings = (handler) => {
|
|
21
|
+
let reported = reportedWarningsByHandler.get(handler);
|
|
22
|
+
if (!reported) {
|
|
23
|
+
reported = /* @__PURE__ */ new Set();
|
|
24
|
+
reportedWarningsByHandler.set(handler, reported);
|
|
25
|
+
}
|
|
26
|
+
return reported;
|
|
27
|
+
};
|
|
7
28
|
var DeprecationWarningProvider = (props) => {
|
|
8
29
|
const { children, onWarning } = props;
|
|
30
|
+
const [reportedWarnings] = useState(() => /* @__PURE__ */ new Set());
|
|
9
31
|
return /* @__PURE__ */ jsx(DeprecationWarningContext.Provider, {
|
|
10
32
|
value: onWarning,
|
|
11
|
-
children
|
|
33
|
+
children: /* @__PURE__ */ jsx(ReportedWarningsContext.Provider, {
|
|
34
|
+
value: reportedWarnings,
|
|
35
|
+
children
|
|
36
|
+
})
|
|
12
37
|
});
|
|
13
38
|
};
|
|
14
39
|
var useWarnDeprecation = () => {
|
|
15
40
|
const onWarning = useContext(DeprecationWarningContext);
|
|
16
|
-
const
|
|
41
|
+
const providerReportedWarnings = useContext(ReportedWarningsContext);
|
|
42
|
+
const handlerReportedWarnings = onWarning ? providerReportedWarnings ?? getHandlerReportedWarnings(onWarning) : void 0;
|
|
17
43
|
const pendingWarnings = useRef([]);
|
|
18
44
|
useEffect(() => {
|
|
45
|
+
if (pendingWarnings.current.length === 0) return;
|
|
19
46
|
const warnings = pendingWarnings.current;
|
|
20
47
|
pendingWarnings.current = [];
|
|
21
48
|
for (const message of warnings) {
|
|
22
|
-
|
|
23
|
-
|
|
49
|
+
if (!consoleReportedWarnings.has(message)) {
|
|
50
|
+
consoleReportedWarnings.add(message);
|
|
51
|
+
console.warn(message);
|
|
52
|
+
}
|
|
53
|
+
if (onWarning && !handlerReportedWarnings?.has(message)) {
|
|
54
|
+
handlerReportedWarnings?.add(message);
|
|
55
|
+
onWarning(message);
|
|
56
|
+
}
|
|
24
57
|
}
|
|
25
58
|
});
|
|
26
59
|
return useCallback((message) => {
|
|
27
|
-
if (
|
|
28
|
-
reportedWarnings.current.add(message);
|
|
60
|
+
if (consoleReportedWarnings.has(message) && (handlerReportedWarnings?.has(message) ?? true) || pendingWarnings.current.includes(message)) return;
|
|
29
61
|
pendingWarnings.current.push(message);
|
|
30
|
-
}, []);
|
|
62
|
+
}, [handlerReportedWarnings]);
|
|
31
63
|
};
|
|
32
64
|
//#endregion
|
|
33
65
|
export { DeprecationWarningContext, DeprecationWarningProvider, DeprecationWarningProvider as default, useWarnDeprecation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../../../src/components/DeprecationWarningProvider/DeprecationWarningProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useRef,\n} from \"react\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nexport interface DeprecationWarningProviderProps extends PropsWithChildren {\n onWarning?: DeprecationWarningHandler;\n}\n\nexport const DeprecationWarningContext = createContext<\n DeprecationWarningHandler | undefined\n>(undefined);\n\nexport const DeprecationWarningProvider: FC<DeprecationWarningProviderProps> = (\n props,\n) => {\n const { children, onWarning } = props;\n\n return (\n <DeprecationWarningContext.Provider value={onWarning}>\n {children}\n </DeprecationWarningContext.Provider>\n );\n};\n\nexport const useWarnDeprecation = () => {\n const onWarning = useContext(DeprecationWarningContext);\n const
|
|
1
|
+
{"version":3,"file":"DeprecationWarningProvider.mjs","names":[],"sources":["../../../../../../../src/components/DeprecationWarningProvider/DeprecationWarningProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\n\nexport type DeprecationWarningHandler = (message: string) => void;\n\nexport interface DeprecationWarningProviderProps extends PropsWithChildren {\n onWarning?: DeprecationWarningHandler;\n}\n\nexport const DeprecationWarningContext = createContext<\n DeprecationWarningHandler | undefined\n>(undefined);\n\n/**\n * Messages a provider has passed to its `onWarning`. Held by the provider, not\n * keyed by the handler: an inline `onWarning` is a new function on every\n * render.\n */\nconst ReportedWarningsContext = createContext<Set<string> | undefined>(\n undefined,\n);\n\n/** Messages already written to `console.warn`, across all providers. */\nconst consoleReportedWarnings = new Set<string>();\n\n/**\n * Fallback for a bare `DeprecationWarningContext.Provider`, which has no\n * provider-held set.\n */\nconst reportedWarningsByHandler = new WeakMap<\n DeprecationWarningHandler,\n Set<string>\n>();\n\nconst getHandlerReportedWarnings = (handler: DeprecationWarningHandler) => {\n let reported = reportedWarningsByHandler.get(handler);\n if (!reported) {\n reported = new Set();\n reportedWarningsByHandler.set(handler, reported);\n }\n return reported;\n};\n\nexport const DeprecationWarningProvider: FC<DeprecationWarningProviderProps> = (\n props,\n) => {\n const { children, onWarning } = props;\n const [reportedWarnings] = useState(() => new Set<string>());\n\n return (\n <DeprecationWarningContext.Provider value={onWarning}>\n <ReportedWarningsContext.Provider value={reportedWarnings}>\n {children}\n </ReportedWarningsContext.Provider>\n </DeprecationWarningContext.Provider>\n );\n};\n\nexport const useWarnDeprecation = () => {\n const onWarning = useContext(DeprecationWarningContext);\n const providerReportedWarnings = useContext(ReportedWarningsContext);\n const handlerReportedWarnings = onWarning\n ? (providerReportedWarnings ?? getHandlerReportedWarnings(onWarning))\n : undefined;\n\n const pendingWarnings = useRef<string[]>([]);\n\n useEffect(() => {\n if (pendingWarnings.current.length === 0) {\n return;\n }\n\n const warnings = pendingWarnings.current;\n pendingWarnings.current = [];\n\n for (const message of warnings) {\n if (!consoleReportedWarnings.has(message)) {\n consoleReportedWarnings.add(message);\n console.warn(message);\n }\n if (onWarning && !handlerReportedWarnings?.has(message)) {\n handlerReportedWarnings?.add(message);\n onWarning(message);\n }\n }\n });\n\n return useCallback(\n (message: string) => {\n const isReported =\n consoleReportedWarnings.has(message) &&\n (handlerReportedWarnings?.has(message) ?? true);\n\n if (isReported || pendingWarnings.current.includes(message)) {\n return;\n }\n pendingWarnings.current.push(message);\n },\n [handlerReportedWarnings],\n );\n};\n\nexport default DeprecationWarningProvider;\n"],"mappings":";;;;;AAiBA,IAAa,4BAA4B,cAEvC,KAAA,CAAS;;;;;;AAOX,IAAM,0BAA0B,cAC9B,KAAA,CACF;;AAGA,IAAM,0CAA0B,IAAI,IAAY;;;;;AAMhD,IAAM,4CAA4B,IAAI,QAGpC;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mittwald/flow-react-components",
|
|
3
|
-
"version": "1.6.0-next.
|
|
3
|
+
"version": "1.6.0-next.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://flow.mittwald.de",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"@internationalized/string-compiler": "^3.4.1",
|
|
85
85
|
"@lezer/common": "^1.5.2",
|
|
86
86
|
"@lezer/highlight": "^1.2.3",
|
|
87
|
-
"@mittwald/flow-icons": "^1.6.0-next.
|
|
87
|
+
"@mittwald/flow-icons": "^1.6.0-next.23",
|
|
88
88
|
"@mittwald/password-tools-js": "^3.0.0",
|
|
89
|
-
"@mittwald/react-tunnel": "^1.6.0-next.
|
|
89
|
+
"@mittwald/react-tunnel": "^1.6.0-next.23",
|
|
90
90
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
91
91
|
"@react-aria/form": "^3.2.1",
|
|
92
92
|
"@react-aria/i18n": "^3.13.1",
|
|
@@ -139,13 +139,13 @@
|
|
|
139
139
|
"@internationalized/date": "^3.12.3",
|
|
140
140
|
"@lezer/generator": "^1.8.0",
|
|
141
141
|
"@lezer/lr": "^1.4.10",
|
|
142
|
-
"@mittwald/flow-components-base": "1.6.0-next.
|
|
143
|
-
"@mittwald/flow-core": "1.6.0-next.
|
|
144
|
-
"@mittwald/flow-design-tokens": "1.6.0-next.
|
|
145
|
-
"@mittwald/flow-icons-base": "1.6.0-next.
|
|
142
|
+
"@mittwald/flow-components-base": "1.6.0-next.23",
|
|
143
|
+
"@mittwald/flow-core": "1.6.0-next.23",
|
|
144
|
+
"@mittwald/flow-design-tokens": "1.6.0-next.23",
|
|
145
|
+
"@mittwald/flow-icons-base": "1.6.0-next.23",
|
|
146
146
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
147
147
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
148
|
-
"@mittwald/typescript-config": "1.6.0-next.
|
|
148
|
+
"@mittwald/typescript-config": "1.6.0-next.23",
|
|
149
149
|
"@nx/storybook": "^22.7.6",
|
|
150
150
|
"@storybook/addon-a11y": "^10.5.10",
|
|
151
151
|
"@storybook/addon-actions": "^9.0.8",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
"peerDependencies": {
|
|
201
201
|
"@internationalized/date": "^3.12.2",
|
|
202
|
-
"@mittwald/flow-icons-pro": "1.6.0-next.
|
|
202
|
+
"@mittwald/flow-icons-pro": "1.6.0-next.23",
|
|
203
203
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
204
204
|
"next": "^16.2.3",
|
|
205
205
|
"react": "^19.2.0",
|
|
@@ -223,5 +223,5 @@
|
|
|
223
223
|
"browserslist": [
|
|
224
224
|
"baseline widely available"
|
|
225
225
|
],
|
|
226
|
-
"gitHead": "
|
|
226
|
+
"gitHead": "782622840cbf82aa1170c6d0bab099f85e63312f"
|
|
227
227
|
}
|