@hashicorp/mds-react 0.9.13 → 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 -6
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/accordion/item/index.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport { DisclosurePrimitive } from '../../disclosure-primitive'\nimport { useDisclosurePrimitive } from '../../disclosure-primitive/use-disclosure-primitive'\nimport type { HTMLAttributes } from 'react'\nimport { AccordionButton } from './button'\nimport s from '../style.module.scss'\nimport { Text } from '../../text'\n\ninterface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {\n\tariaLabel?: string\n\tisOpen?: boolean\n\tcontainsInteractive?: boolean\n}\n\nconst AccordionItem = ({\n\tchildren,\n\tcontainsInteractive,\n\tisOpen,\n\tariaLabel = 'Toggle display',\n\t...rest\n}: AccordionItemProps) => {\n\treturn (\n\t\t<DisclosurePrimitive.Provider\n\t\t\tclassName={classNames(s.item, {\n\t\t\t\t[s['contains-interactive']]: containsInteractive,\n\t\t\t\t[s['does-not-contain-interactive']]: !containsInteractive,\n\t\t\t})}\n\t\t\ttrackedIsOpen={isOpen}\n\t\t\tcontainsInteractive={containsInteractive}\n\t\t\tariaLabel={ariaLabel}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{children}\n\t\t</DisclosurePrimitive.Provider>\n\t)\n}\n\nAccordionItem.displayName = 'AccordionItem'\n\ninterface AccordionToggleProps {\n\tchildren: React.ReactNode\n\tanchorId?: string\n\tupdateUrl?: boolean\n}\nconst AccordionToggle = ({\n\tchildren,\n\tanchorId,\n\tupdateUrl,\n}: AccordionToggleProps) => {\n\treturn (\n\t\t<div className={s.toggle}>\n\t\t\t<AccordionButton anchorId={anchorId ?? ''} updateUrl={updateUrl} />\n\t\t\t<div className={classNames(s['toggle-content'])}>\n\t\t\t\t<Text.Body weight=\"semibold\">{children}</Text.Body>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nAccordionToggle.displayName = 'AccordionToggle'\n\nconst AccordionContent = ({ children }: React.PropsWithChildren) => {\n\tconst { contentId } = useDisclosurePrimitive()\n\n\treturn (\n\t\t<DisclosurePrimitive.Content>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts['content'],\n\t\t\t\t\t'mds-typography-legacy-body-200 mds-foreground-primary'
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/accordion/item/index.tsx"],"sourcesContent":["'use client'\n\nimport classNames from 'classnames'\nimport { DisclosurePrimitive } from '../../disclosure-primitive'\nimport { useDisclosurePrimitive } from '../../disclosure-primitive/use-disclosure-primitive'\nimport type { HTMLAttributes } from 'react'\nimport { AccordionButton } from './button'\nimport s from '../style.module.scss'\nimport { Text } from '../../text'\n\ninterface AccordionItemProps extends HTMLAttributes<HTMLDivElement> {\n\tariaLabel?: string\n\tisOpen?: boolean\n\tcontainsInteractive?: boolean\n}\n\nconst AccordionItem = ({\n\tchildren,\n\tcontainsInteractive,\n\tisOpen,\n\tariaLabel = 'Toggle display',\n\t...rest\n}: AccordionItemProps) => {\n\treturn (\n\t\t<DisclosurePrimitive.Provider\n\t\t\tclassName={classNames(s.item, {\n\t\t\t\t[s['contains-interactive']]: containsInteractive,\n\t\t\t\t[s['does-not-contain-interactive']]: !containsInteractive,\n\t\t\t})}\n\t\t\ttrackedIsOpen={isOpen}\n\t\t\tcontainsInteractive={containsInteractive}\n\t\t\tariaLabel={ariaLabel}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{children}\n\t\t</DisclosurePrimitive.Provider>\n\t)\n}\n\nAccordionItem.displayName = 'AccordionItem'\n\ninterface AccordionToggleProps {\n\tchildren: React.ReactNode\n\tanchorId?: string\n\tupdateUrl?: boolean\n}\nconst AccordionToggle = ({\n\tchildren,\n\tanchorId,\n\tupdateUrl,\n}: AccordionToggleProps) => {\n\treturn (\n\t\t<div className={s.toggle}>\n\t\t\t<AccordionButton anchorId={anchorId ?? ''} updateUrl={updateUrl} />\n\t\t\t<div className={classNames(s['toggle-content'])}>\n\t\t\t\t<Text.Body weight=\"semibold\">{children}</Text.Body>\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nAccordionToggle.displayName = 'AccordionToggle'\n\nconst AccordionContent = ({ children }: React.PropsWithChildren) => {\n\tconst { contentId } = useDisclosurePrimitive()\n\n\treturn (\n\t\t<DisclosurePrimitive.Content>\n\t\t\t<div\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts['content'],\n\t\t\t\t\t'mds-typography-legacy-body-200 mds-foreground-primary',\n\t\t\t\t)}\n\t\t\t\tid={contentId}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</DisclosurePrimitive.Content>\n\t)\n}\n\nAccordionContent.displayName = 'AccordionContent'\n\nexport { AccordionItem, AccordionToggle, AccordionContent }\n"],"names":["AccordionItem","children","containsInteractive","isOpen","ariaLabel","rest","jsx","DisclosurePrimitive","classNames","s","AccordionToggle","anchorId","updateUrl","jsxs","AccordionButton","Text","contentId","useDisclosurePrim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
|
|
67
67
|
&.parent-does-not-contain-interactive {
|
|
68
|
-
@include hds-focus-ring-with-pseudo-element
|
|
68
|
+
@include hds-focus-ring-with-pseudo-element;
|
|
69
69
|
position: static;
|
|
70
70
|
margin: -1px 0;
|
|
71
71
|
color: var(--mds-color-foreground-primary);
|
|
@@ -84,17 +84,17 @@ $item-border-radius: 6px;
|
|
|
84
84
|
|
|
85
85
|
// only chevron button area is interactive
|
|
86
86
|
&.parent-contains-interactive {
|
|
87
|
-
@include hds-button
|
|
87
|
+
@include hds-button;
|
|
88
88
|
width: 24px;
|
|
89
89
|
height: 24px;
|
|
90
90
|
|
|
91
91
|
&:focus,
|
|
92
92
|
&:global(.mock-focus) {
|
|
93
|
-
@include hds-button-state-focus
|
|
93
|
+
@include hds-button-state-focus;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// `hds-button-color-secondary` determines the focus color and needs to be placed after `hds-button-state-focus`
|
|
97
|
-
@include hds-button-color-secondary
|
|
97
|
+
@include hds-button-color-secondary;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.description {
|
|
41
|
-
|
|
41
|
+
overflow-wrap: break-word;
|
|
42
42
|
|
|
43
43
|
// we add very basic styling for elements that may be injected via the "description" string
|
|
44
44
|
|
|
@@ -145,9 +145,7 @@
|
|
|
145
145
|
|
|
146
146
|
&.type-inline {
|
|
147
147
|
background-color: var(--mds-color-surface-faint);
|
|
148
|
-
border-color: var(
|
|
149
|
-
--mds-color-border-strong
|
|
150
|
-
); // notice: in the "neutral" color the "inline" has a slightly darker border color compared to the others to increase contrast (eg. could be used on a light gray background)
|
|
148
|
+
border-color: var(--mds-color-border-strong); // notice: in the "neutral" color the "inline" has a slightly darker border color compared to the others to increase contrast (eg. could be used on a light gray background)
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
// different color by design
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/alert/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useId } from 'react'\nimport { DismissButton } from '../dismiss-button'\nimport { StandaloneLink, type StandaloneLinkProps } from '../standalone-link'\nimport { Icon } from './icon'\nimport type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react'\nimport type { ButtonProps } from '../button'\nimport { Button } from '../button'\nimport s from './alert.module.scss'\nimport type { FlightIconName } from '../flight-icon'\n\ntype AlertColor = 'neutral' | 'highlight' | 'success' | 'warning' | 'critical'\n\ninterface CommonAlertProps extends HTMLAttributes<HTMLDivElement> {\n\t/**\n\t * Sets the color scheme for `background`, `border`, `title`, and `description`, which cannot be overridden.\n\t * `color` results in a default icon, which can be overridden.\n\t * default: `neutral`\n\t */\n\tcolor?: AlertColor\n\t/**\n\t * The alert can be dismissed by the user. When a function is passed, the \"dismiss\" button is displayed.\n\t */\n\tonDismiss?: () => void\n\t/**\n\t * A string used for the title of the alert.\n\t * Alert must have either a title or a description, or both.\n\t */\n\ttitle?: string\n\t/**\n\t * A plain text string or basic html that is used for the description.\n\t * Alert must have either a title or a description, or both.\n\t */\n\tdescription?: ReactNode\n\t/**\n\t * Role for the alert.\n\t * `alertdialog` should be used when the alert includes interactive elements (<Alert.Actions>).\n\t * `alert` should be used for all other scenarios.\n\t */\n\trole: 'alert' | 'alertdialog'\n}\n\ntype AlertProps =\n\t| (CommonAlertProps & {\n\t\t\t/** compact alerts must specify an icon */\n\t\t\ttype: 'compact'\n\t\t\t/** an icon from the Flight Icon set or false to hide the default icon */\n\t\t\ticon?: FlightIconName\n\t })\n\t| (CommonAlertProps & {\n\t\t\t/** page & inline alerts get an optional icon override */\n\t\t\ttype: 'page' | 'inline'\n\t\t\t/** an icon from the Flight Icon set or false to hide the default icon */\n\t\t\ticon?: FlightIconName | false\n\t })\n\nconst Alert = ({\n\ttype,\n\tcolor = 'neutral',\n\ticon,\n\tonDismiss,\n\ttitle,\n\tdescription,\n\tchildren,\n\trole,\n\tclassName,\n\t...rest\n}: AlertProps) => {\n\tif (!title && !description) {\n\t\tthrow new Error(\n\t\t\t'Alert must include either a title or a description, or both'
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/alert/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useId } from 'react'\nimport { DismissButton } from '../dismiss-button'\nimport { StandaloneLink, type StandaloneLinkProps } from '../standalone-link'\nimport { Icon } from './icon'\nimport type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react'\nimport type { ButtonProps } from '../button'\nimport { Button } from '../button'\nimport s from './alert.module.scss'\nimport type { FlightIconName } from '../flight-icon'\n\ntype AlertColor = 'neutral' | 'highlight' | 'success' | 'warning' | 'critical'\n\ninterface CommonAlertProps extends HTMLAttributes<HTMLDivElement> {\n\t/**\n\t * Sets the color scheme for `background`, `border`, `title`, and `description`, which cannot be overridden.\n\t * `color` results in a default icon, which can be overridden.\n\t * default: `neutral`\n\t */\n\tcolor?: AlertColor\n\t/**\n\t * The alert can be dismissed by the user. When a function is passed, the \"dismiss\" button is displayed.\n\t */\n\tonDismiss?: () => void\n\t/**\n\t * A string used for the title of the alert.\n\t * Alert must have either a title or a description, or both.\n\t */\n\ttitle?: string\n\t/**\n\t * A plain text string or basic html that is used for the description.\n\t * Alert must have either a title or a description, or both.\n\t */\n\tdescription?: ReactNode\n\t/**\n\t * Role for the alert.\n\t * `alertdialog` should be used when the alert includes interactive elements (<Alert.Actions>).\n\t * `alert` should be used for all other scenarios.\n\t */\n\trole: 'alert' | 'alertdialog'\n}\n\ntype AlertProps =\n\t| (CommonAlertProps & {\n\t\t\t/** compact alerts must specify an icon */\n\t\t\ttype: 'compact'\n\t\t\t/** an icon from the Flight Icon set or false to hide the default icon */\n\t\t\ticon?: FlightIconName\n\t })\n\t| (CommonAlertProps & {\n\t\t\t/** page & inline alerts get an optional icon override */\n\t\t\ttype: 'page' | 'inline'\n\t\t\t/** an icon from the Flight Icon set or false to hide the default icon */\n\t\t\ticon?: FlightIconName | false\n\t })\n\nconst Alert = ({\n\ttype,\n\tcolor = 'neutral',\n\ticon,\n\tonDismiss,\n\ttitle,\n\tdescription,\n\tchildren,\n\trole,\n\tclassName,\n\t...rest\n}: AlertProps) => {\n\tif (!title && !description) {\n\t\tthrow new Error(\n\t\t\t'Alert must include either a title or a description, or both',\n\t\t)\n\t}\n\n\t// `alertdialog` must have an accessible name so we use either the\n\t// title or the description as label for the alert\n\tconst generatedLabelId = useId()\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts.alert,\n\t\t\t\ts[`type-${type}`],\n\t\t\t\ts[`color-${color}`],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\trole={role}\n\t\t\taria-live=\"polite\"\n\t\t\taria-labelledby={generatedLabelId}\n\t\t\t{...rest}\n\t\t>\n\t\t\t<Icon icon={icon} type={type} color={color} />\n\t\t\t<div className={s.content}>\n\t\t\t\t<div\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\ts.text,\n\t\t\t\t\t\ttype === 'compact'\n\t\t\t\t\t\t\t? 'mds-typography-legacy-body-100'\n\t\t\t\t\t\t\t: 'mds-typography-legacy-body-200',\n\t\t\t\t\t)}\n\t\t\t\t>\n\t\t\t\t\t{title && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\ts.title,\n\t\t\t\t\t\t\t\t'mds-typography-font-weight-semibold',\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tid={generatedLabelId}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{title}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t{description && (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t\t\ts.description,\n\t\t\t\t\t\t\t\t'mds-typography-font-weight-regular mds-foreground-primary',\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\tid={!title ? generatedLabelId : undefined}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{description}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</div>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t\t{onDismiss && (\n\t\t\t\t<div className={s['dismiss-button-wrapper']}>\n\t\t\t\t\t<DismissButton onClick={onDismiss} />\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\nAlert.displayName = 'Alert'\n\nconst AlertActions = ({ children }: PropsWithChildren) => {\n\treturn <div className={s.actions}>{children}</div>\n}\n\nAlertActions.displayName = 'AlertActions'\n\nconst AlertButton = ({ ...props }: Exclude<ButtonProps, 'size'>) => {\n\treturn <Button size=\"small\" {...props} />\n}\n\nAlertButton.displayName = 'AlertButton'\n\nconst AlertStandaloneLink = ({\n\t...props\n}: Exclude<StandaloneLinkProps, 'size'>) => {\n\treturn <StandaloneLink size=\"small\" {...props} />\n}\n\nAlertStandaloneLink.displayName = 'AlertStandaloneLink'\n\nexport { Alert, AlertActions, AlertButton, AlertStandaloneLink }\nexport type { AlertProps, AlertColor }\n"],"names":["Alert","type","color","icon","onDismiss","title","description","children","role","className","rest","generatedLabelId","useId","jsxs","classNames","s","jsx","Icon","DismissButton","AlertActions","AlertButton","props","Button","AlertStandaloneLink","StandaloneLink"],"mappings":";;;;;;;;AAwDA,MAAMA,IAAQ,CAAC;AAAA,EACd,MAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAAkB;AACjB,MAAI,CAACL,KAAS,CAACC;AACd,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAMF,QAAMK,IAAmBC,EAAA;AAEzB,SACC,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,WAAWC;AAAA,QACV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AU,UAAAR,GAAS;AAG7CY,EAAa,cAAc;AAE3B,MAAMC,IAAc,CAAC,EAAE,GAAGC,QAClB,gBAAAL,EAACM,GAAA,EAAO,MAAK,SAAS,GAAGD,GAAO;AAGxCD,EAAY,cAAc;AAE1B,MAAMG,IAAsB,CAAC;AAAA,EAC5B,GAAGF;AACJ,MACQ,gBAAAL,EAACQ,GAAA,EAAe,MAAK,SAAS,GAAGH,GAAO;AAGhDE,EAAoB,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/badge/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport type { FlightIconName, FlightIconSize } from '../flight-icon'\nimport { FlightIcon } from '../flight-icon'\nimport s from './style.module.scss'\n\nconst BADGE_SIZES = ['small', 'medium', 'large'] as const\ntype BadgeSize = (typeof BADGE_SIZES)[number]\n\nconst BADGE_TYPES = ['filled', 'inverted', 'outlined'] as const\ntype BadgeType = (typeof BADGE_TYPES)[number]\n\nconst BADGE_COLORS = [\n\t'neutral',\n\t'highlight',\n\t'success',\n\t'warning',\n\t'critical',\n] as const\ntype BadgeColor = (typeof BADGE_COLORS)[number]\n\nconst ICON_SIZE_MAP = {\n\tsmall: 12,\n\tmedium: 16,\n\tlarge: 16,\n} as const satisfies Record<'small' | 'medium' | 'large', FlightIconSize>\n\ninterface BaseBadgeProps {\n\tsize?: BadgeSize\n\ttype?: BadgeType\n\tcolor?: BadgeColor\n\tclassName?: string\n\ticonColor?: string\n}\n\ninterface BadgeWithTextProps extends BaseBadgeProps {\n\ttext: string\n\ticon?: FlightIconName\n\taccessibleText?: string\n}\n\ninterface IconOnlyBadgeProps extends BaseBadgeProps {\n\ttext?: undefined\n\ticon: FlightIconName\n\taccessibleText: string\n}\n\ntype BadgeProps = IconOnlyBadgeProps | BadgeWithTextProps\n\nconst Badge = ({\n\ticon,\n\ticonColor,\n\ttext,\n\tsize = 'medium',\n\ttype = 'filled',\n\tcolor = 'neutral',\n\tclassName,\n\taccessibleText,\n}: BadgeProps) => {\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts.badge,\n\t\t\t\ts[`size-${size}`],\n\t\t\t\ts[`type-${type}`],\n\t\t\t\ts[`color-${color}`],\n\t\t\t\tclassName
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/badge/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport type { FlightIconName, FlightIconSize } from '../flight-icon'\nimport { FlightIcon } from '../flight-icon'\nimport s from './style.module.scss'\n\nconst BADGE_SIZES = ['small', 'medium', 'large'] as const\ntype BadgeSize = (typeof BADGE_SIZES)[number]\n\nconst BADGE_TYPES = ['filled', 'inverted', 'outlined'] as const\ntype BadgeType = (typeof BADGE_TYPES)[number]\n\nconst BADGE_COLORS = [\n\t'neutral',\n\t'highlight',\n\t'success',\n\t'warning',\n\t'critical',\n] as const\ntype BadgeColor = (typeof BADGE_COLORS)[number]\n\nconst ICON_SIZE_MAP = {\n\tsmall: 12,\n\tmedium: 16,\n\tlarge: 16,\n} as const satisfies Record<'small' | 'medium' | 'large', FlightIconSize>\n\ninterface BaseBadgeProps {\n\tsize?: BadgeSize\n\ttype?: BadgeType\n\tcolor?: BadgeColor\n\tclassName?: string\n\ticonColor?: string\n}\n\ninterface BadgeWithTextProps extends BaseBadgeProps {\n\ttext: string\n\ticon?: FlightIconName\n\taccessibleText?: string\n}\n\ninterface IconOnlyBadgeProps extends BaseBadgeProps {\n\ttext?: undefined\n\ticon: FlightIconName\n\taccessibleText: string\n}\n\ntype BadgeProps = IconOnlyBadgeProps | BadgeWithTextProps\n\nconst Badge = ({\n\ticon,\n\ticonColor,\n\ttext,\n\tsize = 'medium',\n\ttype = 'filled',\n\tcolor = 'neutral',\n\tclassName,\n\taccessibleText,\n}: BadgeProps) => {\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts.badge,\n\t\t\t\ts[`size-${size}`],\n\t\t\t\ts[`type-${type}`],\n\t\t\t\ts[`color-${color}`],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{icon && (\n\t\t\t\t<FlightIcon name={icon} color={iconColor} size={ICON_SIZE_MAP[size]} />\n\t\t\t)}\n\t\t\t{text ? (\n\t\t\t\t<div className={s.text} aria-hidden={!!accessibleText}>\n\t\t\t\t\t{text}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t\t{accessibleText ? (\n\t\t\t\t<span className=\"sr-only\">{accessibleText}</span>\n\t\t\t) : null}\n\t\t</div>\n\t)\n}\n\nBadge.displayName = 'Badge'\n\nexport type { BadgeProps, BadgeColor, BadgeSize, BadgeType }\nexport { Badge, BADGE_COLORS, BADGE_SIZES, BADGE_TYPES }\n"],"names":["BADGE_SIZES","BADGE_TYPES","BADGE_COLORS","ICON_SIZE_MAP","Badge","icon","iconColor","text","size","type","color","className","accessibleText","jsxs","classNames","s","jsx","FlightIcon"],"mappings":";;;;AAKA,MAAMA,IAAc,CAAC,SAAS,UAAU,OAAO,GAGzCC,IAAc,CAAC,UAAU,YAAY,UAAU,GAG/CC,IAAe;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAGMC,IAAgB;AAAA,EACrB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACR,GAwBMC,IAAQ,CAAC;AAAA,EACd,MAAAC;AAAA,EACA,WAAAC;AAAA,EACA,MAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,gBAAAC;AACD,MAEE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACA,WAAWC;AAAA,MACVC,EAAE;AAAA,MACFA,EAAE,QAAQP,CAAI,EAAE;AAAA,MAChBO,EAAE,QAAQN,CAAI,EAAE;AAAA,MAChBM,EAAE,SAASL,CAAK,EAAE;AAAA,MAClBC;AAAA,IAAA;AAAA,IAGA,UAAA;AAAA,MAAAN,KACA,gBAAAW,EAACC,KAAW,MAAMZ,GAAM,OAAOC,GAAW,MAAMH,EAAcK,CAAI,EAAA,CAAG;AAAA,MAErED,IACA,gBAAAS,EAAC,OAAA,EAAI,WAAWD,EAAE,MAAM,eAAa,CAAC,CAACH,GACrC,UAAAL,EAAA,CACF,IACG;AAAA,MACHK,IACA,gBAAAI,EAAC,QAAA,EAAK,WAAU,WAAW,aAAe,IACvC;AAAA,IAAA;AAAA,EAAA;AAAA;AAKPZ,EAAM,cAAc;"}
|
|
@@ -58,12 +58,7 @@ $size-props: (
|
|
|
58
58
|
.size-#{$size} {
|
|
59
59
|
gap: map.get($size-props, $size, 'gap');
|
|
60
60
|
min-height: map.get($size-props, $size, 'height');
|
|
61
|
-
padding: calc(
|
|
62
|
-
#{map.get($size-props, $size, 'padding-vertical')} - #{$border-width}
|
|
63
|
-
)
|
|
64
|
-
calc(
|
|
65
|
-
#{map.get($size-props, $size, 'padding-horizontal')} - #{$border-width}
|
|
66
|
-
);
|
|
61
|
+
padding: calc(#{map.get($size-props, $size, 'padding-vertical')} - #{$border-width}) calc(#{map.get($size-props, $size, 'padding-horizontal')} - #{$border-width});
|
|
67
62
|
|
|
68
63
|
.text {
|
|
69
64
|
font-size: map.get($size-props, $size, 'font-size');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/badge-count/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport type { HTMLAttributes } from 'react'\nimport s from './style.module.scss'\n\ninterface BadgeCountProps extends HTMLAttributes<HTMLDivElement> {\n\tsize?: 'small' | 'medium' | 'large'\n\ttype?: 'filled' | 'inverted' | 'outlined'\n\t/**\n\t * Text value that renders in the Badge Count.\n\t */\n\ttext: string\n}\n\nconst BadgeCount = ({\n\ttext,\n\tsize = 'medium',\n\ttype = 'filled',\n\tcolor = 'neutral',\n\tclassName,\n\t...rest\n}: BadgeCountProps) => {\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts['badge-count'],\n\t\t\t\ts[`size-${size}`],\n\t\t\t\ts[`type-${type}`],\n\t\t\t\ts[`color-neutral`],\n\t\t\t\tclassName
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/badge-count/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport type { HTMLAttributes } from 'react'\nimport s from './style.module.scss'\n\ninterface BadgeCountProps extends HTMLAttributes<HTMLDivElement> {\n\tsize?: 'small' | 'medium' | 'large'\n\ttype?: 'filled' | 'inverted' | 'outlined'\n\t/**\n\t * Text value that renders in the Badge Count.\n\t */\n\ttext: string\n}\n\nconst BadgeCount = ({\n\ttext,\n\tsize = 'medium',\n\ttype = 'filled',\n\tcolor = 'neutral',\n\tclassName,\n\t...rest\n}: BadgeCountProps) => {\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts['badge-count'],\n\t\t\t\ts[`size-${size}`],\n\t\t\t\ts[`type-${type}`],\n\t\t\t\ts[`color-neutral`],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{text}\n\t\t</div>\n\t)\n}\n\nBadgeCount.displayName = 'BadgeCount'\n\nexport type { BadgeCountProps }\nexport { BadgeCount }\n"],"names":["BadgeCount","text","size","type","color","className","rest","jsx","classNames","s"],"mappings":";;;AAaA,MAAMA,IAAa,CAAC;AAAA,EACnB,MAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,WAAAC;AAAA,EACA,GAAGC;AACJ,MAEE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACA,WAAWC;AAAA,MACVC,EAAE,aAAa;AAAA,MACfA,EAAE,QAAQP,CAAI,EAAE;AAAA,MAChBO,EAAE,QAAQN,CAAI,EAAE;AAAA,MAChBM,EAAE,eAAe;AAAA,MACjBJ;AAAA,IAAA;AAAA,IAEA,GAAGC;AAAA,IAEH,UAAAL;AAAA,EAAA;AAAA;AAKJD,EAAW,cAAc;"}
|
|
@@ -58,12 +58,7 @@ $size-props: (
|
|
|
58
58
|
@each $size in $sizes {
|
|
59
59
|
.size-#{$size} {
|
|
60
60
|
min-height: map.get($size-props, $size, 'height');
|
|
61
|
-
padding: calc(
|
|
62
|
-
#{map.get($size-props, $size, 'padding-vertical')} - #{$border-width}
|
|
63
|
-
)
|
|
64
|
-
calc(
|
|
65
|
-
#{map.get($size-props, $size, 'padding-horizontal')} - #{$border-width}
|
|
66
|
-
);
|
|
61
|
+
padding: calc(#{map.get($size-props, $size, 'padding-vertical')} - #{$border-width}) calc(#{map.get($size-props, $size, 'padding-horizontal')} - #{$border-width});
|
|
67
62
|
font-size: map.get($size-props, $size, 'font-size');
|
|
68
63
|
line-height: map.get($size-props, $size, 'line-height');
|
|
69
64
|
border-radius: math.div(map.get($size-props, $size, 'height'), 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport * as MenuPrimitive from '../menu-primitive'\nimport { Item } from './item'\nimport { TruncationButton } from './truncation-button'\nimport type { BreadcrumbProps, BreadcrumbTruncationProps } from './types'\nimport s from './style.module.scss'\n\nconst Root = ({\n\titemsCanWrap = true,\n\tariaLabel = 'breadcrumbs',\n\tchildren,\n\tclassName,\n\t...rest\n}: BreadcrumbProps) => {\n\treturn (\n\t\t<nav\n\t\t\tclassName={classNames(\n\t\t\t\ts.breadcrumbs,\n\t\t\t\t{\n\t\t\t\t\t[s['items-can-wrap']]: itemsCanWrap,\n\t\t\t\t},\n\t\t\t\tclassName
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/breadcrumbs/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport * as MenuPrimitive from '../menu-primitive'\nimport { Item } from './item'\nimport { TruncationButton } from './truncation-button'\nimport type { BreadcrumbProps, BreadcrumbTruncationProps } from './types'\nimport s from './style.module.scss'\n\nconst Root = ({\n\titemsCanWrap = true,\n\tariaLabel = 'breadcrumbs',\n\tchildren,\n\tclassName,\n\t...rest\n}: BreadcrumbProps) => {\n\treturn (\n\t\t<nav\n\t\t\tclassName={classNames(\n\t\t\t\ts.breadcrumbs,\n\t\t\t\t{\n\t\t\t\t\t[s['items-can-wrap']]: itemsCanWrap,\n\t\t\t\t},\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\taria-label={ariaLabel}\n\t\t\t{...rest}\n\t\t>\n\t\t\t<ol className={s.list}>{children}</ol>\n\t\t</nav>\n\t)\n}\n\nconst Truncation = ({\n\tariaLabel,\n\tchildren,\n\t...rest\n}: BreadcrumbTruncationProps) => {\n\treturn (\n\t\t<li className={classNames(s.item, s.truncation)} {...rest}>\n\t\t\t<MenuPrimitive.Provider>\n\t\t\t\t<MenuPrimitive.Toggle>\n\t\t\t\t\t<TruncationButton />\n\t\t\t\t</MenuPrimitive.Toggle>\n\t\t\t\t<MenuPrimitive.Content>\n\t\t\t\t\t<div className={s['truncation-content']}>\n\t\t\t\t\t\t<ol className={s.sublist}>{children}</ol>\n\t\t\t\t\t</div>\n\t\t\t\t</MenuPrimitive.Content>\n\t\t\t</MenuPrimitive.Provider>\n\t\t</li>\n\t)\n}\n\nconst Breadcrumbs = { Root, Item, Truncation }\n\nexport { Breadcrumbs }\n"],"names":["Root","itemsCanWrap","ariaLabel","children","className","rest","jsx","classNames","s","Truncation","jsxs","MenuPrimitive.Provider","MenuPrimitive.Toggle","TruncationButton","MenuPrimitive.Content","Breadcrumbs","Item"],"mappings":";;;;;;AAOA,MAAMA,IAAO,CAAC;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,WAAAC,IAAY;AAAA,EACZ,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAEE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACA,WAAWC;AAAA,MACVC,EAAE;AAAA,MACF;AAAA,QACC,CAACA,EAAE,gBAAgB,CAAC,GAAGP;AAAA,MAAA;AAAA,MAExBG;AAAA,IAAA;AAAA,IAED,cAAYF;AAAA,IACX,GAAGG;AAAA,IAEJ,UAAA,gBAAAC,EAAC,MAAA,EAAG,WAAWE,EAAE,MAAO,UAAAL,EAAA,CAAS;AAAA,EAAA;AAAA,GAK9BM,IAAa,CAAC;AAAA,EACnB,WAAAP;AAAA,EACA,UAAAC;AAAA,EACA,GAAGE;AACJ,MAEE,gBAAAC,EAAC,MAAA,EAAG,WAAWC,EAAWC,EAAE,MAAMA,EAAE,UAAU,GAAI,GAAGH,GACpD,UAAA,gBAAAK,EAACC,GAAA,EACA,UAAA;AAAA,EAAA,gBAAAL,EAACM,GAAA,EACA,UAAA,gBAAAN,EAACO,KAAiB,GACnB;AAAA,oBACCC,GAAA,EACA,UAAA,gBAAAR,EAAC,SAAI,WAAWE,EAAE,oBAAoB,GACrC,4BAAC,MAAA,EAAG,WAAWA,EAAE,SAAU,UAAAL,GAAS,GACrC,EAAA,CACD;AAAA,EAAA,CACD,EAAA,CACD,GAIIY,IAAc,EAAE,MAAAf,GAAM,MAAAgB,GAAM,YAAAP,EAAA;"}
|
|
@@ -77,7 +77,7 @@ $item-visual-horizontal-padding: 4px;
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// we apply the focus directly to the element, without using a pseudo-element
|
|
80
|
-
@include hds-focus-ring-basic
|
|
80
|
+
@include hds-focus-ring-basic;
|
|
81
81
|
|
|
82
82
|
&:active {
|
|
83
83
|
& > .text {
|
|
@@ -154,7 +154,7 @@ $item-visual-horizontal-padding: 4px;
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// we apply the focus directly to the element, without using a pseudo-element
|
|
157
|
-
@include hds-focus-ring-basic
|
|
157
|
+
@include hds-focus-ring-basic;
|
|
158
158
|
|
|
159
159
|
&:focus {
|
|
160
160
|
background-color: transparent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button-primitive.js","sources":["../../../src/components/button/button-primitive.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport type { ButtonPrimitiveProps } from '.'\nimport { FlightIcon, type FlightIconSize } from '../flight-icon'\nimport { Interactive } from '../interactive'\nimport classNames from 'classnames'\nimport s from './styles.module.scss'\n\n// These are the only “real” colors our legacy button knows about\nconst LEGACY_COLORS = [\n\t'primary',\n\t'secondary',\n\t'tertiary',\n\t'critical',\n\t'custom',\n] as const\nexport type LegacyButtonColor = (typeof LEGACY_COLORS)[number]\n\nconst ICON_SIZE_MAP = {\n\tsmall: 12,\n\tmedium: 16,\n\tlarge: 24,\n} as const satisfies Record<'small' | 'medium' | 'large', FlightIconSize>\n\nexport const ButtonPrimitive = forwardRef<\n\tHTMLButtonElement,\n\tButtonPrimitiveProps\n>(\n\t(\n\t\t{\n\t\t\tsize = 'medium',\n\t\t\tcolor = 'primary',\n\t\t\tisFullWidth,\n\t\t\tisIconOnly,\n\t\t\ticon,\n\t\t\ticonPosition = 'leading',\n\t\t\ttext,\n\t\t\thref,\n\t\t\tisHrefExternal,\n\t\t\tclassName,\n\t\t\tlocale,\n\t\t\t...rest\n\t\t},\n\t\tref
|
|
1
|
+
{"version":3,"file":"button-primitive.js","sources":["../../../src/components/button/button-primitive.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport type { ButtonPrimitiveProps } from '.'\nimport { FlightIcon, type FlightIconSize } from '../flight-icon'\nimport { Interactive } from '../interactive'\nimport classNames from 'classnames'\nimport s from './styles.module.scss'\n\n// These are the only “real” colors our legacy button knows about\nconst LEGACY_COLORS = [\n\t'primary',\n\t'secondary',\n\t'tertiary',\n\t'critical',\n\t'custom',\n] as const\nexport type LegacyButtonColor = (typeof LEGACY_COLORS)[number]\n\nconst ICON_SIZE_MAP = {\n\tsmall: 12,\n\tmedium: 16,\n\tlarge: 24,\n} as const satisfies Record<'small' | 'medium' | 'large', FlightIconSize>\n\nexport const ButtonPrimitive = forwardRef<\n\tHTMLButtonElement,\n\tButtonPrimitiveProps\n>(\n\t(\n\t\t{\n\t\t\tsize = 'medium',\n\t\t\tcolor = 'primary',\n\t\t\tisFullWidth,\n\t\t\tisIconOnly,\n\t\t\ticon,\n\t\t\ticonPosition = 'leading',\n\t\t\ttext,\n\t\t\thref,\n\t\t\tisHrefExternal,\n\t\t\tclassName,\n\t\t\tlocale,\n\t\t\t...rest\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst hasIcon = Boolean(icon)\n\t\tconst showIconOnly = isIconOnly && hasIcon\n\n\t\tconst iconElement = icon && (\n\t\t\t<FlightIcon name={icon} size={ICON_SIZE_MAP[size]} />\n\t\t)\n\n\t\treturn (\n\t\t\t<Interactive\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts.button,\n\t\t\t\t\ts[`size-${size}`],\n\t\t\t\t\t{\n\t\t\t\t\t\t[s['width-full']]: isFullWidth,\n\t\t\t\t\t\t[s['icon-only']]: showIconOnly,\n\t\t\t\t\t},\n\t\t\t\t\tcolor !== 'custom' && s[`color-${color}`],\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\thref={rest.disabled ? '' : href}\n\t\t\t\tisHrefExternal={isHrefExternal}\n\t\t\t\taria-label={showIconOnly ? text : undefined}\n\t\t\t\tlocale={locale}\n\t\t\t\t{...rest}\n\t\t\t\tref={ref}\n\t\t\t>\n\t\t\t\t{showIconOnly && icon ? (\n\t\t\t\t\ticonElement\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{icon && iconPosition === 'leading' && iconElement}\n\t\t\t\t\t\t{text ? <div className={s.text}>{text}</div> : null}\n\t\t\t\t\t\t{icon && iconPosition === 'trailing' && iconElement}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</Interactive>\n\t\t)\n\t},\n)\nButtonPrimitive.displayName = 'ButtonPrimitive'\n"],"names":["ICON_SIZE_MAP","ButtonPrimitive","forwardRef","size","color","isFullWidth","isIconOnly","icon","iconPosition","text","href","isHrefExternal","className","locale","rest","ref","showIconOnly","iconElement","jsx","FlightIcon","Interactive","classNames","s","jsxs","Fragment"],"mappings":";;;;;;AAiBA,MAAMA,IAAgB;AAAA,EACrB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACR,GAEaC,IAAkBC;AAAA,EAI9B,CACC;AAAA,IACC,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,MAAAC;AAAA,IACA,MAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEJC,MACI;AAEJ,UAAMC,IAAeV,KADL,EAAQC,GAGlBU,IAAcV,KACnB,gBAAAW,EAACC,GAAA,EAAW,MAAMZ,GAAM,MAAMP,EAAcG,CAAI,EAAA,CAAG;AAGpD,WACC,gBAAAe;AAAA,MAACE;AAAA,MAAA;AAAA,QACA,WAAWC;AAAA,UACVC,EAAE;AAAA,UACFA,EAAE,QAAQnB,CAAI,EAAE;AAAA,UAChB;AAAA,YACC,CAACmB,EAAE,YAAY,CAAC,GAAGjB;AAAA,YACnB,CAACiB,EAAE,WAAW,CAAC,GAAGN;AAAA,UAAA;AAAA,UAEnBZ,MAAU,YAAYkB,EAAE,SAASlB,CAAK,EAAE;AAAA,UACxCQ;AAAA,QAAA;AAAA,QAED,MAAME,EAAK,WAAW,KAAKJ;AAAA,QAC3B,gBAAAC;AAAA,QACA,cAAYK,IAAeP,IAAO;AAAA,QAClC,QAAAI;AAAA,QACC,GAAGC;AAAA,QACJ,KAAAC;AAAA,QAEC,UAAAC,KAAgBT,IAChBU,IAEA,gBAAAM,EAAAC,GAAA,EACE,UAAA;AAAA,UAAAjB,KAAQC,MAAiB,aAAaS;AAAA,UACtCR,IAAO,gBAAAS,EAAC,OAAA,EAAI,WAAWI,EAAE,MAAO,aAAK,IAAS;AAAA,UAC9Cf,KAAQC,MAAiB,cAAcS;AAAA,QAAA,EAAA,CACzC;AAAA,MAAA;AAAA,IAAA;AAAA,EAIJ;AACD;AACAhB,EAAgB,cAAc;"}
|
|
@@ -5,7 +5,7 @@ $button-focus-border-width: 3px;
|
|
|
5
5
|
$button-border-radius: 5px;
|
|
6
6
|
|
|
7
7
|
.button {
|
|
8
|
-
@include hds-button
|
|
8
|
+
@include hds-button;
|
|
9
9
|
|
|
10
10
|
// the <a> element behaves differently than a <button>
|
|
11
11
|
@at-root a#{&} {
|
|
@@ -31,7 +31,7 @@ $button-border-radius: 5px;
|
|
|
31
31
|
&[disabled]:focus,
|
|
32
32
|
&:disabled:hover,
|
|
33
33
|
&[disabled]:hover {
|
|
34
|
-
@include hds-button-state-disabled
|
|
34
|
+
@include hds-button-state-disabled;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
&.width-full {
|
|
@@ -44,7 +44,7 @@ $button-border-radius: 5px;
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
&:focus {
|
|
47
|
-
@include hds-button-state-focus
|
|
47
|
+
@include hds-button-state-focus;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -53,28 +53,25 @@ $button-border-radius: 5px;
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.color-primary {
|
|
56
|
-
@include hds-button-color-primary
|
|
56
|
+
@include hds-button-color-primary;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.color-secondary {
|
|
60
|
-
@include hds-button-color-secondary
|
|
60
|
+
@include hds-button-color-secondary;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
.color-tertiary {
|
|
64
|
-
@include hds-button-color-tertiary
|
|
64
|
+
@include hds-button-color-tertiary;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
.color-critical {
|
|
68
|
-
@include hds-button-color-critical
|
|
68
|
+
@include hds-button-color-critical;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
@mixin mds-button-color-product($product) {
|
|
72
72
|
color: var(--mds-color-#{$product}-button-foreground);
|
|
73
73
|
background-color: var(--mds-color-#{$product}-button-background);
|
|
74
|
-
border-color: var(
|
|
75
|
-
--mds-color-#{$product}-button-border,
|
|
76
|
-
var(--mds-color-border-primary)
|
|
77
|
-
);
|
|
74
|
+
border-color: var(--mds-color-#{$product}-button-border, var(--mds-color-border-primary));
|
|
78
75
|
box-shadow: var(--mds-elevation-low-box-shadow);
|
|
79
76
|
|
|
80
77
|
&:hover {
|
|
@@ -97,8 +94,7 @@ $button-border-radius: 5px;
|
|
|
97
94
|
bottom: -$shift;
|
|
98
95
|
left: -$shift;
|
|
99
96
|
border-color: var(--mds-color-focus-action-external);
|
|
100
|
-
border-radius: $button-border-radius + $button-focus-border-width +
|
|
101
|
-
2px;
|
|
97
|
+
border-radius: $button-border-radius + $button-focus-border-width + 2px;
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, type PropsWithChildren } from 'react'\nimport type { CardContentProps, CardProps, CardCtaProps } from './types'\nimport { CardThumbnail } from './card-thumbnail'\nimport { useMDSLink } from '../../utils/mds-context'\nimport { Text } from '../text'\nimport classNames from 'classnames'\nimport { Badge } from '../badge'\nimport { StandaloneLink } from '../standalone-link'\nimport { FlightIcon } from '../flight-icon'\nimport s from './styles.module.css'\n\nconst Card = forwardRef<HTMLDivElement, CardProps>(\n\t(\n\t\t{\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tcontent,\n\t\t\tctaLabel,\n\t\t\thref,\n\t\t\tstandaloneLink,\n\t\t\tisExternal,\n\t\t\tonClickCapture,\n\t\t\t'aria-label': ariaLabel,\n\t\t},\n\t\tref\n\t) => {\n\t\tconst Link = useMDSLink()\n\n\t\tconst isCardLink = href && !ctaLabel\n\n\t\tconst linkProps = isExternal\n\t\t\t? { target: '_blank', rel: 'noopener noreferrer' }\n\t\t\t: {}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts.card,\n\t\t\t\t\t{ [s.interactive]: isCardLink },\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{isCardLink && (\n\t\t\t\t\t<Link\n\t\t\t\t\t\thref={href}\n\t\t\t\t\t\tclassName={s.link}\n\t\t\t\t\t\tdraggable=\"false\"\n\t\t\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\t{...linkProps}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{content && (\n\t\t\t\t\t<CardContent\n\t\t\t\t\t\tbadges={content.badges}\n\t\t\t\t\t\tdescription={content.description}\n\t\t\t\t\t\teyebrow={content.eyebrow}\n\t\t\t\t\t\theading={content.heading}\n\t\t\t\t\t\tsubheading={content.subheading}\n\t\t\t\t\t\tthumbnail={content.thumbnail}\n\t\t\t\t\t\tshowArrow={content.showArrow && !!isCardLink}\n\t\t\t\t\t\tcta={{\n\t\t\t\t\t\t\tctaLabel,\n\t\t\t\t\t\t\thref,\n\t\t\t\t\t\t\tstandaloneLink,\n\t\t\t\t\t\t\tonClickCapture,\n\t\t\t\t\t\t\tisExternal,\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t\t{children && (\n\t\t\t\t\t<CardCta\n\t\t\t\t\t\tctaLabel={ctaLabel}\n\t\t\t\t\t\thref={href}\n\t\t\t\t\t\tstandaloneLink={standaloneLink}\n\t\t\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\t\t\tisExternal={isExternal}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t)\n\t}\n)\n\nCard.displayName = 'Card'\n\nexport const CardContent = ({\n\tbadges,\n\tdescription,\n\teyebrow,\n\theading,\n\tthumbnail,\n\tsubheading,\n\tcta,\n\tchildren,\n\tshowArrow,\n}: CardContentProps) => {\n\treturn (\n\t\t<div className={classNames(s.content, { [s['has-thumbnail']]: thumbnail })}>\n\t\t\t{thumbnail && <CardThumbnail {...thumbnail} />}\n\t\t\t<div className={s.contentLockup}>\n\t\t\t\t<CardEyebrow>{eyebrow}</CardEyebrow>\n\t\t\t\t<CardHeading>{heading}</CardHeading>\n\t\t\t\t<CardSubheading>{subheading}</CardSubheading>\n\t\t\t\t<CardDescription>{description}</CardDescription>\n\t\t\t\t<Badges badges={badges} />\n\t\t\t\t{cta && (\n\t\t\t\t\t<CardCta\n\t\t\t\t\t\tctaLabel={cta.ctaLabel}\n\t\t\t\t\t\thref={cta.href}\n\t\t\t\t\t\tstandaloneLink={cta.standaloneLink}\n\t\t\t\t\t\tisExternal={cta.isExternal}\n\t\t\t\t\t\tonClickCapture={cta.onClickCapture}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{showArrow ? (\n\t\t\t\t\t<div className={s.arrow}>\n\t\t\t\t\t\t<FlightIcon name=\"arrow-right\" />\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nconst CardCta = ({\n\thref,\n\tctaLabel,\n\tstandaloneLink,\n\tisExternal,\n\tonClickCapture,\n}: CardCtaProps) => {\n\tconst isCardLink = href && !ctaLabel\n\n\tif (standaloneLink) {\n\t\tconst standaloneLinkProps = {\n\t\t\t...standaloneLink,\n\t\t\ticon: standaloneLink.icon || 'chevron-right',\n\t\t\ticonPosition: standaloneLink.iconPosition || 'trailing',\n\t\t}\n\n\t\treturn <StandaloneLink className={s.cta} {...standaloneLinkProps} />\n\t}\n\n\tif (href && !isCardLink && ctaLabel) {\n\t\treturn (\n\t\t\t<StandaloneLink\n\t\t\t\tclassName={s.cta}\n\t\t\t\ttext={ctaLabel}\n\t\t\t\thref={href}\n\t\t\t\ticon=\"chevron-right\"\n\t\t\t\ticonPosition=\"trailing\"\n\t\t\t\tcolor=\"secondary\"\n\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\tisHrefExternal={isExternal}\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn null\n}\n\nconst CardEyebrow = ({ children }: PropsWithChildren) => {\n\tif (!children) {\n\t\treturn null\n\t}\n\n\tif (Array.isArray(children)) {\n\t\treturn <CardEyebrowList items={Array.from(children)} />\n\t}\n\n\treturn <CardEyebrowText>{children}</CardEyebrowText>\n}\n\nconst CardEyebrowList = ({ items }: { items: string[] }) => (\n\t<ul className={s.meta}>\n\t\t{items.map((item, idx) => (\n\t\t\t<li key={item}>\n\t\t\t\t<CardEyebrowText>{item}</CardEyebrowText>\n\t\t\t\t{idx < items.length - 1 ? (\n\t\t\t\t\t<span className={s.metaSeparator} aria-hidden={true}>\n\t\t\t\t\t\t|\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</li>\n\t\t))}\n\t</ul>\n)\n\nconst CardEyebrowText = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.Label color=\"faint\" weight=\"medium\">\n\t\t\t{children}\n\t\t</Text.Label>\n\t) : null\n\nconst CardHeading = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.DisplayExpressive\n\t\t\ttag=\"span\"\n\t\t\tsize=\"200\"\n\t\t\tweight=\"semibold\"\n\t\t\tcolor=\"strong\"\n\t\t>\n\t\t\t{children}\n\t\t</Text.DisplayExpressive>\n\t) : null\n\nconst CardSubheading = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.Body tag=\"span\" size=\"200\" className={s.subheading} color=\"primary\">\n\t\t\t{children}\n\t\t</Text.Body>\n\t) : null\n\nconst CardDescription = ({ children }: PropsWithChildren) => {\n\tif (!children) {\n\t\treturn null\n\t}\n\n\tif (typeof children === 'string') {\n\t\treturn (\n\t\t\t<Text.Body tag=\"span\" size=\"200\" color=\"primary\">\n\t\t\t\t{children}\n\t\t\t</Text.Body>\n\t\t)\n\t}\n\n\treturn <>{children}</>\n}\n\nconst Badges = ({ badges }: { badges: CardContentProps['badges'] }) =>\n\tbadges && badges.length > 0 ? (\n\t\t<div className={s.badges}>\n\t\t\t{badges.map((badge) => (\n\t\t\t\t<Badge key={badge.text} {...badge} />\n\t\t\t))}\n\t\t</div>\n\t) : null\n\nCard.displayName = 'Card'\nexport { Card }\n"],"names":["Card","forwardRef","children","className","content","ctaLabel","href","standaloneLink","isExternal","onClickCapture","ariaLabel","ref","Link","useMDSLink","isCardLink","jsxs","classNames","s","jsx","linkProps","CardContent","CardCta","badges","description","eyebrow","heading","thumbnail","subheading","cta","showArrow","CardThumbnail","CardEyebrow","CardHeading","CardSubheading","CardDescription","FlightIcon","standaloneLinkProps","StandaloneLink","CardEyebrowList","CardEyebrowText","items","item","idx","Text","Fragment","Badges","badge","Badge"],"mappings":";;;;;;;;;;;AAaa,MAEXA,IAAAC;AAAA,EAAA,CAAA;AAAA,IAEC,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,gBAAAC;AAAA,kBAGGC;AAAA,EACJ,GAAAC,MAAM;AAEN,UAAMC,IAAAC,KAEAC,IAAYR,KAAA,YAKjB,EAAA,QAAA,UAAA,KAAA,sBAAA,IAAA,CAAA;AAAA,WAAC,gBAAAS;AAAA,MAAA;AAAA,MAAA;AAAA,QAEA,KAAAJ;AAAA,QAAW,WACRK;AAAA,UACFC,EAAE;AAAA,UACF,EAAA,CAAAA,EAAA,WAAA,GAAAH,EAAA;AAAA,UACDX;AAAA,QAEC;AAAA,QAAA,UAAA;AAAA,UACAW,KAAC,gBAAAI;AAAA,YAAAN;AAAA,YAAA;AAAA,cAEA,MAAAN;AAAA,cACA,WAAUW,EAAA;AAAA,cACV,WAAA;AAAA,cACA,gBA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,CAAA,EAAA,QAAAvB,EAAc,MAAAA,KAAAA,EAAA,SAAA,IAAA,gBAAAJ,EAAA,OAAA,EAAA,WAAAD,EAAA,QAAA,UAAAK,EAAA,IAAA,CAAAwB,MAAA,gBAAA5B,EAAA6B,GAAA,EAAA,GAAAD,EAAA,GAAAA,EAAA,IAAA,CAAA,EAAA,CAAA,IAAA;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/card/index.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, type PropsWithChildren } from 'react'\nimport type { CardContentProps, CardProps, CardCtaProps } from './types'\nimport { CardThumbnail } from './card-thumbnail'\nimport { useMDSLink } from '../../utils/mds-context'\nimport { Text } from '../text'\nimport classNames from 'classnames'\nimport { Badge } from '../badge'\nimport { StandaloneLink } from '../standalone-link'\nimport { FlightIcon } from '../flight-icon'\nimport s from './styles.module.css'\n\nconst Card = forwardRef<HTMLDivElement, CardProps>(\n\t(\n\t\t{\n\t\t\tchildren,\n\t\t\tclassName,\n\t\t\tcontent,\n\t\t\tctaLabel,\n\t\t\thref,\n\t\t\tstandaloneLink,\n\t\t\tisExternal,\n\t\t\tonClickCapture,\n\t\t\t'aria-label': ariaLabel,\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst Link = useMDSLink()\n\n\t\tconst isCardLink = href && !ctaLabel\n\n\t\tconst linkProps = isExternal\n\t\t\t? { target: '_blank', rel: 'noopener noreferrer' }\n\t\t\t: {}\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\ts.card,\n\t\t\t\t\t{ [s.interactive]: isCardLink },\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t>\n\t\t\t\t{isCardLink && (\n\t\t\t\t\t<Link\n\t\t\t\t\t\thref={href}\n\t\t\t\t\t\tclassName={s.link}\n\t\t\t\t\t\tdraggable=\"false\"\n\t\t\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\t{...linkProps}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{content && (\n\t\t\t\t\t<CardContent\n\t\t\t\t\t\tbadges={content.badges}\n\t\t\t\t\t\tdescription={content.description}\n\t\t\t\t\t\teyebrow={content.eyebrow}\n\t\t\t\t\t\theading={content.heading}\n\t\t\t\t\t\tsubheading={content.subheading}\n\t\t\t\t\t\tthumbnail={content.thumbnail}\n\t\t\t\t\t\tshowArrow={content.showArrow && !!isCardLink}\n\t\t\t\t\t\tcta={{\n\t\t\t\t\t\t\tctaLabel,\n\t\t\t\t\t\t\thref,\n\t\t\t\t\t\t\tstandaloneLink,\n\t\t\t\t\t\t\tonClickCapture,\n\t\t\t\t\t\t\tisExternal,\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{children}\n\t\t\t\t{children && (\n\t\t\t\t\t<CardCta\n\t\t\t\t\t\tctaLabel={ctaLabel}\n\t\t\t\t\t\thref={href}\n\t\t\t\t\t\tstandaloneLink={standaloneLink}\n\t\t\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\t\t\tisExternal={isExternal}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t)\n\t},\n)\n\nCard.displayName = 'Card'\n\nexport const CardContent = ({\n\tbadges,\n\tdescription,\n\teyebrow,\n\theading,\n\tthumbnail,\n\tsubheading,\n\tcta,\n\tchildren,\n\tshowArrow,\n}: CardContentProps) => {\n\treturn (\n\t\t<div className={classNames(s.content, { [s['has-thumbnail']]: thumbnail })}>\n\t\t\t{thumbnail && <CardThumbnail {...thumbnail} />}\n\t\t\t<div className={s.contentLockup}>\n\t\t\t\t<CardEyebrow>{eyebrow}</CardEyebrow>\n\t\t\t\t<CardHeading>{heading}</CardHeading>\n\t\t\t\t<CardSubheading>{subheading}</CardSubheading>\n\t\t\t\t<CardDescription>{description}</CardDescription>\n\t\t\t\t<Badges badges={badges} />\n\t\t\t\t{cta && (\n\t\t\t\t\t<CardCta\n\t\t\t\t\t\tctaLabel={cta.ctaLabel}\n\t\t\t\t\t\thref={cta.href}\n\t\t\t\t\t\tstandaloneLink={cta.standaloneLink}\n\t\t\t\t\t\tisExternal={cta.isExternal}\n\t\t\t\t\t\tonClickCapture={cta.onClickCapture}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{showArrow ? (\n\t\t\t\t\t<div className={s.arrow}>\n\t\t\t\t\t\t<FlightIcon name=\"arrow-right\" />\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nconst CardCta = ({\n\thref,\n\tctaLabel,\n\tstandaloneLink,\n\tisExternal,\n\tonClickCapture,\n}: CardCtaProps) => {\n\tconst isCardLink = href && !ctaLabel\n\n\tif (standaloneLink) {\n\t\tconst standaloneLinkProps = {\n\t\t\t...standaloneLink,\n\t\t\ticon: standaloneLink.icon || 'chevron-right',\n\t\t\ticonPosition: standaloneLink.iconPosition || 'trailing',\n\t\t}\n\n\t\treturn <StandaloneLink className={s.cta} {...standaloneLinkProps} />\n\t}\n\n\tif (href && !isCardLink && ctaLabel) {\n\t\treturn (\n\t\t\t<StandaloneLink\n\t\t\t\tclassName={s.cta}\n\t\t\t\ttext={ctaLabel}\n\t\t\t\thref={href}\n\t\t\t\ticon=\"chevron-right\"\n\t\t\t\ticonPosition=\"trailing\"\n\t\t\t\tcolor=\"secondary\"\n\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\tisHrefExternal={isExternal}\n\t\t\t/>\n\t\t)\n\t}\n\n\treturn null\n}\n\nconst CardEyebrow = ({ children }: PropsWithChildren) => {\n\tif (!children) {\n\t\treturn null\n\t}\n\n\tif (Array.isArray(children)) {\n\t\treturn <CardEyebrowList items={Array.from(children)} />\n\t}\n\n\treturn <CardEyebrowText>{children}</CardEyebrowText>\n}\n\nconst CardEyebrowList = ({ items }: { items: string[] }) => (\n\t<ul className={s.meta}>\n\t\t{items.map((item, idx) => (\n\t\t\t<li key={item}>\n\t\t\t\t<CardEyebrowText>{item}</CardEyebrowText>\n\t\t\t\t{idx < items.length - 1 ? (\n\t\t\t\t\t<span className={s.metaSeparator} aria-hidden={true}>\n\t\t\t\t\t\t|\n\t\t\t\t\t</span>\n\t\t\t\t) : null}\n\t\t\t</li>\n\t\t))}\n\t</ul>\n)\n\nconst CardEyebrowText = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.Label color=\"faint\" weight=\"medium\">\n\t\t\t{children}\n\t\t</Text.Label>\n\t) : null\n\nconst CardHeading = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.DisplayExpressive\n\t\t\ttag=\"span\"\n\t\t\tsize=\"200\"\n\t\t\tweight=\"semibold\"\n\t\t\tcolor=\"strong\"\n\t\t>\n\t\t\t{children}\n\t\t</Text.DisplayExpressive>\n\t) : null\n\nconst CardSubheading = ({ children }: PropsWithChildren) =>\n\tchildren ? (\n\t\t<Text.Body tag=\"span\" size=\"200\" className={s.subheading} color=\"primary\">\n\t\t\t{children}\n\t\t</Text.Body>\n\t) : null\n\nconst CardDescription = ({ children }: PropsWithChildren) => {\n\tif (!children) {\n\t\treturn null\n\t}\n\n\tif (typeof children === 'string') {\n\t\treturn (\n\t\t\t<Text.Body tag=\"span\" size=\"200\" color=\"primary\">\n\t\t\t\t{children}\n\t\t\t</Text.Body>\n\t\t)\n\t}\n\n\treturn <>{children}</>\n}\n\nconst Badges = ({ badges }: { badges: CardContentProps['badges'] }) =>\n\tbadges && badges.length > 0 ? (\n\t\t<div className={s.badges}>\n\t\t\t{badges.map((badge) => (\n\t\t\t\t<Badge key={badge.text} {...badge} />\n\t\t\t))}\n\t\t</div>\n\t) : null\n\nCard.displayName = 'Card'\nexport { Card }\n"],"names":["Card","forwardRef","children","className","content","ctaLabel","href","standaloneLink","isExternal","onClickCapture","ariaLabel","ref","Link","useMDSLink","isCardLink","jsxs","classNames","s","jsx","linkProps","CardContent","CardCta","badges","description","eyebrow","heading","thumbnail","subheading","cta","showArrow","CardThumbnail","CardEyebrow","CardHeading","CardSubheading","CardDescription","FlightIcon","standaloneLinkProps","StandaloneLink","CardEyebrowList","CardEyebrowText","items","item","idx","Text","Fragment","Badges","badge","Badge"],"mappings":";;;;;;;;;;;AAaa,MAEXA,IAAAC;AAAA,EAAA,CAAA;AAAA,IAEC,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,gBAAAC;AAAA,kBAGGC;AAAA,EACJ,GAAAC,MAAM;AAEN,UAAMC,IAAAC,KAEAC,IAAYR,KAAA,YAKjB,EAAA,QAAA,UAAA,KAAA,sBAAA,IAAA,CAAA;AAAA,WAAC,gBAAAS;AAAA,MAAA;AAAA,MAAA;AAAA,QAEA,KAAAJ;AAAA,QAAW,WACRK;AAAA,UACFC,EAAE;AAAA,UACF,EAAA,CAAAA,EAAA,WAAA,GAAAH,EAAA;AAAA,UACDX;AAAA,QAEC;AAAA,QAAA,UAAA;AAAA,UACAW,KAAC,gBAAAI;AAAA,YAAAN;AAAA,YAAA;AAAA,cAEA,MAAAN;AAAA,cACA,WAAUW,EAAA;AAAA,cACV,WAAA;AAAA,cACA,gBAAAR;AAAA,cACC,cAAGC;AAAA,cAAA,GAAAS;AAAA,YACL;AAAA,UAEA;AAAA,UACAf,KAAC,gBAAAc;AAAA,YAAAE;AAAA,YAAA;AAAA,cAEA,QAAAhB,EAAa;AAAA,cACb,aAASA,EAAQ;AAAA,cACjB,SAASA,EAAQ;AAAA,cACjB,SAAAA,EAAY;AAAA,cACZ,YAAWA,EAAQ;AAAA,cACnB,WAAWA,EAAQ;AAAA,cACnB,WAAKA,EAAA,aAAA,CAAA,CAAAU;AAAA,cAAA,KACJ;AAAA,gBACA,UAAAT;AAAA,gBACA,MAAAC;AAAA,gBACA,gBAA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24
24
|
word-spacing: normal;
|
|
25
25
|
tab-size: 4;
|
|
@@ -126,9 +126,7 @@
|
|
|
126
126
|
--code-block-color-lang-css-function: var(--code-block-color-cyan);
|
|
127
127
|
--code-block-color-lang-css-property: var(--code-block-color-cyan);
|
|
128
128
|
--code-block-color-lang-css-punctuation: var(--code-block-color-orange);
|
|
129
|
-
--code-block-color-lang-css-not-atrule: var(
|
|
130
|
-
--code-block-color-foreground-primary
|
|
131
|
-
);
|
|
129
|
+
--code-block-color-lang-css-not-atrule: var(--code-block-color-foreground-primary);
|
|
132
130
|
--code-block-color-lang-css-selector: var(--code-block-color-blue);
|
|
133
131
|
--code-block-color-lang-css-url: var(--code-block-color-orange);
|
|
134
132
|
// javascript ----
|
|
@@ -136,9 +134,7 @@
|
|
|
136
134
|
// markup/html ----
|
|
137
135
|
--code-block-color-lang-markup-attr-value: var(--code-block-color-yellow);
|
|
138
136
|
--code-block-color-lang-markup-entity-named: var(--code-block-color-purple);
|
|
139
|
-
--code-block-color-lang-markup-entity-not-named: var(
|
|
140
|
-
--code-block-color-green
|
|
141
|
-
);
|
|
137
|
+
--code-block-color-lang-markup-entity-not-named: var(--code-block-color-green);
|
|
142
138
|
}
|
|
143
139
|
|
|
144
140
|
// Syntax highlighting ----
|
|
@@ -364,7 +360,7 @@
|
|
|
364
360
|
|
|
365
361
|
// Code
|
|
366
362
|
.code {
|
|
367
|
-
@include hds-focus-ring-basic
|
|
363
|
+
@include hds-focus-ring-basic;
|
|
368
364
|
display: block;
|
|
369
365
|
margin: 0;
|
|
370
366
|
padding: var(--code-block-code-padding) 0;
|
|
@@ -399,9 +395,7 @@
|
|
|
399
395
|
}
|
|
400
396
|
|
|
401
397
|
&:active {
|
|
402
|
-
background-color: var(
|
|
403
|
-
--code-block-color-surface-interactive-active
|
|
404
|
-
) !important;
|
|
398
|
+
background-color: var(--code-block-color-surface-interactive-active) !important;
|
|
405
399
|
}
|
|
406
400
|
|
|
407
401
|
&:focus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-jsx-into-lines.js","sources":["../../../../../src/components/code-block/code-lines/utils/split-jsx-into-lines.ts"],"sourcesContent":["import { Children, type ReactNode } from 'react'\n\n/**\n * Given an array of React children,\n * split the array on newlines, grouping consecutive\n * non-newline tokens in individual line elements,\n * and return an array of React <span> elements,\n * each of which will contain a single line.\n *\n * Note that JSX tokens should not be multi-line,\n * ie, all newline characters should be surfaced\n * to the top level rather than nested in syntax\n * highlighting tokens (otherwise the line-by-line\n * markup we render would be invalid). We have\n * a rehype plugin we include with our markdown defaults\n * to ensure newlines are surfaced in this way.\n *\n * @param {*} codeJsx Array of JSX elements, some of which may be newline strings\n * @returns Array of JSX <span> elements representing individual lines\n */\nfunction splitJsxIntoLines(codeJsx: React.ReactNode | React.ReactNode[]) {\n\tconst linesArray = Children.toArray(codeJsx)\n\t/**\n\t * Many newlines take the form of a literal newline string, `\\n`.\n\t * However, some newlines take different forms. We expect these to be tagged\n\t * with an `empty-line` className by our rehype code plugins.\n\t * Here we detect the latter types of newline, and convert them to the former.\n\t */\n\tconst withNormalizedNewlines = linesArray.map((token) => {\n\t\t// If our token has an `empty-line` className, use a literal newline\n\t\t// rather than the token itself (which would render, but with zero height)\n\t\tif (typeof token === 'object' && 'props' in token) {\n\t\t\tif (token.props.className?.includes('empty-line')) {\n\t\t\t\treturn '\\n'\n\t\t\t}\n\t\t}\n\t\t// Otherwise, return the token unmodified\n\t\treturn token\n\t})\n\t// Filter out any surfaces newlines, that are \"in between\"\n\t// other lines of code. Special exceptions should be made for:\n\t// 1. newlines at start or end of array - should be rendered as blank lines\n\t// 2. consecutive newlines - \"n\" consecutive newlines should be rendered\n\t// as \"n - 1\" blank lines.\n\tconst accumulatedLines = withNormalizedNewlines.reduce(\n\t\t(acc, token, idx) => {\n\t\t\tconst isLastLine = idx === withNormalizedNewlines.length - 1\n\t\t\tconst isNewline = token === '\\n'\n\t\t\tconst isInlineToken = token !== '\\n'\n\t\t\t// For newlines, increment the consecutive newline counter\n\t\t\tif (isNewline) acc.consecutiveNewlines++\n\t\t\t// If this token is an inline token, and we have\n\t\t\t// pending newlines, then start a new line,\n\t\t\t// adding blank lines for consecutive newlines as needed\n\t\t\tconst isFinalNewline = isNewline && isLastLine\n\t\t\tconst hasNewlines = acc.consecutiveNewlines > 0\n\t\t\tconst needsNewlines = (isInlineToken || isFinalNewline) && hasNewlines\n\t\t\tif (needsNewlines) {\n\t\t\t\t// If there are any tokens in the current line, add them as a new line\n\t\t\t\tif (acc.currentLine.length > 0) {\n\t\t\t\t\tacc.lines.push(acc.currentLine)\n\t\t\t\t\tacc.currentLine = []\n\t\t\t\t}\n\t\t\t\t// Add blank lines for each consecutive newline, then reset the counter\n\t\t\t\tfor (let i = 1; i < acc.consecutiveNewlines; i++) {\n\t\t\t\t\tacc.lines.push('')\n\t\t\t\t}\n\t\t\t\tacc.consecutiveNewlines = 0\n\t\t\t}\n\t\t\t// If this token is an inline token,\n\t\t\t// append it to the current line\n\t\t\tif (isInlineToken) {\n\t\t\t\tacc.currentLine.push(token)\n\t\t\t\t// If this is the last line,\n\t\t\t\t// then ensure the current line\n\t\t\t\t// has been pushed to the lines array\n\t\t\t\tif (isLastLine) acc.lines.push(acc.currentLine)\n\t\t\t}\n\t\t\treturn acc\n\t\t},\n\t\t{\n\t\t\tlines: [] as ReactNode[],\n\t\t\tcurrentLine: [] as ReactNode[],\n\t\t\tconsecutiveNewlines: 1, // Start at 1 to handle leading newlines\n\t\t}
|
|
1
|
+
{"version":3,"file":"split-jsx-into-lines.js","sources":["../../../../../src/components/code-block/code-lines/utils/split-jsx-into-lines.ts"],"sourcesContent":["import { Children, type ReactNode } from 'react'\n\n/**\n * Given an array of React children,\n * split the array on newlines, grouping consecutive\n * non-newline tokens in individual line elements,\n * and return an array of React <span> elements,\n * each of which will contain a single line.\n *\n * Note that JSX tokens should not be multi-line,\n * ie, all newline characters should be surfaced\n * to the top level rather than nested in syntax\n * highlighting tokens (otherwise the line-by-line\n * markup we render would be invalid). We have\n * a rehype plugin we include with our markdown defaults\n * to ensure newlines are surfaced in this way.\n *\n * @param {*} codeJsx Array of JSX elements, some of which may be newline strings\n * @returns Array of JSX <span> elements representing individual lines\n */\nfunction splitJsxIntoLines(codeJsx: React.ReactNode | React.ReactNode[]) {\n\tconst linesArray = Children.toArray(codeJsx)\n\t/**\n\t * Many newlines take the form of a literal newline string, `\\n`.\n\t * However, some newlines take different forms. We expect these to be tagged\n\t * with an `empty-line` className by our rehype code plugins.\n\t * Here we detect the latter types of newline, and convert them to the former.\n\t */\n\tconst withNormalizedNewlines = linesArray.map((token) => {\n\t\t// If our token has an `empty-line` className, use a literal newline\n\t\t// rather than the token itself (which would render, but with zero height)\n\t\tif (typeof token === 'object' && 'props' in token) {\n\t\t\tif (token.props.className?.includes('empty-line')) {\n\t\t\t\treturn '\\n'\n\t\t\t}\n\t\t}\n\t\t// Otherwise, return the token unmodified\n\t\treturn token\n\t})\n\t// Filter out any surfaces newlines, that are \"in between\"\n\t// other lines of code. Special exceptions should be made for:\n\t// 1. newlines at start or end of array - should be rendered as blank lines\n\t// 2. consecutive newlines - \"n\" consecutive newlines should be rendered\n\t// as \"n - 1\" blank lines.\n\tconst accumulatedLines = withNormalizedNewlines.reduce(\n\t\t(acc, token, idx) => {\n\t\t\tconst isLastLine = idx === withNormalizedNewlines.length - 1\n\t\t\tconst isNewline = token === '\\n'\n\t\t\tconst isInlineToken = token !== '\\n'\n\t\t\t// For newlines, increment the consecutive newline counter\n\t\t\tif (isNewline) acc.consecutiveNewlines++\n\t\t\t// If this token is an inline token, and we have\n\t\t\t// pending newlines, then start a new line,\n\t\t\t// adding blank lines for consecutive newlines as needed\n\t\t\tconst isFinalNewline = isNewline && isLastLine\n\t\t\tconst hasNewlines = acc.consecutiveNewlines > 0\n\t\t\tconst needsNewlines = (isInlineToken || isFinalNewline) && hasNewlines\n\t\t\tif (needsNewlines) {\n\t\t\t\t// If there are any tokens in the current line, add them as a new line\n\t\t\t\tif (acc.currentLine.length > 0) {\n\t\t\t\t\tacc.lines.push(acc.currentLine)\n\t\t\t\t\tacc.currentLine = []\n\t\t\t\t}\n\t\t\t\t// Add blank lines for each consecutive newline, then reset the counter\n\t\t\t\tfor (let i = 1; i < acc.consecutiveNewlines; i++) {\n\t\t\t\t\tacc.lines.push('')\n\t\t\t\t}\n\t\t\t\tacc.consecutiveNewlines = 0\n\t\t\t}\n\t\t\t// If this token is an inline token,\n\t\t\t// append it to the current line\n\t\t\tif (isInlineToken) {\n\t\t\t\tacc.currentLine.push(token)\n\t\t\t\t// If this is the last line,\n\t\t\t\t// then ensure the current line\n\t\t\t\t// has been pushed to the lines array\n\t\t\t\tif (isLastLine) acc.lines.push(acc.currentLine)\n\t\t\t}\n\t\t\treturn acc\n\t\t},\n\t\t{\n\t\t\tlines: [] as ReactNode[],\n\t\t\tcurrentLine: [] as ReactNode[],\n\t\t\tconsecutiveNewlines: 1, // Start at 1 to handle leading newlines\n\t\t},\n\t)\n\treturn accumulatedLines.lines\n}\n\nexport default splitJsxIntoLines\n"],"names":["splitJsxIntoLines","codeJsx","withNormalizedNewlines","Children","token","acc","idx","isLastLine","isNewline","isInlineToken","isFinalNewline","hasNewlines","i"],"mappings":";AAoBA,SAASA,EAAkBC,GAA8C;AAQxE,QAAMC,IAPaC,EAAS,QAAQF,CAAO,EAOD,IAAI,CAACG,MAG1C,OAAOA,KAAU,YAAY,WAAWA,KACvCA,EAAM,MAAM,WAAW,SAAS,YAAY,IACxC;AAAA,IAIFA,CACP;AAgDD,SA1CyBF,EAAuB;AAAA,IAC/C,CAACG,GAAKD,GAAOE,MAAQ;AACpB,YAAMC,IAAaD,MAAQJ,EAAuB,SAAS,GACrDM,IAAYJ,MAAU;AAAA,GACtBK,IAAgBL,MAAU;AAAA;AAEhC,MAAII,KAAWH,EAAI;AAInB,YAAMK,IAAiBF,KAAaD,GAC9BI,IAAcN,EAAI,sBAAsB;AAE9C,WADuBI,KAAiBC,MAAmBC,GACxC;AAElB,QAAIN,EAAI,YAAY,SAAS,MAC5BA,EAAI,MAAM,KAAKA,EAAI,WAAW,GAC9BA,EAAI,cAAc,CAAA;AAGnB,iBAASO,IAAI,GAAGA,IAAIP,EAAI,qBAAqBO;AAC5C,UAAAP,EAAI,MAAM,KAAK,EAAE;AAElB,QAAAA,EAAI,sBAAsB;AAAA,MAC3B;AAGA,aAAII,MACHJ,EAAI,YAAY,KAAKD,CAAK,GAItBG,KAAYF,EAAI,MAAM,KAAKA,EAAI,WAAW,IAExCA;AAAA,IACR;AAAA,IACA;AAAA,MACC,OAAO,CAAA;AAAA,MACP,aAAa,CAAA;AAAA,MACb,qBAAqB;AAAA;AAAA,IAAA;AAAA,EACtB,EAEuB;AACzB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/code-block/hidden-copy-content/index.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useEffect, useState, type ReactNode } from 'react'\n\n/**\n * This hidden element acts solely as a container\n * that we can fetch textContent to copy to clipboard.\n * This allows to ignore the \"how will we copy this cleanly\"\n * concern when splitting code into lines, and adding\n * line numbers and so on in other parts of code-block.\n */\nconst HiddenCopyContentComponent = (\n\t{ code }: { code: ReactNode },\n\tcopyRef: React.ForwardedRef<HTMLPreElement
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/code-block/hidden-copy-content/index.tsx"],"sourcesContent":["'use client'\n\nimport { forwardRef, useEffect, useState, type ReactNode } from 'react'\n\n/**\n * This hidden element acts solely as a container\n * that we can fetch textContent to copy to clipboard.\n * This allows to ignore the \"how will we copy this cleanly\"\n * concern when splitting code into lines, and adding\n * line numbers and so on in other parts of code-block.\n */\nconst HiddenCopyContentComponent = (\n\t{ code }: { code: ReactNode },\n\tcopyRef: React.ForwardedRef<HTMLPreElement>,\n) => {\n\tconst [isClient, setIsClient] = useState(false)\n\n\tuseEffect(() => {\n\t\tsetIsClient(true)\n\t}, [])\n\n\t/**\n\t * We are avoiding SSR here as this component is only used for the copy-to-clipboard interaction, and so rendering\n\t * the text content of the code introduces duplicate markup and some difficult-to-debug hydration mismatches.\n\t * By the time someone interacts with the copy-to-clipboard functionality, this should be rendered.\n\t */\n\tif (!isClient) return null\n\n\treturn (\n\t\t<pre ref={copyRef} style={{ display: 'none' }}>\n\t\t\t{typeof code === 'string' ? (\n\t\t\t\t<span dangerouslySetInnerHTML={{ __html: code }} />\n\t\t\t) : (\n\t\t\t\tcode\n\t\t\t)}\n\t\t</pre>\n\t)\n}\n\nconst HiddenCopyContent = forwardRef(HiddenCopyContentComponent)\n\nexport { HiddenCopyContent }\n"],"names":["HiddenCopyContentComponent","code","copyRef","isClient","setIsClient","useState","useEffect","jsx"],"mappings":";;;AAeC,MAAAA,IAAgC,CAAA,EAAA,MAAAC,EAAS,GAAAC,MAAK;AAE9C,QAAA,CAAAC,GAAgBC,CAAA,IAAAC,EAAA,EAAA;AAWhB,SAVCC,EAAA,MAAY;AACb,IAAAF,EAAK,EAAA;AAAA,EAOL,GAAA,CAAI,CAAC,OAWN,gBAAAG,EAAA,OAAA,EAAA,KAAAL,GAAA,OAAA,EAAA,SAAA,OAAA,GAAA,UAAA,OAAAD,KAAA,WAAA,gBAAAM,EAAA,QAAA,EAAA,yBAAA,EAAA,QAAAN,EAAA,EAAA,CAAA,IAAAA,EAAA,CAAA;AAEA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/code-block/index.tsx"],"sourcesContent":["'use client'\n\nimport { useId, useRef, type ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { Text } from '../text'\nimport { CodeLines } from './code-lines'\nimport { HiddenCopyContent } from './hidden-copy-content'\nimport processSnippet from './utils/process-snippet'\nimport { CopyButton } from '../../patterns/copy-button'\nimport s from './code-block.module.scss'\n\n/**\n * ALERT: This component is a combination of logic from the official HashiCorp\n * Design System CodeBlock component and the CodeBlock component written by the\n * Web Presence Team. The official component relies on client-side rendering\n * for the calculation of line-heights for line numbers, but this is something\n * we want to be able to achieve without client-side rendering.\n */\n\ninterface CodeBlockProps {\n\t/**\n\t * The text/code content for the CodeBlock. The component encodes this\n\t * argument before displaying it. Should be a pre-highlighted string\n\t * generated by Prism.js or Shiki.\n\t */\n\tvalue: ReactNode\n\n\t/**\n\t * The coding language to use for syntax highlighting. If you need\n\t * additional languages contact the Design Systems Team.\n\t */\n\tlanguage?: string\n\n\t/**\n\t * Applies rounded borders to the component. When used within another\n\t * component or when the context requires it, you can turn it off.\n\t */\n\tisStandalone?: boolean\n\n\t/**\n\t * Used to control whether a copy button for copying the code/text content\n\t * will be displayed.\n\t */\n\thasCopyButton?: boolean\n\n\t/**\n\t * Used to control display of line numbers.\n\t */\n\thasLineNumbers?: boolean\n\n\t/**\n\t * Accepts a list or range of line numbers to highlight.\n\t * (Examples: `2, 4`,`6-10`)\n\t */\n\thighlightLines?: string\n\n\t/**\n\t * Accepts any valid CSS unit. If the CodeBlock content exceeds the maximum\n\t * height a vertical scrollbar is enabled. This value applies to the code\n\t * content only and does not include the header element (title and/or description).\n\t */\n\tmaxHeight?: string\n\ttitle?: ReactNode\n\tdescription?: ReactNode\n\tclassName?: string\n}\n\nconst CodeBlock = ({\n\ttitle,\n\tdescription,\n\tlanguage,\n\tvalue,\n\tisStandalone = true,\n\thasCopyButton,\n\thasLineNumbers = true,\n\thighlightLines,\n\tmaxHeight = 'auto',\n\tclassName,\n}: CodeBlockProps) => {\n\tconst copyRef = useRef<HTMLPreElement>(null)\n\tconst preCodeId = useId()\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts['code-block'],\n\t\t\t\ts.dark,\n\t\t\t\t{\n\t\t\t\t\t[s[`language-${language}`]]: language,\n\t\t\t\t\t[s['is-standalone']]: isStandalone,\n\t\t\t\t\t[s['line-numbers']]: hasLineNumbers,\n\t\t\t\t},\n\t\t\t\tclassName
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/code-block/index.tsx"],"sourcesContent":["'use client'\n\nimport { useId, useRef, type ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { Text } from '../text'\nimport { CodeLines } from './code-lines'\nimport { HiddenCopyContent } from './hidden-copy-content'\nimport processSnippet from './utils/process-snippet'\nimport { CopyButton } from '../../patterns/copy-button'\nimport s from './code-block.module.scss'\n\n/**\n * ALERT: This component is a combination of logic from the official HashiCorp\n * Design System CodeBlock component and the CodeBlock component written by the\n * Web Presence Team. The official component relies on client-side rendering\n * for the calculation of line-heights for line numbers, but this is something\n * we want to be able to achieve without client-side rendering.\n */\n\ninterface CodeBlockProps {\n\t/**\n\t * The text/code content for the CodeBlock. The component encodes this\n\t * argument before displaying it. Should be a pre-highlighted string\n\t * generated by Prism.js or Shiki.\n\t */\n\tvalue: ReactNode\n\n\t/**\n\t * The coding language to use for syntax highlighting. If you need\n\t * additional languages contact the Design Systems Team.\n\t */\n\tlanguage?: string\n\n\t/**\n\t * Applies rounded borders to the component. When used within another\n\t * component or when the context requires it, you can turn it off.\n\t */\n\tisStandalone?: boolean\n\n\t/**\n\t * Used to control whether a copy button for copying the code/text content\n\t * will be displayed.\n\t */\n\thasCopyButton?: boolean\n\n\t/**\n\t * Used to control display of line numbers.\n\t */\n\thasLineNumbers?: boolean\n\n\t/**\n\t * Accepts a list or range of line numbers to highlight.\n\t * (Examples: `2, 4`,`6-10`)\n\t */\n\thighlightLines?: string\n\n\t/**\n\t * Accepts any valid CSS unit. If the CodeBlock content exceeds the maximum\n\t * height a vertical scrollbar is enabled. This value applies to the code\n\t * content only and does not include the header element (title and/or description).\n\t */\n\tmaxHeight?: string\n\ttitle?: ReactNode\n\tdescription?: ReactNode\n\tclassName?: string\n}\n\nconst CodeBlock = ({\n\ttitle,\n\tdescription,\n\tlanguage,\n\tvalue,\n\tisStandalone = true,\n\thasCopyButton,\n\thasLineNumbers = true,\n\thighlightLines,\n\tmaxHeight = 'auto',\n\tclassName,\n}: CodeBlockProps) => {\n\tconst copyRef = useRef<HTMLPreElement>(null)\n\tconst preCodeId = useId()\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames(\n\t\t\t\ts['code-block'],\n\t\t\t\ts.dark,\n\t\t\t\t{\n\t\t\t\t\t[s[`language-${language}`]]: language,\n\t\t\t\t\t[s['is-standalone']]: isStandalone,\n\t\t\t\t\t[s['line-numbers']]: hasLineNumbers,\n\t\t\t\t},\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<div className={s.header}>\n\t\t\t\t{title && (\n\t\t\t\t\t<Text.HDSBody\n\t\t\t\t\t\tsize=\"200\"\n\t\t\t\t\t\ttag=\"p\"\n\t\t\t\t\t\tweight=\"semibold\"\n\t\t\t\t\t\tclassName={s.title}\n\t\t\t\t\t>\n\t\t\t\t\t\t{title}\n\t\t\t\t\t</Text.HDSBody>\n\t\t\t\t)}\n\t\t\t\t{description && (\n\t\t\t\t\t<Text.HDSBody tag=\"p\" size=\"100\" className={s.description}>\n\t\t\t\t\t\t{description}\n\t\t\t\t\t</Text.HDSBody>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t<div className={s.body}>\n\t\t\t\t{/**\n\t\t\t\t * NOTE: ideally we'd keep the markup of this component in lockstep\n\t\t\t\t * with the markup of the Helios code block. However, we also need\n\t\t\t\t * to support \"clever\" copying of snippets, parsing out shell\n\t\t\t\t * prompt characters like `$` from output, as this is a common\n\t\t\t\t * practice in our tutorial and documentation content. So, this\n\t\t\t\t * HiddenCopyContent component is one divergence from the markup\n\t\t\t\t * of the Helios code block.\n\t\t\t\t */}\n\t\t\t\t<HiddenCopyContent code={value} ref={copyRef} />\n\t\t\t\t<pre className={s.code} id={preCodeId} style={{ maxHeight }}>\n\t\t\t\t\t<code>\n\t\t\t\t\t\t<CodeLines\n\t\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\t\thighlightLines={highlightLines}\n\t\t\t\t\t\t\thasLineNumbers={hasLineNumbers}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</code>\n\t\t\t\t</pre>\n\t\t\t\t{hasCopyButton && (\n\t\t\t\t\t<CopyButton\n\t\t\t\t\t\tclassName={s['copy-button']}\n\t\t\t\t\t\taria-describedby={preCodeId}\n\t\t\t\t\t\tgetTextFn={() => {\n\t\t\t\t\t\t\tconst rawSnippet = copyRef.current?.textContent\n\t\t\t\t\t\t\tif (!rawSnippet) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\"`code-block` - Couldn't find text content to copy.\",\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn processSnippet(rawSnippet)\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ttext=\"Copy\"\n\t\t\t\t\t\tisIconOnly\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nCodeBlock.displayName = 'CodeBlock'\n\nexport type { CodeBlockProps }\nexport { CodeBlock }\n"],"names":["CodeBlock","title","description","language","value","isStandalone","hasCopyButton","hasLineNumbers","highlightLines","maxHeight","className","copyRef","jsxs","classNames","s","jsx","Text","HiddenCopyContent","preCodeId","CodeLines","CopyButton","rawSnippet","processSnippet"],"mappings":";;;;;;;;;;AAmEmB,MAClBA,IAAA,CAAA;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC,IAAA;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC,IAAA;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC,IAAA;AAAA,EACD,WAAAC;AACC;AACA,QAAMC,MAAY,IAAM,SAGvB;AAAA,SAAC,gBAAAC;AAAA,IAAA;AAAA,IAAA;AAAA,MACW,WACRC;AAAA,QACFC,EAAE,YAAA;AAAA,QACFA,EAAA;AAAA,QAAA;AAAA,UAEC,CAACA,EAAE,YAAAX,CAAmB,EAAA,CAAA,GAAAA;AAAA,UACtB,CAACW,EAAE,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A,CAAA;AAAA,MAAA;AAAA,IACD;AAAA,EAEF;AAEA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-highlighted-lines.js","sources":["../../../../src/components/code-block/utils/parse-highlighted-lines.ts"],"sourcesContent":["function parseHighlightedLines(string?: string | boolean) {\n\tif (typeof string == 'undefined' || string === false || string === '') {\n\t\treturn []\n\t}\n\n\tif (typeof string !== 'string') {\n\t\tthrow new Error(\n\t\t\t`The highlight prop must be a string. Received a value of type \"${typeof string}\" instead
|
|
1
|
+
{"version":3,"file":"parse-highlighted-lines.js","sources":["../../../../src/components/code-block/utils/parse-highlighted-lines.ts"],"sourcesContent":["function parseHighlightedLines(string?: string | boolean) {\n\tif (typeof string == 'undefined' || string === false || string === '') {\n\t\treturn []\n\t}\n\n\tif (typeof string !== 'string') {\n\t\tthrow new Error(\n\t\t\t`The highlight prop must be a string. Received a value of type \"${typeof string}\" instead.`,\n\t\t)\n\t}\n\n\tconst hasValidChars = /^[-,0-9\\s]+$/.test(string)\n\tif (!hasValidChars) {\n\t\tthrow new Error(\n\t\t\t`The highlight prop must be a comma-separated list of single integers or ranges with a single dash between two integers. Found invalid characters: \"${string}\".`,\n\t\t)\n\t}\n\n\tconst parts = string.split(',')\n\treturn parts.reduce((acc, part) => {\n\t\treturn acc.concat(parsePart(part))\n\t}, [] as number[])\n}\n\nfunction parsePart(string: string): number[] {\n\tconst dashParts = string.split('-')\n\tif (dashParts.length > 2) {\n\t\tthrow new Error(\n\t\t\t`Each comma-separated value in the highlight prop must be either a single integer, or a range with a single dash between two integers. Found a value with multiple dashes: \"${string}\".`,\n\t\t)\n\t}\n\t// Single integers are easy, just parse and return\n\tconst isSingle = dashParts.length == 1\n\tif (isSingle) {\n\t\tconst parsedInt = parseInt(string)\n\t\tconst isNaN = parsedInt !== parsedInt\n\t\tif (isNaN) {\n\t\t\tthrow new Error(\n\t\t\t\t`Each comma-separated value in the highlight prop must be either a single integer, or a range with a single dash between two integers. Found a value that parsed to NaN: \"${\n\t\t\t\t\tstring === '' ? '<empty string>' : string\n\t\t\t\t}\".`,\n\t\t\t)\n\t\t}\n\t\treturn [parsedInt]\n\t}\n\t// Ranges require a little more logic\n\tconst [startVal, endVal] = dashParts.map((v) => parseInt(v))\n\tconst hasNaNStart = startVal !== startVal\n\tconst hasNaNEnd = endVal !== endVal\n\tif (hasNaNStart || hasNaNEnd) {\n\t\tthrow new Error(\n\t\t\t`Each comma-separated value in the highlight prop must be either a single integer, or a range with a single dash between two integers. Found a range that produced a NaN: \"${string}\".`,\n\t\t)\n\t}\n\tconst length = endVal - startVal + 1\n\tconst values = [...Array(length).keys()].map((int) => int + startVal)\n\treturn values\n}\n\nexport default parseHighlightedLines\n"],"names":["parseHighlightedLines","string","acc","part","parsePart","dashParts","parsedInt","startVal","endVal","v","length","int"],"mappings":"AAAA,SAASA,EAAsBC,GAA2B;AACzD,MAAI,OAAOA,IAAU,OAAeA,MAAW,MAASA,MAAW;AAClE,WAAO,CAAA;AAGR,MAAI,OAAOA,KAAW;AACrB,UAAM,IAAI;AAAA,MACT,kEAAkE,OAAOA,CAAM;AAAA,IAAA;AAKjF,MAAI,CADkB,eAAe,KAAKA,CAAM;AAE/C,UAAM,IAAI;AAAA,MACT,sJAAsJA,CAAM;AAAA,IAAA;AAK9J,SADcA,EAAO,MAAM,GAAG,EACjB,OAAO,CAACC,GAAKC,MAClBD,EAAI,OAAOE,EAAUD,CAAI,CAAC,GAC/B,CAAA,CAAc;AAClB;AAEA,SAASC,EAAUH,GAA0B;AAC5C,QAAMI,IAAYJ,EAAO,MAAM,GAAG;AAClC,MAAII,EAAU,SAAS;AACtB,UAAM,IAAI;AAAA,MACT,8KAA8KJ,CAAM;AAAA,IAAA;AAKtL,MADiBI,EAAU,UAAU,GACvB;AACb,UAAMC,IAAY,SAASL,CAAM;AAEjC,QADcK,MAAcA;AAE3B,YAAM,IAAI;AAAA,QACT,4KACCL,MAAW,KAAK,mBAAmBA,CACpC;AAAA,MAAA;AAGF,WAAO,CAACK,CAAS;AAAA,EAClB;AAEA,QAAM,CAACC,GAAUC,CAAM,IAAIH,EAAU,IAAI,CAACI,MAAM,SAASA,CAAC,CAAC;AAG3D,MAFoBF,MAAaA,KACfC,MAAWA;AAE5B,UAAM,IAAI;AAAA,MACT,6KAA6KP,CAAM;AAAA,IAAA;AAGrL,QAAMS,IAASF,IAASD,IAAW;AAEnC,SADe,CAAC,GAAG,MAAMG,CAAM,EAAE,MAAM,EAAE,IAAI,CAACC,MAAQA,IAAMJ,CAAQ;AAErE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shellwords.js","sources":["../../../../src/components/code-block/utils/shellwords.ts"],"sourcesContent":["const scan = (\n\tstring: string,\n\tpattern: RegExp,\n\tcallback: (match: RegExpMatchArray) => void
|
|
1
|
+
{"version":3,"file":"shellwords.js","sources":["../../../../src/components/code-block/utils/shellwords.ts"],"sourcesContent":["const scan = (\n\tstring: string,\n\tpattern: RegExp,\n\tcallback: (match: RegExpMatchArray) => void,\n) => {\n\tlet result = ''\n\n\twhile (string.length > 0) {\n\t\tconst match = string.match(pattern)\n\n\t\tif (match && match.index != null && match[0] != null) {\n\t\t\tresult += string.slice(0, match.index)\n\t\t\tresult += callback(match)\n\t\t\tstring = string.slice(match.index + match[0].length)\n\t\t} else {\n\t\t\tresult += string\n\t\t\tstring = ''\n\t\t}\n\t}\n\n\treturn result\n}\n\n/**\n * Splits a string into an array of tokens in the same way the UNIX Bourne shell does.\n *\n * @param line A string to split.\n * @returns An array of the split tokens.\n */\nexport const split = (line = '') => {\n\tconst words: string[] = []\n\tlet field = ''\n\tscan(\n\t\tline,\n\t\t/\\s*(?:([^\\s\\\\'\"]+)|'((?:[^'\\\\]|\\\\.)*)'|\"((?:[^\"\\\\]|\\\\.)*)\"|(\\\\.?)|(\\S))(\\s|$)?/,\n\t\t(match) => {\n\t\t\tconst [_raw, word, sq, dq, escape, garbage, separator] = match\n\n\t\t\tif (garbage != null) {\n\t\t\t\tthrow new Error(`Unmatched quote: ${line}`)\n\t\t\t}\n\n\t\t\tif (word) {\n\t\t\t\tfield += word\n\t\t\t} else {\n\t\t\t\tlet addition\n\n\t\t\t\tif (sq) {\n\t\t\t\t\taddition = sq\n\t\t\t\t} else if (dq) {\n\t\t\t\t\taddition = dq\n\t\t\t\t} else if (escape) {\n\t\t\t\t\taddition = escape\n\t\t\t\t}\n\n\t\t\t\tif (addition) {\n\t\t\t\t\tfield += addition.replace(/\\\\(?=.)/, '')\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (separator != null) {\n\t\t\t\twords.push(field)\n\t\t\t\tfield = ''\n\t\t\t}\n\t\t},\n\t)\n\n\tif (field) {\n\t\twords.push(field)\n\t}\n\n\treturn words\n}\n\n/**\n * Escapes a string so that it can be safely used in a Bourne shell command line.\n *\n * @param str A string to escape.\n * @returns The escaped string.\n */\nexport const escape = (str = '') => {\n\treturn str.replace(/([^A-Za-z0-9_\\-.,:/@\\n])/g, '\\\\$1').replace(/\\n/g, \"'\\n'\")\n}\n"],"names":["scan","string","pattern","callback","result","match","split","line","words","field","_raw","word","sq","dq","escape","garbage","separator","addition","str"],"mappings":"AAAA,MAAMA,IAAO,CACZC,GACAC,GACAC,MACI;AACJ,MAAIC,IAAS;AAEb,SAAOH,EAAO,SAAS,KAAG;AACzB,UAAMI,IAAQJ,EAAO,MAAMC,CAAO;AAElC,IAAIG,KAASA,EAAM,SAAS,QAAQA,EAAM,CAAC,KAAK,QAC/CD,KAAUH,EAAO,MAAM,GAAGI,EAAM,KAAK,GACrCD,KAAUD,EAASE,CAAK,GACxBJ,IAASA,EAAO,MAAMI,EAAM,QAAQA,EAAM,CAAC,EAAE,MAAM,MAEnDD,KAAUH,GACVA,IAAS;AAAA,EAEX;AAEA,SAAOG;AACR,GAQaE,IAAQ,CAACC,IAAO,OAAO;AACnC,QAAMC,IAAkB,CAAA;AACxB,MAAIC,IAAQ;AACZ,SAAAT;AAAA,IACCO;AAAA,IACA;AAAA,IACA,CAACF,MAAU;AACV,YAAM,CAACK,GAAMC,GAAMC,GAAIC,GAAIC,GAAQC,GAASC,CAAS,IAAIX;AAEzD,UAAIU,KAAW;AACd,cAAM,IAAI,MAAM,oBAAoBR,CAAI,EAAE;AAG3C,UAAII;AACH,QAAAF,KAASE;AAAA,WACH;AACN,YAAIM;AAEJ,QAAIL,IACHK,IAAWL,IACDC,IACVI,IAAWJ,IACDC,MACVG,IAAWH,IAGRG,MACHR,KAASQ,EAAS,QAAQ,WAAW,EAAE;AAAA,MAEzC;AAEA,MAAID,KAAa,SAChBR,EAAM,KAAKC,CAAK,GAChBA,IAAQ;AAAA,IAEV;AAAA,EAAA,GAGGA,KACHD,EAAM,KAAKC,CAAK,GAGVD;AACR,GAQaM,IAAS,CAACI,IAAM,OACrBA,EAAI,QAAQ,6BAA6B,MAAM,EAAE,QAAQ,OAAO;AAAA,EAAM;"}
|