@mittwald/flow-react-components 1.3.0-next.24 → 1.3.0-next.25
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/CopyButton/CopyButton.mjs +4 -3
- package/dist/js/packages/components/src/components/CopyButton/CopyButton.mjs.map +1 -1
- package/dist/types/components/CopyButton/CopyButton.d.ts +5 -0
- package/package.json +9 -9
|
@@ -14,10 +14,11 @@ import { onlyText } from "react-children-utilities";
|
|
|
14
14
|
//#region src/components/CopyButton/CopyButton.tsx
|
|
15
15
|
/** @flr-generate all */
|
|
16
16
|
var CopyButton = flowComponent("CopyButton", (props) => {
|
|
17
|
-
const { text = "", ref, variant = "plain", color = "secondary", ...buttonProps } = props;
|
|
17
|
+
const { text = "", ref, variant = "plain", color = "secondary", onCopy, ...buttonProps } = props;
|
|
18
18
|
const tooltip = useLocalizedStringFormatter(__locale_default, "CopyButton").format("copy");
|
|
19
|
-
const copyValue = () => {
|
|
20
|
-
|
|
19
|
+
const copyValue = async () => {
|
|
20
|
+
const copiedText = onlyText(text);
|
|
21
|
+
if (await copy(copiedText)) onCopy?.(copiedText);
|
|
21
22
|
};
|
|
22
23
|
return /* @__PURE__ */ jsxs(TooltipTrigger, { children: [/* @__PURE__ */ jsx(Action, {
|
|
23
24
|
onAction: copyValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.mjs","names":[],"sources":["../../../../../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import copy from \"copy-to-clipboard\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport { Button } from \"@/components/Button\";\nimport { IconCopy } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { Tooltip, TooltipTrigger } from \"@/components/Tooltip\";\nimport { onlyText } from \"react-children-utilities\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Action } from \"@/components/Action\";\n\nexport interface CopyButtonProps\n extends\n Omit<ButtonProps, \"onPress\" | \"aria-label\" | \"render\">,\n FlowComponentProps<HTMLButtonElement> {\n /** The text to copy. */\n text?: string;\n}\n\n/** @flr-generate all */\nexport const CopyButton = flowComponent(\"CopyButton\", (props) => {\n const {\n text = \"\",\n ref,\n variant = \"plain\",\n color = \"secondary\",\n ...buttonProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"CopyButton\");\n\n const tooltip = stringFormatter.format(\"copy\");\n\n const copyValue = () => {\n
|
|
1
|
+
{"version":3,"file":"CopyButton.mjs","names":[],"sources":["../../../../../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import copy from \"copy-to-clipboard\";\nimport type { ButtonProps } from \"@/components/Button\";\nimport { Button } from \"@/components/Button\";\nimport { IconCopy } from \"@/components/Icon/components/icons\";\nimport locales from \"./locales/*.locale.json\";\nimport { useLocalizedStringFormatter } from \"@/components/TranslationProvider/useLocalizedStringFormatter\";\nimport { Tooltip, TooltipTrigger } from \"@/components/Tooltip\";\nimport { onlyText } from \"react-children-utilities\";\nimport type { FlowComponentProps } from \"@/lib/componentFactory/flowComponent\";\nimport { flowComponent } from \"@/lib/componentFactory/flowComponent\";\nimport { Action } from \"@/components/Action\";\n\nexport interface CopyButtonProps\n extends\n Omit<ButtonProps, \"onPress\" | \"aria-label\" | \"render\">,\n FlowComponentProps<HTMLButtonElement> {\n /** The text to copy. */\n text?: string;\n /**\n * Called with the copied text once it has been written to the clipboard. Not\n * called when copying fails.\n */\n onCopy?: (text: string) => void;\n}\n\n/** @flr-generate all */\nexport const CopyButton = flowComponent(\"CopyButton\", (props) => {\n const {\n text = \"\",\n ref,\n variant = \"plain\",\n color = \"secondary\",\n onCopy,\n ...buttonProps\n } = props;\n\n const stringFormatter = useLocalizedStringFormatter(locales, \"CopyButton\");\n\n const tooltip = stringFormatter.format(\"copy\");\n\n const copyValue = async () => {\n const copiedText = onlyText(text);\n if (await copy(copiedText)) {\n onCopy?.(copiedText);\n }\n };\n\n return (\n <TooltipTrigger>\n <Action onAction={copyValue} showFeedback>\n <Button\n aria-label={tooltip}\n {...buttonProps}\n ref={ref}\n variant={variant}\n color={color}\n >\n <IconCopy />\n </Button>\n </Action>\n <Tooltip>{tooltip}</Tooltip>\n </TooltipTrigger>\n );\n});\n\nexport default CopyButton;\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,IAAa,aAAa,cAAc,eAAe,UAAU;CAC/D,MAAM,EACJ,OAAO,IACP,KACA,UAAU,SACV,QAAQ,aACR,QACA,GAAG,gBACD;CAIJ,MAAM,UAFkB,4BAA4B,kBAAS,YAE7C,CAAA,CAAgB,OAAO,MAAM;CAE7C,MAAM,YAAY,YAAY;EAC5B,MAAM,aAAa,SAAS,IAAI;EAChC,IAAI,MAAM,KAAK,UAAU,GACvB,SAAS,UAAU;CAEvB;CAEA,OACE,qBAAC,gBAAD,EAAA,UAAA,CACE,oBAAC,QAAD;EAAQ,UAAU;EAAW,cAAA;EAC3B,UAAA,oBAAC,QAAD;GACE,cAAY;GACZ,GAAI;GACC;GACI;GACF;GAEP,UAAA,oBAAC,UAAD,CAAW,CAAA;EACL,CAAA;CACF,CAAA,GACR,oBAAC,SAAD,EAAA,UAAU,QAAiB,CAAA,CACb,EAAA,CAAA;AAEpB,CAAC"}
|
|
@@ -3,6 +3,11 @@ import { FlowComponentProps } from '../../lib/componentFactory/flowComponent';
|
|
|
3
3
|
export interface CopyButtonProps extends Omit<ButtonProps, "onPress" | "aria-label" | "render">, FlowComponentProps<HTMLButtonElement> {
|
|
4
4
|
/** The text to copy. */
|
|
5
5
|
text?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Called with the copied text once it has been written to the clipboard. Not
|
|
8
|
+
* called when copying fails.
|
|
9
|
+
*/
|
|
10
|
+
onCopy?: (text: string) => void;
|
|
6
11
|
}
|
|
7
12
|
/** @flr-generate all */
|
|
8
13
|
export declare const CopyButton: import('react').FunctionComponent<CopyButtonProps & import('react').RefAttributes<HTMLButtonElement>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-react-components",
|
|
3
|
-
"version": "1.3.0-next.
|
|
3
|
+
"version": "1.3.0-next.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A React implementation of Flow, mittwald’s design system",
|
|
6
6
|
"homepage": "https://flow.mittwald.de",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@internationalized/string-compiler": "^3.4.1",
|
|
84
84
|
"@lezer/common": "^1.5.2",
|
|
85
85
|
"@lezer/highlight": "^1.2.3",
|
|
86
|
-
"@mittwald/flow-icons": "^1.3.0-next.
|
|
86
|
+
"@mittwald/flow-icons": "^1.3.0-next.25",
|
|
87
87
|
"@mittwald/password-tools-js": "^3.0.0",
|
|
88
|
-
"@mittwald/react-tunnel": "^1.3.0-next.
|
|
88
|
+
"@mittwald/react-tunnel": "^1.3.0-next.25",
|
|
89
89
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
90
90
|
"@react-aria/form": "^3.2.1",
|
|
91
91
|
"@react-aria/i18n": "^3.13.1",
|
|
@@ -138,12 +138,12 @@
|
|
|
138
138
|
"@internationalized/date": "^3.12.3",
|
|
139
139
|
"@lezer/generator": "^1.8.0",
|
|
140
140
|
"@lezer/lr": "^1.4.10",
|
|
141
|
-
"@mittwald/flow-core": "1.3.0-next.
|
|
142
|
-
"@mittwald/flow-design-tokens": "1.3.0-next.
|
|
143
|
-
"@mittwald/flow-icons-base": "1.3.0-next.
|
|
141
|
+
"@mittwald/flow-core": "1.3.0-next.25",
|
|
142
|
+
"@mittwald/flow-design-tokens": "1.3.0-next.25",
|
|
143
|
+
"@mittwald/flow-icons-base": "1.3.0-next.25",
|
|
144
144
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
145
145
|
"@mittwald/remote-dom-react": "1.2.2-mittwald.10",
|
|
146
|
-
"@mittwald/typescript-config": "1.3.0-next.
|
|
146
|
+
"@mittwald/typescript-config": "1.3.0-next.25",
|
|
147
147
|
"@nx/storybook": "^22.7.6",
|
|
148
148
|
"@storybook/addon-a11y": "^10.5.10",
|
|
149
149
|
"@storybook/addon-actions": "^9.0.8",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"peerDependencies": {
|
|
197
197
|
"@internationalized/date": "^3.12.2",
|
|
198
|
-
"@mittwald/flow-icons-pro": "1.3.0-next.
|
|
198
|
+
"@mittwald/flow-icons-pro": "1.3.0-next.25",
|
|
199
199
|
"@mittwald/react-use-promise": "^4.2.2",
|
|
200
200
|
"next": "^16.2.3",
|
|
201
201
|
"react": "^19.2.0",
|
|
@@ -219,5 +219,5 @@
|
|
|
219
219
|
"browserslist": [
|
|
220
220
|
"baseline widely available"
|
|
221
221
|
],
|
|
222
|
-
"gitHead": "
|
|
222
|
+
"gitHead": "ee347a2ee20ea60a68bb33cdfdcf6b2fb244c30d"
|
|
223
223
|
}
|