@hashicorp/mds-react 0.9.12 → 0.9.14
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/components/accordion/item/index.js.map +1 -1
- package/components/accordion/style.module.scss +4 -4
- package/components/alert/alert.module.scss +2 -4
- package/components/alert/index.js.map +1 -1
- package/components/badge/index.js.map +1 -1
- package/components/badge/style.module.scss +1 -7
- package/components/badge-count/index.js.map +1 -1
- package/components/badge-count/style.module.scss +1 -6
- package/components/breadcrumbs/index.js.map +1 -1
- package/components/breadcrumbs/style.module.scss +2 -2
- package/components/button/button-primitive.js.map +1 -1
- package/components/button/styles.module.scss +9 -13
- package/components/card/index.js.map +1 -1
- package/components/code-block/code-block.module.scss +5 -11
- package/components/code-block/code-lines/utils/split-jsx-into-lines.js.map +1 -1
- package/components/code-block/hidden-copy-content/index.js.map +1 -1
- package/components/code-block/index.js.map +1 -1
- package/components/code-block/utils/parse-highlighted-lines.js.map +1 -1
- package/components/code-block/utils/shellwords.js.map +1 -1
- package/components/combo-box-primitive/index.js.map +1 -1
- package/components/dialog-primitive/index.js.map +1 -1
- package/components/disclosure-primitive/index.js.map +1 -1
- package/components/disclosure-primitive/use-disclosure-primitive.js.map +1 -1
- package/components/dismiss-button/styles.module.scss +1 -6
- package/components/dropdown/index.js.map +1 -1
- package/components/dropdown/list-item/styles.module.css +2 -6
- package/components/dropdown/list-item/title.js.map +1 -1
- package/components/dropdown/toggle-button/index.js.map +1 -1
- package/components/dropdown/toggle-button/styles.module.scss +5 -5
- package/components/flight-icon/index.js.map +1 -1
- package/components/form/checkbox/form-checkbox.module.css +4 -11
- package/components/form/file-input/form-file-input.module.scss +1 -1
- package/components/form/radio/form-radio.module.scss +2 -5
- package/components/form/radio-card/form-radio-card.module.css +1 -2
- package/components/form/radio-card/index.js.map +1 -1
- package/components/form/select/form-select.module.css +6 -14
- package/components/form/select/index.js.map +1 -1
- package/components/form/super-select/form-super-select.module.css +4 -10
- package/components/form/super-select/index.js.map +1 -1
- package/components/form/text-input/index.js.map +1 -1
- package/components/form/text-input/styles.module.css +7 -21
- package/components/form/textarea/form-textarea.module.css +1 -2
- package/components/form/textarea/index.js.map +1 -1
- package/components/form/toggle/form-toggle.module.scss +7 -20
- package/components/icon-tile/index.js.map +1 -1
- package/components/icon-tile/style.module.scss +3 -18
- package/components/index.d.ts +2 -0
- package/components/index.js +49 -45
- package/components/index.js.map +1 -1
- package/components/interactive/index.d.ts +2 -2
- package/components/interactive/index.js.map +1 -1
- package/components/legacy-button/index.js.map +1 -1
- package/components/legacy-button/utils.js.map +1 -1
- package/components/menu-primitive/index.js.map +1 -1
- package/components/menu-primitive/use-menu-primitive.js.map +1 -1
- package/components/modal/index.js.map +1 -1
- package/components/modal/use-modal.js.map +1 -1
- package/components/skeleton/index.d.ts +14 -0
- package/components/skeleton/index.js +30 -0
- package/components/skeleton/index.js.map +1 -0
- package/components/skeleton/skeleton-form/index.d.ts +7 -0
- package/components/skeleton/skeleton-form/index.js +19 -0
- package/components/skeleton/skeleton-form/index.js.map +1 -0
- package/components/skeleton/skeleton-form/skeleton-form.module.css +32 -0
- package/components/skeleton/skeleton-form/skeleton-form.module.css.js +11 -0
- package/components/skeleton/skeleton-form/skeleton-form.module.css.js.map +1 -0
- package/components/skeleton/skeleton.module.css +87 -0
- package/components/skeleton/skeleton.module.css.js +19 -0
- package/components/skeleton/skeleton.module.css.js.map +1 -0
- package/components/standalone-link/index.js.map +1 -1
- package/components/standalone-link/styles.module.scss +4 -6
- package/components/table/index.js.map +1 -1
- package/components/table/td.js.map +1 -1
- package/components/table/th.js.map +1 -1
- package/components/table/utils.js.map +1 -1
- package/components/tabs/index.js.map +1 -1
- package/components/tabs/tab-panel.js.map +1 -1
- package/components/tabs/tab.js.map +1 -1
- package/components/tabs/tabs.module.scss +11 -54
- package/components/tabs/use-tabs-context.js.map +1 -1
- package/components/text/index.js.map +1 -1
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js +19 -18
- package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js.map +1 -1
- package/components/visualizations/bar-chart/horizontal-chart/index.js +1 -1
- package/components/visualizations/bar-chart/horizontal-chart/index.js.map +1 -1
- package/components/visualizations/bar-chart/horizontal-chart/style.module.css +2 -2
- package/components/visualizations/bar-chart/style.module.css +2 -4
- package/components/visualizations/donut-chart/index.js +49 -48
- package/components/visualizations/donut-chart/index.js.map +1 -1
- package/components/visualizations/donut-chart/styles.module.css +2 -4
- package/index.js +107 -101
- package/index.js.map +1 -1
- package/package.json +8 -7
- package/patterns/card/style.module.css +0 -2
- package/patterns/card/unified-card/index.js.map +1 -1
- package/patterns/copy-button/index.d.ts +3 -3
- package/patterns/copy-button/index.js +17 -17
- package/patterns/copy-button/index.js.map +1 -1
- package/patterns/layout/layout.module.css +2 -8
- package/patterns/product-badge/style.module.css +1 -1
- package/patterns/related-content/style.module.css +1 -1
- package/style.css +1 -1
- package/styles/mixins/button.scss +18 -73
- package/styles/mixins/focus-ring.scss +1 -8
- package/{patterns/copy-button → utils}/clipboard.d.ts +5 -5
- package/{patterns/copy-button → utils}/clipboard.js +1 -1
- package/utils/clipboard.js.map +1 -0
- package/utils/get-contrast-yiq.js.map +1 -1
- package/utils/hooks/use-media-query/index.d.ts +1 -0
- package/utils/hooks/use-media-query/index.js +16 -0
- package/utils/hooks/use-media-query/index.js.map +1 -0
- package/utils/hooks/{use-screen-size.js → use-screen-size/index.js} +2 -2
- package/utils/hooks/use-screen-size/index.js.map +1 -0
- package/utils/i18n/constants/index.d.ts +14 -0
- package/utils/i18n/constants/index.js.map +1 -1
- package/utils/i18n/helpers/index.d.ts +1 -0
- package/utils/i18n/helpers/is-supported-local.d.ts +2 -0
- package/utils/i18n/helpers/{index.js → is-supported-local.js} +1 -1
- package/utils/i18n/helpers/is-supported-local.js.map +1 -0
- package/utils/i18n/helpers/locale-provider.d.ts +1 -1
- package/utils/i18n/helpers/locale-provider.js +1 -1
- package/utils/i18n/helpers/locale-provider.js.map +1 -1
- package/utils/i18n/helpers/to-smart-sentence-case.d.ts +1 -1
- package/utils/i18n/helpers/to-smart-sentence-case.js.map +1 -1
- package/utils/i18n/helpers/to-smart-title-case.d.ts +1 -1
- package/utils/i18n/helpers/to-smart-title-case.js.map +1 -1
- package/utils/i18n/helpers/use-locale.d.ts +1 -1
- package/utils/i18n/helpers/use-locale.js +6 -6
- package/utils/i18n/helpers/use-locale.js.map +1 -1
- package/utils/i18n/index.d.ts +1 -1
- package/utils/i18n/index.js.map +1 -1
- package/utils/i18n/types.d.ts +2 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +8 -6
- package/utils/index.js.map +1 -1
- package/utils/make-normalizer/index.js.map +1 -1
- package/utils/mds-context/index.js.map +1 -1
- package/hooks/use-media-query/index.js +0 -16
- package/hooks/use-media-query/index.js.map +0 -1
- package/patterns/copy-button/clipboard.js.map +0 -1
- package/utils/hooks/use-screen-size.js.map +0 -1
- package/utils/i18n/helpers/index.js.map +0 -1
- /package/utils/hooks/{use-screen-size.d.ts → use-screen-size/index.d.ts} +0 -0
|
@@ -18,8 +18,11 @@ $hds-button-focus-border-width: 3px;
|
|
|
18
18
|
outline-style: solid; // used to avoid double outline+focus-ring in Safari (see https://github.com/hashicorp/design-system-components/issues/161#issuecomment-1031548656)
|
|
19
19
|
outline-color: transparent; // We need this to be transparent for a11y
|
|
20
20
|
isolation: isolate;
|
|
21
|
-
transition:
|
|
22
|
-
|
|
21
|
+
transition:
|
|
22
|
+
color 0.15s ease-in,
|
|
23
|
+
background-color 0.15s ease-in,
|
|
24
|
+
border-color 0.15s ease-in,
|
|
25
|
+
text-decoration-color 0.15s ease-in;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
@mixin hds-button-state-disabled() {
|
|
@@ -54,65 +57,23 @@ $hds-button-focus-border-width: 3px;
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
@mixin hds-button-color-primary() {
|
|
57
|
-
color: var(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
background: var(
|
|
62
|
-
--mds-accent-button-color-background,
|
|
63
|
-
var(--mds-color-palette-blue-200)
|
|
64
|
-
);
|
|
65
|
-
border-color: var(
|
|
66
|
-
--mds-accent-button-color-border,
|
|
67
|
-
var(--mds-color-palette-blue-300)
|
|
68
|
-
);
|
|
60
|
+
color: var(--mds-accent-button-color-foreground, var(--mds-color-foreground-high-contrast));
|
|
61
|
+
background: var(--mds-accent-button-color-background, var(--mds-color-palette-blue-200));
|
|
62
|
+
border-color: var(--mds-accent-button-color-border, var(--mds-color-palette-blue-300));
|
|
69
63
|
border-width: var(--mds-accent-button-border-width, $hds-button-border-width);
|
|
70
64
|
box-shadow: var(--mds-elevation-low-box-shadow);
|
|
71
65
|
|
|
72
66
|
&:hover {
|
|
73
|
-
color: var(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
--mds-accent-button-color-foreground,
|
|
77
|
-
var(--mds-color-foreground-high-contrast)
|
|
78
|
-
)
|
|
79
|
-
);
|
|
80
|
-
background: var(
|
|
81
|
-
--mds-accent-button-color-hover-background,
|
|
82
|
-
var(
|
|
83
|
-
--mds-accent-button-color-background,
|
|
84
|
-
var(--mds-color-palette-blue-300)
|
|
85
|
-
)
|
|
86
|
-
);
|
|
87
|
-
border-color: var(
|
|
88
|
-
--mds-accent-button-color-hover-border,
|
|
89
|
-
var(--mds-accent-button-color-border, var(--mds-color-palette-blue-400))
|
|
90
|
-
);
|
|
67
|
+
color: var(--mds-accent-button-color-hover-foreground, var(--mds-accent-button-color-foreground, var(--mds-color-foreground-high-contrast)));
|
|
68
|
+
background: var(--mds-accent-button-color-hover-background, var(--mds-accent-button-color-background, var(--mds-color-palette-blue-300)));
|
|
69
|
+
border-color: var(--mds-accent-button-color-hover-border, var(--mds-accent-button-color-border, var(--mds-color-palette-blue-400)));
|
|
91
70
|
cursor: pointer;
|
|
92
71
|
}
|
|
93
72
|
|
|
94
73
|
&:focus {
|
|
95
|
-
color: var(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
--mds-accent-button-color-foreground,
|
|
99
|
-
var(--mds-color-foreground-high-contrast)
|
|
100
|
-
)
|
|
101
|
-
);
|
|
102
|
-
background: var(
|
|
103
|
-
--mds-accent-button-color-focus-background,
|
|
104
|
-
var(
|
|
105
|
-
--mds-accent-button-color-background,
|
|
106
|
-
var(--mds-color-palette-blue-200)
|
|
107
|
-
)
|
|
108
|
-
);
|
|
109
|
-
border-color: var(
|
|
110
|
-
--mds-accent-button-color-focus-border,
|
|
111
|
-
var(
|
|
112
|
-
--mds-accent-button-color-border,
|
|
113
|
-
var(--mds-color-focus-action-internal)
|
|
114
|
-
)
|
|
115
|
-
);
|
|
74
|
+
color: var(--mds-accent-button-color-focus-foreground, var(--mds-accent-button-color-foreground, var(--mds-color-foreground-high-contrast)));
|
|
75
|
+
background: var(--mds-accent-button-color-focus-background, var(--mds-accent-button-color-background, var(--mds-color-palette-blue-200)));
|
|
76
|
+
border-color: var(--mds-accent-button-color-focus-border, var(--mds-accent-button-color-border, var(--mds-color-focus-action-internal)));
|
|
116
77
|
|
|
117
78
|
&::before {
|
|
118
79
|
// the position absolute of an element is computed from the inside of the border of the container
|
|
@@ -124,30 +85,14 @@ $hds-button-focus-border-width: 3px;
|
|
|
124
85
|
bottom: -$shift;
|
|
125
86
|
left: -$shift;
|
|
126
87
|
border-color: var(--mds-color-focus-action-external);
|
|
127
|
-
border-radius: $hds-button-border-radius + $hds-button-focus-border-width +
|
|
128
|
-
2px;
|
|
88
|
+
border-radius: $hds-button-border-radius + $hds-button-focus-border-width + 2px;
|
|
129
89
|
}
|
|
130
90
|
}
|
|
131
91
|
|
|
132
92
|
&:active {
|
|
133
|
-
color: var(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
--mds-accent-button-color-foreground,
|
|
137
|
-
var(--mds-color-foreground-high-contrast)
|
|
138
|
-
)
|
|
139
|
-
);
|
|
140
|
-
background: var(
|
|
141
|
-
--mds-accent-button-color-active-background,
|
|
142
|
-
var(
|
|
143
|
-
--mds-accent-button-color-background,
|
|
144
|
-
var(--mds-color-palette-blue-400)
|
|
145
|
-
)
|
|
146
|
-
);
|
|
147
|
-
border-color: var(
|
|
148
|
-
--mds-accent-button-color-active-border,
|
|
149
|
-
var(--mds-accent-button-color-border, var(--mds-color-palette-blue-400))
|
|
150
|
-
);
|
|
93
|
+
color: var(--mds-accent-button-color-active-foreground, var(--mds-accent-button-color-foreground, var(--mds-color-foreground-high-contrast)));
|
|
94
|
+
background: var(--mds-accent-button-color-active-background, var(--mds-accent-button-color-background, var(--mds-color-palette-blue-400)));
|
|
95
|
+
border-color: var(--mds-accent-button-color-active-border, var(--mds-accent-button-color-border, var(--mds-color-palette-blue-400)));
|
|
151
96
|
box-shadow: none;
|
|
152
97
|
|
|
153
98
|
&::before {
|
|
@@ -24,14 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
@mixin hds-focus-ring-with-pseudo-element(
|
|
28
|
-
$top: 0,
|
|
29
|
-
$right: 0,
|
|
30
|
-
$bottom: 0,
|
|
31
|
-
$left: 0,
|
|
32
|
-
$radius: 5px,
|
|
33
|
-
$color: action
|
|
34
|
-
) {
|
|
27
|
+
@mixin hds-focus-ring-with-pseudo-element($top: 0, $right: 0, $bottom: 0, $left: 0, $radius: 5px, $color: action) {
|
|
35
28
|
position: relative;
|
|
36
29
|
outline-style: solid; // used to avoid double outline+focus-ring in Safari (see https://github.com/hashicorp/design-system-components/issues/161#issuecomment-1031548656)
|
|
37
30
|
outline-color: transparent;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type ClipboardHandlerArgs = {
|
|
3
3
|
trigger: Element;
|
|
4
4
|
text: string | number | bigint | undefined;
|
|
5
5
|
target: string | Element | undefined;
|
|
6
6
|
};
|
|
7
|
-
declare const
|
|
7
|
+
declare const onClipboardClickHandler: (named: {
|
|
8
8
|
text: string | number | bigint | undefined;
|
|
9
9
|
target: string | Element | undefined;
|
|
10
10
|
getTextFn: (() => string) | undefined;
|
|
11
|
-
onSuccess: (args:
|
|
12
|
-
onError: (args:
|
|
11
|
+
onSuccess: (args: ClipboardHandlerArgs) => void;
|
|
12
|
+
onError: (args: ClipboardHandlerArgs) => void;
|
|
13
13
|
}) => {
|
|
14
14
|
onClick: (event: MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
15
15
|
};
|
|
16
|
-
export {
|
|
16
|
+
export { onClipboardClickHandler, type ClipboardHandlerArgs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clipboard.js","sources":["../../src/utils/clipboard.ts"],"sourcesContent":["import type { MouseEvent } from 'react'\n\nconst getTextToCopy = (text: string | number | bigint) => {\n\tlet textToCopy: string\n\n\tif (text) {\n\t\tif (typeof text === 'string') {\n\t\t\ttextToCopy = text\n\t\t} else if (\n\t\t\t// context: https://github.com/hashicorp/design-system/pull/1564\n\t\t\ttypeof text === 'number' ||\n\t\t\ttypeof text === 'bigint'\n\t\t) {\n\t\t\ttextToCopy = text.toString()\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`hds-clipboard\\` modifier - \\`text\\` argument must be a string - provided: ${typeof text}`,\n\t\t\t)\n\t\t}\n\t}\n\treturn textToCopy!\n}\n\nconst getTargetElement = (target: string | Element) => {\n\tlet targetElement: Element | null\n\tif (typeof target === 'string') {\n\t\ttargetElement = document.querySelector(target)\n\n\t\tif (!targetElement) {\n\t\t\tconsole.error(\n\t\t\t\t'`hds-clipboard` modifier - `target` selector provided does not point to an existing DOM node, check your selector string',\n\t\t\t\ttargetElement,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t} else if (target instanceof Node && target.nodeType === Node.ELEMENT_NODE) {\n\t\ttargetElement = target\n\t} else {\n\t\tif (target instanceof NodeList) {\n\t\t\tthrow new Error(\n\t\t\t\t'`hds-clipboard` modifier - `target` argument must be a string or a DOM node - provided: a list of DOM nodes',\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`hds-clipboard\\` modifier - \\`target\\` argument must be a string or a DOM node - provided: ${typeof target}`,\n\t\t\t)\n\t\t}\n\t}\n\treturn targetElement\n}\n\nconst getTextToCopyFromTargetElement = (targetElement: Element | undefined) => {\n\tlet textToCopy: string | undefined\n\tif (\n\t\ttargetElement instanceof Node &&\n\t\ttargetElement.nodeType === Node.ELEMENT_NODE\n\t) {\n\t\tif (\n\t\t\ttargetElement instanceof HTMLInputElement || // targetElement.nodeName === 'INPUT' ||\n\t\t\ttargetElement instanceof HTMLTextAreaElement || // targetElement.nodeName === 'TEXTAREA' ||\n\t\t\ttargetElement instanceof HTMLSelectElement // targetElement.nodeName === 'SELECT'\n\t\t) {\n\t\t\ttextToCopy = targetElement.value\n\t\t} else {\n\t\t\t// simplest approach\n\t\t\ttextToCopy = (targetElement as HTMLElement).innerText\n\n\t\t\t// approach based on text selection (left for backup just in case)\n\t\t\t// var selection = window.getSelection();\n\t\t\t// var range = document.createRange();\n\t\t\t// selection.removeAllRanges();\n\t\t\t// range.selectNodeContents(targetElement);\n\t\t\t// selection.addRange(range);\n\t\t\t// textToCopy = selection.toString();\n\t\t\t// selection.removeAllRanges();\n\t\t}\n\t}\n\treturn textToCopy\n}\n\nconst writeTextToClipboard = async (textToCopy: string | undefined) => {\n\t// finally copy the text to the clipboard using the Clipboard API\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API\n\tif (textToCopy) {\n\t\ttry {\n\t\t\t// notice: the \"clipboard-write\" permission is granted automatically to pages when they are in the active tab\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write\n\t\t\tawait navigator.clipboard.writeText(textToCopy)\n\t\t\t// DEBUG uncomment this for easy debugging\n\t\t\t// console.log('success', textToCopy);\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// clipboard write failed\n\t\t\t// this probably never happens (see comment above) or happens only for very old browsers that don't for which `navigator.clipboard` is undefined\n\t\t\tconsole.warn(\n\t\t\t\t'copy action failed, please check your browser‘s permissions',\n\t\t\t\t{\n\t\t\t\t\tid: 'hds-clipboard.write-text-to-clipboard.catch-error',\n\t\t\t\t},\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\treturn false\n\t}\n}\n\nconst copyToClipboard = async (\n\ttext: string | number | bigint | undefined,\n\ttarget: string | Element | undefined,\n\tgetTextFn: (() => string) | undefined,\n) => {\n\tlet textToCopy: string | undefined\n\n\tif (getTextFn) {\n\t\ttextToCopy = getTextFn()\n\t} else if (text) {\n\t\ttextToCopy = getTextToCopy(text)\n\t} else if (target) {\n\t\tconst targetElement = getTargetElement(target)\n\t\ttextToCopy = getTextToCopyFromTargetElement(targetElement)\n\t} else {\n\t\tthrow new Error(\n\t\t\t'`hds-clipboard` modifier - either a `getTextFn`, `text`, or a `target` argument is required',\n\t\t)\n\t}\n\tconst success = await writeTextToClipboard(textToCopy)\n\treturn success\n}\n\ntype ClipboardHandlerArgs = {\n\ttrigger: Element\n\ttext: string | number | bigint | undefined\n\ttarget: string | Element | undefined\n}\n\nconst onClipboardClickHandler = (named: {\n\ttext: string | number | bigint | undefined\n\ttarget: string | Element | undefined\n\tgetTextFn: (() => string) | undefined\n\tonSuccess: (args: ClipboardHandlerArgs) => void\n\tonError: (args: ClipboardHandlerArgs) => void\n}) => {\n\tconst { text, target, getTextFn, onSuccess, onError } = named\n\n\tconst onClick = async (event: MouseEvent<HTMLButtonElement>) => {\n\t\tconst trigger = event.currentTarget\n\t\tconst success = await copyToClipboard(text, target, getTextFn)\n\n\t\t// fire the `onSuccess/onError` callbacks (if provided)\n\t\tif (success) {\n\t\t\tif (typeof onSuccess === 'function') {\n\t\t\t\tonSuccess({ trigger, text, target })\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof onError === 'function') {\n\t\t\t\tonError({ trigger, text, target })\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { onClick }\n}\n\nexport { onClipboardClickHandler, type ClipboardHandlerArgs }\n"],"names":["getTextToCopy","text","textToCopy","getTargetElement","target","targetElement","getTextToCopyFromTargetElement","writeTextToClipboard","copyToClipboard","getTextFn","onClipboardClickHandler","named","onSuccess","onError","event","trigger"],"mappings":"AAEA,MAAMA,IAAgB,CAACC,MAAmC;AACzD,MAAIC;AAEJ,MAAID;AACH,QAAI,OAAOA,KAAS;AACnB,MAAAC,IAAaD;AAAA;AAAA;AAAA,MAGb,OAAOA,KAAS,YAChB,OAAOA,KAAS;AAAA;AAEhB,MAAAC,IAAaD,EAAK,SAAA;AAAA;AAElB,YAAM,IAAI;AAAA,QACT,+EAA+E,OAAOA,CAAI;AAAA,MAAA;AAI7F,SAAOC;AACR,GAEMC,IAAmB,CAACC,MAA6B;AACtD,MAAIC;AACJ,MAAI,OAAOD,KAAW;AAGrB,QAFAC,IAAgB,SAAS,cAAcD,CAAM,GAEzC,CAACC,GAAe;AACnB,cAAQ;AAAA,QACP;AAAA,QACAA;AAAA,MAAA;AAED;AAAA,IACD;AAAA,aACUD,aAAkB,QAAQA,EAAO,aAAa,KAAK;AAC7D,IAAAC,IAAgBD;AAAA;AAEhB,UAAIA,aAAkB,WACf,IAAI;AAAA,MACT;AAAA,IAAA,IAGK,IAAI;AAAA,MACT,+FAA+F,OAAOA,CAAM;AAAA,IAAA;AAI/G,SAAOC;AACR,GAEMC,IAAiC,CAACD,MAAuC;AAC9E,MAAIH;AACJ,SACCG,aAAyB,QACzBA,EAAc,aAAa,KAAK,iBAG/BA,aAAyB;AAAA,EACzBA,aAAyB;AAAA,EACzBA,aAAyB,oBAEzBH,IAAaG,EAAc,QAG3BH,IAAcG,EAA8B,YAYvCH;AACR,GAEMK,IAAuB,OAAOL,MAAmC;AAGtE,MAAIA;AACH,QAAI;AAGH,mBAAM,UAAU,UAAU,UAAUA,CAAU,GAGvC;AAAA,IACR,QAAgB;AAGf,qBAAQ;AAAA,QACP;AAAA,QACA;AAAA,UACC,IAAI;AAAA,QAAA;AAAA,MACL,GAEM;AAAA,IACR;AAAA;AAEA,WAAO;AAET,GAEMM,IAAkB,OACvBP,GACAG,GACAK,MACI;AACJ,MAAIP;AAEJ,MAAIO;AACH,IAAAP,IAAaO,EAAA;AAAA,WACHR;AACV,IAAAC,IAAaF,EAAcC,CAAI;AAAA,WACrBG,GAAQ;AAClB,UAAMC,IAAgBF,EAAiBC,CAAM;AAC7C,IAAAF,IAAaI,EAA+BD,CAAa;AAAA,EAC1D;AACC,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAIF,SADgB,MAAME,EAAqBL,CAAU;AAEtD,GAQMQ,IAA0B,CAACC,MAM3B;AACL,QAAM,EAAE,MAAAV,GAAM,QAAAG,GAAQ,WAAAK,GAAW,WAAAG,GAAW,SAAAC,MAAYF;AAkBxD,SAAO,EAAE,SAhBO,OAAOG,MAAyC;AAC/D,UAAMC,IAAUD,EAAM;AAItB,IAHgB,MAAMN,EAAgBP,GAAMG,GAAQK,CAAS,IAIxD,OAAOG,KAAc,cACxBA,EAAU,EAAE,SAAAG,GAAS,MAAAd,GAAM,QAAAG,EAAA,CAAQ,IAGhC,OAAOS,KAAY,cACtBA,EAAQ,EAAE,SAAAE,GAAS,MAAAd,GAAM,QAAAG,EAAA,CAAQ;AAAA,EAGpC,EAES;AACV;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-contrast-yiq.js","sources":["../../src/utils/get-contrast-yiq.ts"],"sourcesContent":["/**\n * Calculates the contrast of an RGB color and determines whether to use dark or light text.\n * @param rgb - An object containing the red (r), green (g), and blue (b) components of the color.\n * @returns A string indicating whether to use 'dark' or 'light'.\n */\nexport const getContrastYIQ = (rgb: {\n\tr: number\n\tg: number\n\tb: number\n}): string => {\n\t// Calculate the YIQ value using the RGB components\n\tconst yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\n\t// If YIQ is greater than or equal to 192, use 'dark', otherwise use 'light'\n\treturn yiq >= 192 ? 'dark' : 'light'\n}\n\n/**\n * Converts a HEX color string to an RGB object.\n * @param hex - The HEX color string (e.g., \"#ffffff\").\n * @returns An object containing the red (r), green (g), and blue (b) components, and black if the HEX string is invalid.\n */\nexport const hexToRgb = (hex: string): { r: number; g: number; b: number } => {\n\t// Extract the RGB components from the HEX string using a regular expression\n\tconst result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\t// If the HEX string is valid, parse the components and return the RGB object\n\treturn result\n\t\t? {\n\t\t\t\tr: parseInt(result[1], 16),\n\t\t\t\tg: parseInt(result[2], 16),\n\t\t\t\tb: parseInt(result[3], 16),\n\t\t
|
|
1
|
+
{"version":3,"file":"get-contrast-yiq.js","sources":["../../src/utils/get-contrast-yiq.ts"],"sourcesContent":["/**\n * Calculates the contrast of an RGB color and determines whether to use dark or light text.\n * @param rgb - An object containing the red (r), green (g), and blue (b) components of the color.\n * @returns A string indicating whether to use 'dark' or 'light'.\n */\nexport const getContrastYIQ = (rgb: {\n\tr: number\n\tg: number\n\tb: number\n}): string => {\n\t// Calculate the YIQ value using the RGB components\n\tconst yiq = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000\n\t// If YIQ is greater than or equal to 192, use 'dark', otherwise use 'light'\n\treturn yiq >= 192 ? 'dark' : 'light'\n}\n\n/**\n * Converts a HEX color string to an RGB object.\n * @param hex - The HEX color string (e.g., \"#ffffff\").\n * @returns An object containing the red (r), green (g), and blue (b) components, and black if the HEX string is invalid.\n */\nexport const hexToRgb = (hex: string): { r: number; g: number; b: number } => {\n\t// Extract the RGB components from the HEX string using a regular expression\n\tconst result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex)\n\t// If the HEX string is valid, parse the components and return the RGB object\n\treturn result\n\t\t? {\n\t\t\t\tr: parseInt(result[1], 16),\n\t\t\t\tg: parseInt(result[2], 16),\n\t\t\t\tb: parseInt(result[3], 16),\n\t\t\t}\n\t\t: { r: 0, g: 0, b: 0 } // Return black if the HEX string is invalid\n}\n"],"names":["getContrastYIQ","rgb","hexToRgb","hex","result"],"mappings":"AAKO,MAAMA,IAAiB,CAACC,OAMjBA,EAAI,IAAI,MAAMA,EAAI,IAAI,MAAMA,EAAI,IAAI,OAAO,OAE1C,MAAM,SAAS,SAQjBC,IAAW,CAACC,MAAqD;AAE7E,QAAMC,IAAS,4CAA4C,KAAKD,CAAG;AAEnE,SAAOC,IACJ;AAAA,IACA,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,IACzB,GAAG,SAASA,EAAO,CAAC,GAAG,EAAE;AAAA,EAAA,IAEzB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAA;AACrB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMediaQuery: (query: string) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useState as r, useEffect as i } from "react";
|
|
2
|
+
const o = (s) => {
|
|
3
|
+
const [t, a] = r(!1);
|
|
4
|
+
return i(() => {
|
|
5
|
+
const e = window.matchMedia(s);
|
|
6
|
+
e.matches !== t && a(e.matches);
|
|
7
|
+
const n = (c) => {
|
|
8
|
+
a(c.matches);
|
|
9
|
+
};
|
|
10
|
+
return e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
11
|
+
}, [t, s]), t;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
o as useMediaQuery
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/hooks/use-media-query/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport const useMediaQuery = (query: string) => {\n\tconst [matches, setMatches] = useState(false)\n\n\tuseEffect(() => {\n\t\tconst media = window.matchMedia(query)\n\t\tif (media.matches !== matches) {\n\t\t\tsetMatches(media.matches)\n\t\t}\n\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tsetMatches(event.matches)\n\t\t}\n\n\t\tmedia.addEventListener('change', listener)\n\t\treturn () => media.removeEventListener('change', listener)\n\t}, [matches, query])\n\n\treturn matches\n}\n"],"names":["useMediaQuery","query","matches","setMatches","useState","useEffect","media","listener","event"],"mappings":";AAEO,MAAMA,IAAgB,CAACC,MAAkB;AAC/C,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAE5C,SAAAC,EAAU,MAAM;AACf,UAAMC,IAAQ,OAAO,WAAWL,CAAK;AACrC,IAAIK,EAAM,YAAYJ,KACrBC,EAAWG,EAAM,OAAO;AAGzB,UAAMC,IAAW,CAACC,MAA+B;AAChD,MAAAL,EAAWK,EAAM,OAAO;AAAA,IACzB;AAEA,WAAAF,EAAM,iBAAiB,UAAUC,CAAQ,GAClC,MAAMD,EAAM,oBAAoB,UAAUC,CAAQ;AAAA,EAC1D,GAAG,CAACL,GAASD,CAAK,CAAC,GAEZC;AACR;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMediaQuery as e } from "
|
|
2
|
+
import { useMediaQuery as e } from "../use-media-query/index.js";
|
|
3
3
|
const t = () => e("(max-width: 768px)"), m = () => e("(min-width: 768px) and (max-width: 1119px)"), s = () => e("(min-width: 768px)"), d = () => e("(min-width: 1120px)");
|
|
4
4
|
export {
|
|
5
5
|
d as useLarge,
|
|
@@ -7,4 +7,4 @@ export {
|
|
|
7
7
|
s as useMediumUp,
|
|
8
8
|
t as useSmall
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/hooks/use-screen-size/index.ts"],"sourcesContent":["'use client'\n\nimport { useMediaQuery } from '../use-media-query'\n\n// ref: https://github.com/hashicorp/web/blob/main/packages/mds-tokens/src/custom-media.css\nconst useSmall = () => useMediaQuery('(max-width: 768px)')\nconst useMedium = () =>\n\tuseMediaQuery('(min-width: 768px) and (max-width: 1119px)')\nconst useMediumUp = () => useMediaQuery('(min-width: 768px)')\nconst useLarge = () => useMediaQuery('(min-width: 1120px)')\n\nexport { useSmall, useMedium, useMediumUp, useLarge }\n"],"names":["useSmall","useMediaQuery","useMedium","useMediumUp"],"mappings":";;AAMA,MAAMA,IAAA,MAAYC,EACjB,oBAAc,GACTC,IAAA,MAAcD,EAAM,4CAAkC,GACtDE,IAAW,MAAMF,EAAc,oBAAqB;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SupportedLocale } from '../types';
|
|
2
|
+
export declare const DEFAULT_LOCALE = "en";
|
|
3
|
+
export declare const LOCALE_LANGUAGE_MAP: {
|
|
4
|
+
en: string;
|
|
5
|
+
fr: string;
|
|
6
|
+
de: string;
|
|
7
|
+
ja: string;
|
|
8
|
+
ko: string;
|
|
9
|
+
pt: string;
|
|
10
|
+
es: string;
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const SUPPORTED_LOCALES: ("id" | "fr" | "en" | "de" | "es" | "ja" | "ko" | "pt")[];
|
|
14
|
+
export declare const smallWordsByLocale: Record<SupportedLocale, Set<string>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/utils/i18n/constants/index.ts"],"sourcesContent":["import type { SupportedLocale } from '../types'\n\nexport const DEFAULT_LOCALE = 'en'\n\nexport const LOCALE_LANGUAGE_MAP = {\n\ten: 'English',\n\tfr: 'Français',\n\tde: 'Deutsch',\n\tja: '日本語',\n\tko: '한국어',\n\tpt: 'Português',\n\tes: 'Español',\n\tid: 'Bahasa Indonesia',\n}\n\nexport const SUPPORTED_LOCALES = Object.keys(\n\tLOCALE_LANGUAGE_MAP,\n) as SupportedLocale[]\n\nexport const smallWordsByLocale: Record<SupportedLocale, Set<string>> = {\n\ten: new Set([\n\t\t'a',\n\t\t'an',\n\t\t'and',\n\t\t'as',\n\t\t'at',\n\t\t'but',\n\t\t'by',\n\t\t'for',\n\t\t'in',\n\t\t'nor',\n\t\t'of',\n\t\t'on',\n\t\t'or',\n\t\t'so',\n\t\t'the',\n\t\t'to',\n\t\t'up',\n\t\t'yet',\n\t]),\n\tde: new Set(), // Capitalization rules in German don't suppress small words.\n\tes: new Set([\n\t\t'el',\n\t\t'la',\n\t\t'los',\n\t\t'las',\n\t\t'un',\n\t\t'una',\n\t\t'unos',\n\t\t'unas',\n\t\t'y',\n\t\t'o',\n\t\t'pero',\n\t\t'de',\n\t\t'del',\n\t\t'al',\n\t\t'en',\n\t\t'por',\n\t\t'para',\n\t\t'con',\n\t]),\n\tfr: new Set([\n\t\t'le',\n\t\t'la',\n\t\t'les',\n\t\t'un',\n\t\t'une',\n\t\t'et',\n\t\t'de',\n\t\t'du',\n\t\t'des',\n\t\t'en',\n\t\t'à',\n\t\t'au',\n\t\t'aux',\n\t\t'pour',\n\t\t'avec',\n\t]),\n\tja: new Set(), // Japanese doesn't use title casing; characters are not case-sensitive\n\tko: new Set(), // Korean doesn't use casing\n\tpt: new Set([\n\t\t'o',\n\t\t'a',\n\t\t'os',\n\t\t'as',\n\t\t'um',\n\t\t'uma',\n\t\t'uns',\n\t\t'umas',\n\t\t'e',\n\t\t'ou',\n\t\t'mas',\n\t\t'de',\n\t\t'do',\n\t\t'da',\n\t\t'dos',\n\t\t'das',\n\t\t'em',\n\t\t'no',\n\t\t'na',\n\t\t'nos',\n\t\t'nas',\n\t\t'por',\n\t\t'para',\n\t\t'com',\n\t]),\n\tid: new Set(), // ! TODO Determine Indonesian's small word rules, and apply them here\n}\n"],"names":["DEFAULT_LOCALE","LOCALE_LANGUAGE_MAP","SUPPORTED_LOCALES","smallWordsByLocale"],"mappings":"AAEO,MAAMA,IAAiB,MAEjBC,IAAsB;AAAA,EAClC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACL,GAEaC,IAAoB,OAAO;AAAA,EACvCD;AACD,GAEaE,IAA2D;AAAA,EACvE,wBAAQ,IAAI;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAAA,EACD,wBAAQ,IAAA;AAAA;AAAA,EACR,wBAAQ,IAAI;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAAA,EACD,wBAAQ,IAAI;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAAA,EACD,wBAAQ,IAAA;AAAA;AAAA,EACR,wBAAQ,IAAA;AAAA;AAAA,EACR,wBAAQ,IAAI;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAAA,EACD,wBAAQ,IAAA;AAAA;AACT;"}
|
|
@@ -2,3 +2,4 @@ export { LocaleProvider } from './locale-provider';
|
|
|
2
2
|
export { toSmartSentenceCase } from './to-smart-sentence-case';
|
|
3
3
|
export { toSmartTitleCase } from './to-smart-title-case';
|
|
4
4
|
export { useLocale } from './use-locale';
|
|
5
|
+
export { isSupportedLocale } from './is-supported-local';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-supported-local.js","sources":["../../../../src/utils/i18n/helpers/is-supported-local.ts"],"sourcesContent":["import { SUPPORTED_LOCALES } from '../constants'\nimport type { SupportedLocale } from '../types'\n\nexport function isSupportedLocale(locale: string): locale is SupportedLocale {\n\treturn SUPPORTED_LOCALES.includes(locale as SupportedLocale)\n}\n"],"names":["isSupportedLocale","locale","SUPPORTED_LOCALES"],"mappings":";AAGO,SAASA,EAAkBC,GAA2C;AAC5E,SAAOC,EAAkB,SAASD,CAAyB;AAC5D;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
import { createContext as c } from "react";
|
|
4
4
|
import { DEFAULT_LOCALE as l } from "../constants/index.js";
|
|
5
|
-
import { isSupportedLocale as i } from "./
|
|
5
|
+
import { isSupportedLocale as i } from "./is-supported-local.js";
|
|
6
6
|
function n(o) {
|
|
7
7
|
return i(o) ? o : l;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale-provider.js","sources":["../../../../src/utils/i18n/helpers/locale-provider.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, type PropsWithChildren } from 'react'\nimport type { SupportedLocale } from '
|
|
1
|
+
{"version":3,"file":"locale-provider.js","sources":["../../../../src/utils/i18n/helpers/locale-provider.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, type PropsWithChildren } from 'react'\nimport type { SupportedLocale } from '../types'\nimport { DEFAULT_LOCALE } from '../constants'\nimport { isSupportedLocale } from '../helpers'\n\nfunction resolveLocale(input: string): SupportedLocale {\n\treturn isSupportedLocale(input) ? input : DEFAULT_LOCALE\n}\n\ntype LocaleContextValue = {\n\tlocale: SupportedLocale\n}\n\ninterface LocaleProviderProps extends PropsWithChildren {\n\t/**\n\t * Supported locales can be found in `SUPPORTED_LOCALES`.\n\t */\n\tlocale: string\n}\n\nexport const LocaleContext = createContext<LocaleContextValue | undefined>(\n\tundefined,\n)\n\nexport const LocaleProvider = ({ locale, children }: LocaleProviderProps) => {\n\tconst resolvedLocale = resolveLocale(locale)\n\n\treturn (\n\t\t<LocaleContext.Provider value={{ locale: resolvedLocale }}>\n\t\t\t{children}\n\t\t</LocaleContext.Provider>\n\t)\n}\n"],"names":["resolveLocale","isSupportedLocale","input","DEFAULT_LOCALE","LocaleContext","createContext","locale","children","jsx","resolvedLocale"],"mappings":";;;;;AAQC,SAAOA,KAAkB;AAC1B,SAAAC,EAAAC,CAAA,IAAAA,IAAAC;AAaO;AAAsB,MAC5BC,IAAAC;AAAA,EACD;AAEO,OACA,CAAA,EAAiB,QAAAC,GAAA,UAAAC,QAAoB;AAE3C,YACCP,GAAe;AAIjB,SAAA,gBAAAQ,EAAAJ,EAAA,UAAA,EAAA,OAAA,EAAA,QAAAK,EAAA,GAAA,UAAAF,EAAA,CAAA;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SupportedLocale } from '
|
|
1
|
+
import { SupportedLocale } from '../types';
|
|
2
2
|
export declare function toSmartSentenceCase(text: string, locale: SupportedLocale): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-smart-sentence-case.js","sources":["../../../../src/utils/i18n/helpers/to-smart-sentence-case.ts"],"sourcesContent":["import type { SupportedLocale } from '
|
|
1
|
+
{"version":3,"file":"to-smart-sentence-case.js","sources":["../../../../src/utils/i18n/helpers/to-smart-sentence-case.ts"],"sourcesContent":["import type { SupportedLocale } from '../types'\n\nexport function toSmartSentenceCase(\n\ttext: string,\n\tlocale: SupportedLocale,\n): string {\n\t// Skip transformation for non-cased languages\n\tif (locale === 'ja' || locale === 'ko') {\n\t\treturn text\n\t}\n\n\tconst match = text.match(/^(\\s*[\\p{P}\\p{Zs}]*)?(\\p{L})(.*)$/u)\n\n\tif (!match) return text // fallback if no match\n\n\tconst [, leading, firstChar, rest] = match\n\n\treturn (\n\t\t(leading ?? '') +\n\t\tfirstChar.toLocaleUpperCase(locale) +\n\t\trest.toLocaleLowerCase(locale)\n\t)\n}\n"],"names":["toSmartSentenceCase","text","locale","match","leading","firstChar","rest"],"mappings":"AAEO,SAASA,EACfC,GACAC,GACS;AAET,MAAIA,MAAW,QAAQA,MAAW;AACjC,WAAOD;AAGR,QAAME,IAAQF,EAAK,MAAM,oCAAoC;AAE7D,MAAI,CAACE,EAAO,QAAOF;AAEnB,QAAM,GAAGG,GAASC,GAAWC,CAAI,IAAIH;AAErC,UACEC,KAAW,MACZC,EAAU,kBAAkBH,CAAM,IAClCI,EAAK,kBAAkBJ,CAAM;AAE/B;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SupportedLocale } from '
|
|
1
|
+
import { SupportedLocale } from '../types';
|
|
2
2
|
export declare function toSmartTitleCase(text: string, locale: SupportedLocale): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-smart-title-case.js","sources":["../../../../src/utils/i18n/helpers/to-smart-title-case.ts"],"sourcesContent":["import { smallWordsByLocale } from '
|
|
1
|
+
{"version":3,"file":"to-smart-title-case.js","sources":["../../../../src/utils/i18n/helpers/to-smart-title-case.ts"],"sourcesContent":["import { smallWordsByLocale } from '../constants'\nimport type { SupportedLocale } from '../types'\n\nexport function toSmartTitleCase(\n\ttext: string,\n\tlocale: SupportedLocale,\n): string {\n\tconst smallWords = smallWordsByLocale[locale]\n\tconst segments = text.toLocaleLowerCase(locale).split(/([\\s\\-:,.]+)/)\n\n\tlet capitalizeNext = true\n\n\treturn segments\n\t\t.map((segment) => {\n\t\t\tif (/^[\\s\\-:,.]+$/.test(segment)) {\n\t\t\t\t// If punctuation ends a sentence-like clause, capitalize the next word\n\t\t\t\tif (/[:.!?]\\s*$/.test(segment)) {\n\t\t\t\t\tcapitalizeNext = true\n\t\t\t\t}\n\t\t\t\treturn segment\n\t\t\t}\n\n\t\t\t// For non-cased languages (ja, ko), return as-is\n\t\t\tif (!segment.charAt(0).toLocaleUpperCase) return segment\n\n\t\t\tif (capitalizeNext || !smallWords.has(segment)) {\n\t\t\t\tcapitalizeNext = false\n\t\t\t\treturn segment.charAt(0).toLocaleUpperCase(locale) + segment.slice(1)\n\t\t\t} else {\n\t\t\t\treturn segment\n\t\t\t}\n\t\t})\n\t\t.join('')\n}\n"],"names":["toSmartTitleCase","text","locale","smallWords","smallWordsByLocale","segments","capitalizeNext","segment"],"mappings":";AAGO,SAASA,EACfC,GACAC,GACS;AACT,QAAMC,IAAaC,EAAmBF,CAAM,GACtCG,IAAWJ,EAAK,kBAAkBC,CAAM,EAAE,MAAM,cAAc;AAEpE,MAAII,IAAiB;AAErB,SAAOD,EACL,IAAI,CAACE,MACD,eAAe,KAAKA,CAAO,KAE1B,aAAa,KAAKA,CAAO,MAC5BD,IAAiB,KAEXC,KAIHA,EAAQ,OAAO,CAAC,EAAE,sBAEnBD,KAAkB,CAACH,EAAW,IAAII,CAAO,MAC5CD,IAAiB,IACVC,EAAQ,OAAO,CAAC,EAAE,kBAAkBL,CAAM,IAAIK,EAAQ,MAAM,CAAC,KAJpBA,CAQjD,EACA,KAAK,EAAE;AACV;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SupportedLocale } from '
|
|
1
|
+
import { SupportedLocale } from '../types';
|
|
2
2
|
export declare function useLocale(): SupportedLocale;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { useContext as
|
|
2
|
-
import { LocaleContext as
|
|
1
|
+
import { useContext as r } from "react";
|
|
2
|
+
import { LocaleContext as n } from "./locale-provider.js";
|
|
3
3
|
import { DEFAULT_LOCALE as e } from "../constants/index.js";
|
|
4
4
|
let t = !1;
|
|
5
|
-
function
|
|
6
|
-
const o = n
|
|
5
|
+
function f() {
|
|
6
|
+
const o = r(n)?.locale;
|
|
7
7
|
return !o && typeof window < "u" && !t && (t = !0, console.warn(
|
|
8
|
-
`[@
|
|
8
|
+
`[@hashicorp/mds-react] No <LocaleProvider> found. Defaulting to "${e}".`
|
|
9
9
|
)), o || e;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
f as useLocale
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=use-locale.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-locale.js","sources":["../../../../src/utils/i18n/helpers/use-locale.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { LocaleContext } from './locale-provider'\nimport type { SupportedLocale } from '
|
|
1
|
+
{"version":3,"file":"use-locale.js","sources":["../../../../src/utils/i18n/helpers/use-locale.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { LocaleContext } from './locale-provider'\nimport type { SupportedLocale } from '../types'\nimport { DEFAULT_LOCALE } from '../constants'\n\nlet hasWarned = false\n\nexport function useLocale(): SupportedLocale {\n\tconst locale = useContext(LocaleContext)?.locale\n\n\tif (!locale && typeof window !== 'undefined' && !hasWarned) {\n\t\thasWarned = true\n\t\tconsole.warn(\n\t\t\t`[@hashicorp/mds-react] No <LocaleProvider> found. Defaulting to \"${DEFAULT_LOCALE}\".`,\n\t\t)\n\t}\n\n\treturn locale || DEFAULT_LOCALE\n}\n"],"names":["hasWarned","useLocale","locale","useContext","LocaleContext","DEFAULT_LOCALE"],"mappings":";;;AAKA,IAAIA,IAAY;AAET,SAASC,IAA6B;AAC5C,QAAMC,IAASC,EAAWC,CAAa,GAAG;AAE1C,SAAI,CAACF,KAAU,OAAO,SAAW,OAAe,CAACF,MAChDA,IAAY,IACZ,QAAQ;AAAA,IACP,oEAAoEK,CAAc;AAAA,EAAA,IAI7EH,KAAUG;AAClB;"}
|
package/utils/i18n/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportedLocale } from '
|
|
1
|
+
import { SupportedLocale } from './types';
|
|
2
2
|
type Capitalization = 'none' | 'lower' | 'sentence' | 'title' | 'upper';
|
|
3
3
|
type DotPrefix<T extends string, U extends string> = `${T}.${U}`;
|
|
4
4
|
type NestedKeyOf<ObjectType extends object> = {
|
package/utils/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/i18n/index.ts"],"sourcesContent":["import type { SupportedLocale } from '
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/i18n/index.ts"],"sourcesContent":["import type { SupportedLocale } from './types'\nimport { toSmartSentenceCase, toSmartTitleCase } from './helpers'\n\ntype Capitalization = 'none' | 'lower' | 'sentence' | 'title' | 'upper'\n\ntype DotPrefix<T extends string, U extends string> = `${T}.${U}`\n\ntype NestedKeyOf<ObjectType extends object> = {\n\t[K in keyof ObjectType & string]: ObjectType[K] extends object\n\t\t? DotPrefix<K, NestedKeyOf<ObjectType[K]>>\n\t\t: K\n}[keyof ObjectType & string]\n\nfunction getByDotPath<T extends object, P extends string>(\n\tobj: T,\n\tpath: P,\n): unknown {\n\treturn path.split('.').reduce((acc: unknown, part) => {\n\t\tif (typeof acc === 'object' && acc !== null && part in acc) {\n\t\t\treturn (acc as Record<string, unknown>)[part]\n\t\t}\n\t\treturn undefined\n\t}, obj)\n}\n\nfunction createLocalize<Messages extends Record<string, unknown>>(\n\tlocalizations: Record<SupportedLocale, Messages>,\n\tfallbackLocale: SupportedLocale = 'en',\n) {\n\ttype Key = NestedKeyOf<Messages>\n\n\treturn function translate(\n\t\tkey: Key,\n\t\tlocale: SupportedLocale,\n\t\tcapitalization?: Capitalization,\n\t): string {\n\t\tconst word =\n\t\t\tgetByDotPath(localizations[locale], key) ??\n\t\t\tgetByDotPath(localizations[fallbackLocale], key)\n\n\t\tif (typeof word !== 'string') return ''\n\n\t\tswitch (capitalization) {\n\t\t\tcase 'title':\n\t\t\t\treturn toSmartTitleCase(word, locale)\n\t\t\tcase 'sentence':\n\t\t\t\treturn toSmartSentenceCase(word, locale)\n\t\t\tcase 'upper':\n\t\t\t\treturn word.toLocaleUpperCase(locale)\n\t\t\tcase 'lower':\n\t\t\t\treturn word.toLocaleLowerCase(locale)\n\t\t\tcase 'none':\n\t\t\tdefault:\n\t\t\t\treturn word\n\t\t}\n\t}\n}\n\nexport const localize = createLocalize({\n\tde: {\n\t\toptional: 'optional', // \"optional\" is the same in German\n\t\trequired: 'erforderlich',\n\t},\n\ten: {\n\t\toptional: 'optional',\n\t\trequired: 'required',\n\t},\n\tes: {\n\t\toptional: 'opcional',\n\t\trequired: 'obligatorio',\n\t},\n\tfr: {\n\t\toptional: 'facultatif',\n\t\trequired: 'obligatoire',\n\t},\n\tid: {\n\t\t// ! TODO Translate text to Indonesian\n\t\toptional: 'optional',\n\t\trequired: 'required',\n\t},\n\tja: {\n\t\toptional: '任意',\n\t\trequired: '必須',\n\t},\n\tko: {\n\t\toptional: '선택 사항',\n\t\trequired: '필수',\n\t},\n\tpt: {\n\t\toptional: 'opcional',\n\t\trequired: 'obrigatório',\n\t},\n})\n"],"names":["getByDotPath","obj","path","acc","part","createLocalize","localizations","fallbackLocale","key","locale","capitalization","word","toSmartTitleCase","toSmartSentenceCase","localize"],"mappings":";;AAaA,SAASA,EACRC,GACAC,GACU;AACV,SAAOA,EAAK,MAAM,GAAG,EAAE,OAAO,CAACC,GAAcC,MAAS;AACrD,QAAI,OAAOD,KAAQ,YAAYA,MAAQ,QAAQC,KAAQD;AACtD,aAAQA,EAAgCC,CAAI;AAAA,EAG9C,GAAGH,CAAG;AACP;AAEA,SAASI,EACRC,GACAC,IAAkC,MACjC;AAGD,SAAO,SACNC,GACAC,GACAC,GACS;AACT,UAAMC,IACLX,EAAaM,EAAcG,CAAM,GAAGD,CAAG,KACvCR,EAAaM,EAAcC,CAAc,GAAGC,CAAG;AAEhD,QAAI,OAAOG,KAAS,SAAU,QAAO;AAErC,YAAQD,GAAA;AAAA,MACP,KAAK;AACJ,eAAOE,EAAiBD,GAAMF,CAAM;AAAA,MACrC,KAAK;AACJ,eAAOI,EAAoBF,GAAMF,CAAM;AAAA,MACxC,KAAK;AACJ,eAAOE,EAAK,kBAAkBF,CAAM;AAAA,MACrC,KAAK;AACJ,eAAOE,EAAK,kBAAkBF,CAAM;AAAA,MACrC,KAAK;AAAA,MACL;AACC,eAAOE;AAAA,IAAA;AAAA,EAEV;AACD;AAEO,MAAMG,IAAWT,EAAe;AAAA,EACtC,IAAI;AAAA,IACH,UAAU;AAAA;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA;AAAA,IAEH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAAA,EAEX,IAAI;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,EAAA;AAEZ,CAAC;"}
|
package/utils/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { useLarge, useMedium, useMediumUp, useSmall, } from './hooks/use-screen-
|
|
|
2
2
|
export { MDSProvider } from './mds-context';
|
|
3
3
|
export type { MDSLinkProps, MDSImageProps } from './mds-context';
|
|
4
4
|
export { LocaleProvider, useLocale } from './i18n/helpers';
|
|
5
|
+
export { onClipboardClickHandler, type ClipboardHandlerArgs } from './clipboard';
|
package/utils/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { useLarge as o, useMedium as m, useMediumUp as
|
|
1
|
+
import { useLarge as o, useMedium as m, useMediumUp as l, useSmall as p } from "./hooks/use-screen-size/index.js";
|
|
2
2
|
import { MDSProvider as a } from "./mds-context/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { onClipboardClickHandler as i } from "./clipboard.js";
|
|
4
|
+
import { LocaleProvider as s } from "./i18n/helpers/locale-provider.js";
|
|
5
|
+
import { useLocale as x } from "./i18n/helpers/use-locale.js";
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
+
s as LocaleProvider,
|
|
7
8
|
a as MDSProvider,
|
|
9
|
+
i as onClipboardClickHandler,
|
|
8
10
|
o as useLarge,
|
|
9
|
-
|
|
11
|
+
x as useLocale,
|
|
10
12
|
m as useMedium,
|
|
11
|
-
|
|
13
|
+
l as useMediumUp,
|
|
12
14
|
p as useSmall
|
|
13
15
|
};
|
|
14
16
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/make-normalizer/index.tsx"],"sourcesContent":["export type NormalizerOpts<TOut extends string> = {\n\taliases?: Record<string, TOut>\n\tfallback?: TOut\n\ttransform?: (raw: string) => string\n}\n\nexport type Normalizer<TOut extends string> = {\n\t(input: unknown, opts?: NormalizerOpts<TOut>): TOut\n\twith(bound: NormalizerOpts<TOut>): Normalizer<TOut>\n}\n\nexport function makeNormalizer<\n\tTAllowed extends readonly string[],\n\tTOut extends TAllowed[number]
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/make-normalizer/index.tsx"],"sourcesContent":["export type NormalizerOpts<TOut extends string> = {\n\taliases?: Record<string, TOut>\n\tfallback?: TOut\n\ttransform?: (raw: string) => string\n}\n\nexport type Normalizer<TOut extends string> = {\n\t(input: unknown, opts?: NormalizerOpts<TOut>): TOut\n\twith(bound: NormalizerOpts<TOut>): Normalizer<TOut>\n}\n\nexport function makeNormalizer<\n\tTAllowed extends readonly string[],\n\tTOut extends TAllowed[number],\n>(\n\tallowed: TAllowed,\n\tdefaults: {\n\t\tfallback: TOut\n\t\taliases?: Record<string, TOut>\n\t\ttransform?: (raw: string) => string\n\t},\n): Normalizer<TOut> {\n\tconst list = allowed as readonly string[]\n\n\tconst defaultAliases: Record<string, TOut> =\n\t\tdefaults.aliases ??\n\t\t(Object.fromEntries(list.map((v) => [v, v])) as Record<string, TOut>)\n\n\tconst defaultTransform =\n\t\tdefaults.transform ?? ((s: string) => s.trim().toLowerCase())\n\n\tconst core = ((input: unknown, opts?: NormalizerOpts<TOut>): TOut => {\n\t\tconst aliases = { ...defaultAliases, ...(opts?.aliases ?? {}) }\n\t\tconst fallback = opts?.fallback ?? defaults.fallback\n\t\tconst transform = opts?.transform ?? defaultTransform\n\n\t\tif (typeof input !== 'string') return fallback\n\n\t\tconst s = transform(input)\n\t\tconst candidate = (aliases[s] ?? s) as string\n\t\treturn list.includes(candidate) ? (candidate as TOut) : fallback\n\t}) as Normalizer<TOut>\n\n\tcore.with = (bound: NormalizerOpts<TOut>) =>\n\t\t((input: unknown, opts?: NormalizerOpts<TOut>) =>\n\t\t\tcore(input, { ...bound, ...(opts ?? {}) })) as Normalizer<TOut>\n\n\treturn core\n}\n\n/**\n * Group helper: normalize a whole props object in one call.\n * - `all.transform` applies to every normalizer in the set (safe cross-type).\n * - `each[key]` lets you override per-key opts (aliases/fallback/transform).\n */\nexport function makeNormalizerSet<TOuts extends Record<string, string>>(map: {\n\t[K in keyof TOuts]: Normalizer<TOuts[K]>\n}) {\n\ttype In = { [K in keyof TOuts]?: unknown | null }\n\ttype Out = { [K in keyof TOuts]: TOuts[K] }\n\ttype All = Pick<NormalizerOpts<string>, 'transform'> // safe cross-prop\n\ttype Each = { [K in keyof TOuts]?: NormalizerOpts<TOuts[K]> }\n\ttype Call = (input: In, opts?: { all?: All; each?: Each }) => Out\n\n\tconst call = ((input: In, opts?: { all?: All; each?: Each }) => {\n\t\tconst out = {} as Out\n\t\tfor (const k in map) {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(map, k)) continue\n\t\t\tconst key = k as keyof TOuts\n\t\t\tconst n = map[key]\n\t\t\tconst base = opts?.all ? n.with(opts.all as any) : n\n\t\t\tout[key] = base(input?.[key], opts?.each?.[key]) as TOuts[typeof key]\n\t\t}\n\t\treturn out\n\t}) as Call & { with(all: All): Call }\n\n\tcall.with = (all: All) => {\n\t\tconst bound = {} as { [K in keyof TOuts]: Normalizer<TOuts[K]> }\n\t\tfor (const k in map) {\n\t\t\tif (!Object.prototype.hasOwnProperty.call(map, k)) continue\n\t\t\tconst key = k as keyof TOuts\n\t\t\tbound[key] = map[key].with(all as any)\n\t\t}\n\t\treturn makeNormalizerSet(bound)\n\t}\n\n\treturn call\n}\n"],"names":["makeNormalizer","allowed","defaults","list","defaultAliases","v","defaultTransform","s","core","input","opts","aliases","fallback","transform","candidate","bound","makeNormalizerSet","map","call","out","k","key","n","base","all"],"mappings":"AAWO,SAASA,EAIfC,GACAC,GAKmB;AACnB,QAAMC,IAAOF,GAEPG,IACLF,EAAS,WACR,OAAO,YAAYC,EAAK,IAAI,CAACE,MAAM,CAACA,GAAGA,CAAC,CAAC,CAAC,GAEtCC,IACLJ,EAAS,cAAc,CAACK,MAAcA,EAAE,OAAO,gBAE1CC,IAAQ,CAACC,GAAgBC,MAAsC;AACpE,UAAMC,IAAU,EAAE,GAAGP,GAAgB,GAAIM,GAAM,WAAW,GAAC,GACrDE,IAAWF,GAAM,YAAYR,EAAS,UACtCW,IAAYH,GAAM,aAAaJ;AAErC,QAAI,OAAOG,KAAU,SAAU,QAAOG;AAEtC,UAAML,IAAIM,EAAUJ,CAAK,GACnBK,IAAaH,EAAQJ,CAAC,KAAKA;AACjC,WAAOJ,EAAK,SAASW,CAAS,IAAKA,IAAqBF;AAAA,EACzD;AAEA,SAAAJ,EAAK,OAAO,CAACO,MACX,CAACN,GAAgBC,MACjBF,EAAKC,GAAO,EAAE,GAAGM,GAAO,GAAIL,KAAQ,CAAA,GAAK,GAEpCF;AACR;AAOO,SAASQ,EAAwDC,GAErE;AAOF,QAAMC,IAAQ,CAACT,GAAWC,MAAsC;AAC/D,UAAMS,IAAM,CAAA;AACZ,eAAWC,KAAKH,GAAK;AACpB,UAAI,CAAC,OAAO,UAAU,eAAe,KAAKA,GAAKG,CAAC,EAAG;AACnD,YAAMC,IAAMD,GACNE,IAAIL,EAAII,CAAG,GACXE,IAAOb,GAAM,MAAMY,EAAE,KAAKZ,EAAK,GAAU,IAAIY;AACnD,MAAAH,EAAIE,CAAG,IAAIE,EAAKd,IAAQY,CAAG,GAAGX,GAAM,OAAOW,CAAG,CAAC;AAAA,IAChD;AACA,WAAOF;AAAA,EACR;AAEA,SAAAD,EAAK,OAAO,CAACM,MAAa;AACzB,UAAMT,IAAQ,CAAA;AACd,eAAWK,KAAKH,GAAK;AACpB,UAAI,CAAC,OAAO,UAAU,eAAe,KAAKA,GAAKG,CAAC,EAAG;AACnD,YAAMC,IAAMD;AACZ,MAAAL,EAAMM,CAAG,IAAIJ,EAAII,CAAG,EAAE,KAAKG,CAAU;AAAA,IACtC;AACA,WAAOR,EAAkBD,CAAK;AAAA,EAC/B,GAEOG;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/utils/mds-context/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tcreateContext,\n\tuseContext,\n\tforwardRef,\n\ttype CSSProperties,\n\ttype ImgHTMLAttributes,\n\ttype ComponentType,\n} from 'react'\n\n/* ----------------------------- Image ----------------------------- */\n\ntype FillLayout = {\n\tfill: true\n\t/** Strongly recommended when using fill */\n\tsizes?: string\n}\n\ntype FixedLayout = {\n\twidth: number\n\theight: number\n\tfill?: false\n}\n\n/** Next/Image extras we want to allow on adapters (all optional here) */\ntype NextImageExtras = {\n\tpriority?: boolean\n\tplaceholder?: 'blur' | 'empty'\n\tblurDataURL?: string\n\tquality?: number\n\tunoptimized?: boolean\n\tonLoadingComplete?: (img: HTMLImageElement) => void\n}\n\nexport type MDSImageProps =\n\t// Core, DS-neutral props\n\t({\n\t\talt: string\n\t\t/** DS-neutral; Next adapter may also accept StaticImageData at runtime */\n\t\tsrc: string\n\t\tclassName?: string\n\t\tstyle?: CSSProperties\n\t\tloading?: 'eager' | 'lazy'\n\t\tdecoding?: 'sync' | 'async' | 'auto'\n\t\tfetchPriority?: 'high' | 'low' | 'auto'\n\t\tobjectFit?: string\n\t\tobjectPosition?: string\n\t} & (FillLayout | FixedLayout)) &\n\t\t// Allow common <img> props without clobbering the ones we define\n\t\tOmit<\n\t\t\tImgHTMLAttributes<HTMLImageElement>,\n\t\t\t'src' | 'alt' | 'width' | 'height' | 'loading' | 'decoding'\n\t\t> &\n\t\t// Make Next extras available (adapters can use them; default img ignores)\n\t\tNextImageExtras\n\ntype ImageComponent = ComponentType<MDSImageProps>\n\nconst DefaultImg: ImageComponent = (props) => {\n\tconst {\n\t\talt,\n\t\tsrc,\n\t\tclassName,\n\t\tstyle,\n\t\tloading,\n\t\tdecoding,\n\t\tfetchPriority,\n\t\tobjectFit,\n\t\tobjectPosition,\n\t\t// Next extras are accepted but ignored by the default renderer\n\t} = props\n\n\tif ('fill' in props && props.fill) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\talt={alt}\n\t\t\t\tsrc={src}\n\t\t\t\tclassName={className}\n\t\t\t\tloading={loading}\n\t\t\t\tdecoding={decoding}\n\t\t\t\tfetchPriority={fetchPriority}\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tinset: 0,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tobjectFit: (objectFit as CSSProperties['objectFit']) ?? 'cover',\n\t\t\t\t\tobjectPosition,\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn (\n\t\t<img\n\t\t\talt={alt}\n\t\t\tsrc={src}\n\t\t\twidth={props.width}\n\t\t\theight={props.height}\n\t\t\tclassName={className}\n\t\t\tloading={loading}\n\t\t\tdecoding={decoding}\n\t\t\tfetchPriority={fetchPriority}\n\t\t\tstyle={{\n\t\t\t\tobjectFit: objectFit as CSSProperties['objectFit'],\n\t\t\t\tobjectPosition,\n\t\t\t\t...style,\n\t\t\t}}\n\t\t/>\n\t)\n}\n\nconst ImageCtx = createContext<ImageComponent>(DefaultImg)\n\n/* ------------------------------ Link ----------------------------- */\n\n/**\n * Start from all standard <a> props, then refine:\n * - force a typed href\n * - keep children required\n * - keep Next-specific props optional so the default <a> can ignore them\n */\nexport type MDSLinkProps = Omit<\n\tReact.AnchorHTMLAttributes<HTMLAnchorElement>,\n\t'href'\n> & {\n\thref: string | URL\n\ttarget?: React.HTMLAttributeAnchorTarget\n\tonClick?: React.MouseEventHandler<HTMLAnchorElement>\n} & {\n\t// Next.js extras (optional; default <a> ignores them)\n\tprefetch?: boolean\n\treplace?: boolean\n\tscroll?: boolean\n\tshallow?: boolean\n\tlocale?: string | false\n}\n\ntype LinkComponent = React.ForwardRefExoticComponent<\n\tMDSLinkProps & React.RefAttributes<HTMLAnchorElement>\n>\n\nconst DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, MDSLinkProps>(\n\t({ href, children, ...rest }, ref) => (\n\t\t<a\n\t\t\tref={ref}\n\t\t\thref={typeof href === 'string' ? href : href.toString()}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{children}\n\t\t</a>\n\t)
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/utils/mds-context/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n\tcreateContext,\n\tuseContext,\n\tforwardRef,\n\ttype CSSProperties,\n\ttype ImgHTMLAttributes,\n\ttype ComponentType,\n} from 'react'\n\n/* ----------------------------- Image ----------------------------- */\n\ntype FillLayout = {\n\tfill: true\n\t/** Strongly recommended when using fill */\n\tsizes?: string\n}\n\ntype FixedLayout = {\n\twidth: number\n\theight: number\n\tfill?: false\n}\n\n/** Next/Image extras we want to allow on adapters (all optional here) */\ntype NextImageExtras = {\n\tpriority?: boolean\n\tplaceholder?: 'blur' | 'empty'\n\tblurDataURL?: string\n\tquality?: number\n\tunoptimized?: boolean\n\tonLoadingComplete?: (img: HTMLImageElement) => void\n}\n\nexport type MDSImageProps =\n\t// Core, DS-neutral props\n\t({\n\t\talt: string\n\t\t/** DS-neutral; Next adapter may also accept StaticImageData at runtime */\n\t\tsrc: string\n\t\tclassName?: string\n\t\tstyle?: CSSProperties\n\t\tloading?: 'eager' | 'lazy'\n\t\tdecoding?: 'sync' | 'async' | 'auto'\n\t\tfetchPriority?: 'high' | 'low' | 'auto'\n\t\tobjectFit?: string\n\t\tobjectPosition?: string\n\t} & (FillLayout | FixedLayout)) &\n\t\t// Allow common <img> props without clobbering the ones we define\n\t\tOmit<\n\t\t\tImgHTMLAttributes<HTMLImageElement>,\n\t\t\t'src' | 'alt' | 'width' | 'height' | 'loading' | 'decoding'\n\t\t> &\n\t\t// Make Next extras available (adapters can use them; default img ignores)\n\t\tNextImageExtras\n\ntype ImageComponent = ComponentType<MDSImageProps>\n\nconst DefaultImg: ImageComponent = (props) => {\n\tconst {\n\t\talt,\n\t\tsrc,\n\t\tclassName,\n\t\tstyle,\n\t\tloading,\n\t\tdecoding,\n\t\tfetchPriority,\n\t\tobjectFit,\n\t\tobjectPosition,\n\t\t// Next extras are accepted but ignored by the default renderer\n\t} = props\n\n\tif ('fill' in props && props.fill) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\talt={alt}\n\t\t\t\tsrc={src}\n\t\t\t\tclassName={className}\n\t\t\t\tloading={loading}\n\t\t\t\tdecoding={decoding}\n\t\t\t\tfetchPriority={fetchPriority}\n\t\t\t\tstyle={{\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tinset: 0,\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t\tobjectFit: (objectFit as CSSProperties['objectFit']) ?? 'cover',\n\t\t\t\t\tobjectPosition,\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn (\n\t\t<img\n\t\t\talt={alt}\n\t\t\tsrc={src}\n\t\t\twidth={props.width}\n\t\t\theight={props.height}\n\t\t\tclassName={className}\n\t\t\tloading={loading}\n\t\t\tdecoding={decoding}\n\t\t\tfetchPriority={fetchPriority}\n\t\t\tstyle={{\n\t\t\t\tobjectFit: objectFit as CSSProperties['objectFit'],\n\t\t\t\tobjectPosition,\n\t\t\t\t...style,\n\t\t\t}}\n\t\t/>\n\t)\n}\n\nconst ImageCtx = createContext<ImageComponent>(DefaultImg)\n\n/* ------------------------------ Link ----------------------------- */\n\n/**\n * Start from all standard <a> props, then refine:\n * - force a typed href\n * - keep children required\n * - keep Next-specific props optional so the default <a> can ignore them\n */\nexport type MDSLinkProps = Omit<\n\tReact.AnchorHTMLAttributes<HTMLAnchorElement>,\n\t'href'\n> & {\n\thref: string | URL\n\ttarget?: React.HTMLAttributeAnchorTarget\n\tonClick?: React.MouseEventHandler<HTMLAnchorElement>\n} & {\n\t// Next.js extras (optional; default <a> ignores them)\n\tprefetch?: boolean\n\treplace?: boolean\n\tscroll?: boolean\n\tshallow?: boolean\n\tlocale?: string | false\n}\n\ntype LinkComponent = React.ForwardRefExoticComponent<\n\tMDSLinkProps & React.RefAttributes<HTMLAnchorElement>\n>\n\nconst DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, MDSLinkProps>(\n\t({ href, children, ...rest }, ref) => (\n\t\t<a\n\t\t\tref={ref}\n\t\t\thref={typeof href === 'string' ? href : href.toString()}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{children}\n\t\t</a>\n\t),\n)\n\nDefaultLink.displayName = 'DefaultLink'\n\nconst LinkCtx = createContext<LinkComponent>(DefaultLink)\n\n/* ----------------------- Provider + hooks ------------------------ */\n\nexport function MDSProvider({\n\tchildren,\n\timageComponent,\n\tlinkComponent,\n}: {\n\tchildren: React.ReactNode\n\timageComponent?: ImageComponent\n\tlinkComponent?: LinkComponent\n}) {\n\treturn (\n\t\t<ImageCtx.Provider value={imageComponent ?? DefaultImg}>\n\t\t\t<LinkCtx.Provider value={linkComponent ?? DefaultLink}>\n\t\t\t\t{children}\n\t\t\t</LinkCtx.Provider>\n\t\t</ImageCtx.Provider>\n\t)\n}\n\nexport function useMDSImage() {\n\treturn useContext(ImageCtx)\n}\n\nexport function useMDSLink() {\n\treturn useContext(LinkCtx)\n}\n"],"names":["DefaultImg","props","alt","src","className","style","loading","decoding","fetchPriority","objectFit","objectPosition","jsx","ImageCtx","createContext","DefaultLink","href","children","rest","ref","LinkCtx","MDSProvider","imageComponent","linkComponent","useMDSImage","useContext","useMDSLink"],"mappings":";;;AA4DC,MAAAA,IAAM,CAAAC,MAAA;AAAA,QACL;AAAA,IACA,KAAAC;AAAA,IACA,KAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,eAAAC;AAAA,IACA,WAAAC;AAAA,IAAA,gBAAAC;AAAA;AAAA,EAID,IAAIT;AACH,0BACC,OAAC,gBAAAU;AAAA,IAAA;AAAA,IAAA;AAAA,MAEA,KAAAT;AAAA,MACA,KAAAC;AAAA,MACA,WAAAC;AAAA,MACA,SAAAE;AAAA,MACA,UAAAC;AAAA,MACA,eAAAC;AAAA,MAAO,OACN;AAAA,QACA,UAAO;AAAA,QACP,OAAO;AAAA,QACP;QACA,QAAA;AAAA,QACA,WAAAC,KAAA;AAAA,QACA,gBAAAC;AAAA,QAAG,GAAAL;AAAA,MACJ;AAAA,IACD;AAAA,EAEF,IAGE,gBAAAM;AAAA,IAAA;AAAA,IAAA;AAAA,MAEA,KAAAT;AAAA,MACA,KAAAC;AAAA,MACA,SAAQ;AAAA,MACR,QAAAF,EAAA;AAAA,MACA,WAAAG;AAAA,MACA,SAAAE;AAAA,MACA,UAAAC;AAAA,MACA,eAAAC;AAAA,MAAO,OACN;AAAA,QACA,WAAAC;AAAA,QACA,gBAAAC;AAAA,QAAG,GAAAL;AAAA,MACJ;AAAA,IACD;AAAA,EAEF;AAEA,GA8BMO,IAAAC,EAA6Bb,CAAA,GAC/Bc;EACF,CAAA,EAAC,MAAAC,GAAA,UAAAC,GAAA,GAAAC,EAAA,GAAAC,MAAA,gBAAAP;AAAA,IAAA;AAAA,IAAA;AAAA,MAEA,KAAAO;AAAA,MACC,MAAG,OAAAH,KAAA,WAAAA,IAAAA,EAAA,SAAA;AAAA,MAEH,GAAAE;AAAA,MAAA,UAAAD;AAAA,IAAA;AAAA,EAGJ;AAEA;AAEAF,EAAM,cAAU;AAIT,MAAAK,MAAqBL,CAAA;AAAA,SAC3BM,EAAA;AAAA,EACA,UAAAJ;AAAA,EACA,gBAAAK;AAAA,EACD,eAAAC;AAKC,GAAA;AAOD,SAAA,gBAAAX,EAAAC,EAAA,UAAA,EAAA,OAAAS,KAAArB,GAAA,UAAA,gBAAAW,EAAAQ,EAAA,UAAA,EAAA,OAAAG,KAAAR,GAAA,UAAAE,EAAA,CAAA,EAAA,CAAA;AAEO;AACN,SAAOO,IAAW;AACnB,SAAAC,EAAAZ,CAAA;AAEO;AACN,SAAOa,IAAW;AACnB,SAAAD,EAAAL,CAAA;;"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useState as r, useEffect as i } from "react";
|
|
2
|
-
function o(s) {
|
|
3
|
-
const [t, n] = r(!1);
|
|
4
|
-
return i(() => {
|
|
5
|
-
const e = window.matchMedia(s);
|
|
6
|
-
e.matches !== t && n(e.matches);
|
|
7
|
-
const a = (c) => {
|
|
8
|
-
n(c.matches);
|
|
9
|
-
};
|
|
10
|
-
return e.addEventListener("change", a), () => e.removeEventListener("change", a);
|
|
11
|
-
}, [t, s]), t;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
o as useMediaQuery
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../hooks/use-media-query/index.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\nfunction useMediaQuery(query: string) {\n\tconst [matches, setMatches] = useState(false)\n\n\tuseEffect(() => {\n\t\tconst media = window.matchMedia(query)\n\t\tif (media.matches !== matches) {\n\t\t\tsetMatches(media.matches)\n\t\t}\n\n\t\tconst listener = (event: MediaQueryListEvent) => {\n\t\t\tsetMatches(event.matches)\n\t\t}\n\n\t\tmedia.addEventListener('change', listener)\n\t\treturn () => media.removeEventListener('change', listener)\n\t}, [matches, query])\n\n\treturn matches\n}\n\nexport { useMediaQuery }\n"],"names":["useMediaQuery","query","matches","setMatches","useState","useEffect","media","listener","event"],"mappings":";AAEA,SAASA,EAAcC,GAAe;AACrC,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK;AAE5C,SAAAC,EAAU,MAAM;AACf,UAAMC,IAAQ,OAAO,WAAWL,CAAK;AACrC,IAAIK,EAAM,YAAYJ,KACrBC,EAAWG,EAAM,OAAO;AAGzB,UAAMC,IAAW,CAACC,MAA+B;AAChD,MAAAL,EAAWK,EAAM,OAAO;AAAA,IACzB;AAEA,WAAAF,EAAM,iBAAiB,UAAUC,CAAQ,GAClC,MAAMD,EAAM,oBAAoB,UAAUC,CAAQ;AAAA,EAC1D,GAAG,CAACL,GAASD,CAAK,CAAC,GAEZC;AACR;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","sources":["../../../src/patterns/copy-button/clipboard.ts"],"sourcesContent":["import type { MouseEvent } from 'react'\n\nconst getTextToCopy = (text: string | number | bigint) => {\n\tlet textToCopy: string\n\n\tif (text) {\n\t\tif (typeof text === 'string') {\n\t\t\ttextToCopy = text\n\t\t} else if (\n\t\t\t// context: https://github.com/hashicorp/design-system/pull/1564\n\t\t\ttypeof text === 'number' ||\n\t\t\ttypeof text === 'bigint'\n\t\t) {\n\t\t\ttextToCopy = text.toString()\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`hds-clipboard\\` modifier - \\`text\\` argument must be a string - provided: ${typeof text}`\n\t\t\t)\n\t\t}\n\t}\n\treturn textToCopy!\n}\n\nconst getTargetElement = (target: string | Element) => {\n\tlet targetElement: Element | null\n\tif (typeof target === 'string') {\n\t\ttargetElement = document.querySelector(target)\n\n\t\tif (!targetElement) {\n\t\t\tconsole.error(\n\t\t\t\t'`hds-clipboard` modifier - `target` selector provided does not point to an existing DOM node, check your selector string',\n\t\t\t\ttargetElement\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t} else if (target instanceof Node && target.nodeType === Node.ELEMENT_NODE) {\n\t\ttargetElement = target\n\t} else {\n\t\tif (target instanceof NodeList) {\n\t\t\tthrow new Error(\n\t\t\t\t'`hds-clipboard` modifier - `target` argument must be a string or a DOM node - provided: a list of DOM nodes'\n\t\t\t)\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`\\`hds-clipboard\\` modifier - \\`target\\` argument must be a string or a DOM node - provided: ${typeof target}`\n\t\t\t)\n\t\t}\n\t}\n\treturn targetElement\n}\n\nconst getTextToCopyFromTargetElement = (targetElement: Element | undefined) => {\n\tlet textToCopy: string | undefined\n\tif (\n\t\ttargetElement instanceof Node &&\n\t\ttargetElement.nodeType === Node.ELEMENT_NODE\n\t) {\n\t\tif (\n\t\t\ttargetElement instanceof HTMLInputElement || // targetElement.nodeName === 'INPUT' ||\n\t\t\ttargetElement instanceof HTMLTextAreaElement || // targetElement.nodeName === 'TEXTAREA' ||\n\t\t\ttargetElement instanceof HTMLSelectElement // targetElement.nodeName === 'SELECT'\n\t\t) {\n\t\t\ttextToCopy = targetElement.value\n\t\t} else {\n\t\t\t// simplest approach\n\t\t\ttextToCopy = (targetElement as HTMLElement).innerText\n\n\t\t\t// approach based on text selection (left for backup just in case)\n\t\t\t// var selection = window.getSelection();\n\t\t\t// var range = document.createRange();\n\t\t\t// selection.removeAllRanges();\n\t\t\t// range.selectNodeContents(targetElement);\n\t\t\t// selection.addRange(range);\n\t\t\t// textToCopy = selection.toString();\n\t\t\t// selection.removeAllRanges();\n\t\t}\n\t}\n\treturn textToCopy\n}\n\nconst writeTextToClipboard = async (textToCopy: string | undefined) => {\n\t// finally copy the text to the clipboard using the Clipboard API\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API\n\tif (textToCopy) {\n\t\ttry {\n\t\t\t// notice: the \"clipboard-write\" permission is granted automatically to pages when they are in the active tab\n\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write\n\t\t\tawait navigator.clipboard.writeText(textToCopy)\n\t\t\t// DEBUG uncomment this for easy debugging\n\t\t\t// console.log('success', textToCopy);\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\t// clipboard write failed\n\t\t\t// this probably never happens (see comment above) or happens only for very old browsers that don't for which `navigator.clipboard` is undefined\n\t\t\tconsole.warn(\n\t\t\t\t'copy action failed, please check your browser‘s permissions',\n\t\t\t\t{\n\t\t\t\t\tid: 'hds-clipboard.write-text-to-clipboard.catch-error',\n\t\t\t\t}\n\t\t\t)\n\t\t\treturn false\n\t\t}\n\t} else {\n\t\treturn false\n\t}\n}\n\nconst copyToClipboard = async (\n\ttext: string | number | bigint | undefined,\n\ttarget: string | Element | undefined,\n\tgetTextFn: (() => string) | undefined\n) => {\n\tlet textToCopy: string | undefined\n\n\tif (getTextFn) {\n\t\ttextToCopy = getTextFn()\n\t} else if (text) {\n\t\ttextToCopy = getTextToCopy(text)\n\t} else if (target) {\n\t\tconst targetElement = getTargetElement(target)\n\t\ttextToCopy = getTextToCopyFromTargetElement(targetElement)\n\t} else {\n\t\tthrow new Error(\n\t\t\t'`hds-clipboard` modifier - either a `getTextFn`, `text`, or a `target` argument is required'\n\t\t)\n\t}\n\tconst success = await writeTextToClipboard(textToCopy)\n\treturn success\n}\n\ntype HandlerArgs = {\n\ttrigger: Element\n\ttext: string | number | bigint | undefined\n\ttarget: string | Element | undefined\n}\n\nconst onClickHandler = (named: {\n\ttext: string | number | bigint | undefined\n\ttarget: string | Element | undefined\n\tgetTextFn: (() => string) | undefined\n\tonSuccess: (args: HandlerArgs) => void\n\tonError: (args: HandlerArgs) => void\n}) => {\n\tconst { text, target, getTextFn, onSuccess, onError } = named\n\n\tconst onClick = async (event: MouseEvent<HTMLButtonElement>) => {\n\t\tconst trigger = event.currentTarget\n\t\tconst success = await copyToClipboard(text, target, getTextFn)\n\n\t\t// fire the `onSuccess/onError` callbacks (if provided)\n\t\tif (success) {\n\t\t\tif (typeof onSuccess === 'function') {\n\t\t\t\tonSuccess({ trigger, text, target })\n\t\t\t}\n\t\t} else {\n\t\t\tif (typeof onError === 'function') {\n\t\t\t\tonError({ trigger, text, target })\n\t\t\t}\n\t\t}\n\t}\n\n\treturn { onClick }\n}\n\nexport { onClickHandler, type HandlerArgs }\n"],"names":["getTextToCopy","text","textToCopy","getTargetElement","target","targetElement","getTextToCopyFromTargetElement","writeTextToClipboard","copyToClipboard","getTextFn","onClickHandler","named","onSuccess","onError","event","trigger"],"mappings":"AAEA,MAAMA,IAAgB,CAACC,MAAmC;AACzD,MAAIC;AAEJ,MAAID;AACH,QAAI,OAAOA,KAAS;AACnB,MAAAC,IAAaD;AAAA;AAAA;AAAA,MAGb,OAAOA,KAAS,YAChB,OAAOA,KAAS;AAAA;AAEhB,MAAAC,IAAaD,EAAK,SAAA;AAAA;AAElB,YAAM,IAAI;AAAA,QACT,+EAA+E,OAAOA,CAAI;AAAA,MAAA;AAI7F,SAAOC;AACR,GAEMC,IAAmB,CAACC,MAA6B;AACtD,MAAIC;AACJ,MAAI,OAAOD,KAAW;AAGrB,QAFAC,IAAgB,SAAS,cAAcD,CAAM,GAEzC,CAACC,GAAe;AACnB,cAAQ;AAAA,QACP;AAAA,QACAA;AAAA,MAAA;AAED;AAAA,IACD;AAAA,aACUD,aAAkB,QAAQA,EAAO,aAAa,KAAK;AAC7D,IAAAC,IAAgBD;AAAA;AAEhB,UAAIA,aAAkB,WACf,IAAI;AAAA,MACT;AAAA,IAAA,IAGK,IAAI;AAAA,MACT,+FAA+F,OAAOA,CAAM;AAAA,IAAA;AAI/G,SAAOC;AACR,GAEMC,IAAiC,CAACD,MAAuC;AAC9E,MAAIH;AACJ,SACCG,aAAyB,QACzBA,EAAc,aAAa,KAAK,iBAG/BA,aAAyB;AAAA,EACzBA,aAAyB;AAAA,EACzBA,aAAyB,oBAEzBH,IAAaG,EAAc,QAG3BH,IAAcG,EAA8B,YAYvCH;AACR,GAEMK,IAAuB,OAAOL,MAAmC;AAGtE,MAAIA;AACH,QAAI;AAGH,mBAAM,UAAU,UAAU,UAAUA,CAAU,GAGvC;AAAA,IACR,QAAgB;AAGf,qBAAQ;AAAA,QACP;AAAA,QACA;AAAA,UACC,IAAI;AAAA,QAAA;AAAA,MACL,GAEM;AAAA,IACR;AAAA;AAEA,WAAO;AAET,GAEMM,IAAkB,OACvBP,GACAG,GACAK,MACI;AACJ,MAAIP;AAEJ,MAAIO;AACH,IAAAP,IAAaO,EAAA;AAAA,WACHR;AACV,IAAAC,IAAaF,EAAcC,CAAI;AAAA,WACrBG,GAAQ;AAClB,UAAMC,IAAgBF,EAAiBC,CAAM;AAC7C,IAAAF,IAAaI,EAA+BD,CAAa;AAAA,EAC1D;AACC,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAIF,SADgB,MAAME,EAAqBL,CAAU;AAEtD,GAQMQ,IAAiB,CAACC,MAMlB;AACL,QAAM,EAAE,MAAAV,GAAM,QAAAG,GAAQ,WAAAK,GAAW,WAAAG,GAAW,SAAAC,MAAYF;AAkBxD,SAAO,EAAE,SAhBO,OAAOG,MAAyC;AAC/D,UAAMC,IAAUD,EAAM;AAItB,IAHgB,MAAMN,EAAgBP,GAAMG,GAAQK,CAAS,IAIxD,OAAOG,KAAc,cACxBA,EAAU,EAAE,SAAAG,GAAS,MAAAd,GAAM,QAAAG,EAAA,CAAQ,IAGhC,OAAOS,KAAY,cACtBA,EAAQ,EAAE,SAAAE,GAAS,MAAAd,GAAM,QAAAG,EAAA,CAAQ;AAAA,EAGpC,EAES;AACV;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-screen-size.js","sources":["../../../src/utils/hooks/use-screen-size.ts"],"sourcesContent":["'use client'\n\nimport { useMediaQuery } from '@web/hooks/use-media-query'\n\n// ref: https://github.com/hashicorp/web/blob/main/packages/mds-tokens/src/custom-media.css\nconst useSmall = () => useMediaQuery('(max-width: 768px)')\nconst useMedium = () =>\n\tuseMediaQuery('(min-width: 768px) and (max-width: 1119px)')\nconst useMediumUp = () => useMediaQuery('(min-width: 768px)')\nconst useLarge = () => useMediaQuery('(min-width: 1120px)')\n\nexport { useSmall, useMedium, useMediumUp, useLarge }\n"],"names":["useSmall","useMediaQuery","useMedium","useMediumUp"],"mappings":";;AAMA,MAAMA,IAAA,MAAYC,EACjB,oBAAc,GACTC,IAAA,MAAcD,EAAM,4CAAkC,GACtDE,IAAW,MAAMF,EAAc,oBAAqB;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../utils/i18n/helpers/index.ts"],"sourcesContent":["import { SUPPORTED_LOCALES } from '../constants'\nimport type { SupportedLocale } from '../types'\n\nexport function isSupportedLocale(locale: string): locale is SupportedLocale {\n\treturn SUPPORTED_LOCALES.includes(locale as SupportedLocale)\n}\n"],"names":["isSupportedLocale","locale","SUPPORTED_LOCALES"],"mappings":";AAGO,SAASA,EAAkBC,GAA2C;AAC5E,SAAOC,EAAkB,SAASD,CAAyB;AAC5D;"}
|
|
File without changes
|