@frontify/fondue-components 23.0.0 → 24.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fondue-components.js +50 -46
- package/dist/fondue-components.js.map +1 -1
- package/dist/fondue-components10.js +3 -3
- package/dist/fondue-components10.js.map +1 -1
- package/dist/fondue-components11.js +104 -86
- package/dist/fondue-components11.js.map +1 -1
- package/dist/fondue-components12.js +2 -2
- package/dist/fondue-components13.js +58 -57
- package/dist/fondue-components13.js.map +1 -1
- package/dist/fondue-components14.js +2 -2
- package/dist/fondue-components15.js +2 -2
- package/dist/fondue-components16.js +2 -2
- package/dist/fondue-components17.js +56 -36
- package/dist/fondue-components17.js.map +1 -1
- package/dist/fondue-components18.js +34 -16
- package/dist/fondue-components18.js.map +1 -1
- package/dist/fondue-components19.js +18 -73
- package/dist/fondue-components19.js.map +1 -1
- package/dist/fondue-components20.js +18 -36
- package/dist/fondue-components20.js.map +1 -1
- package/dist/fondue-components21.js +71 -50
- package/dist/fondue-components21.js.map +1 -1
- package/dist/fondue-components22.js +36 -138
- package/dist/fondue-components22.js.map +1 -1
- package/dist/fondue-components23.js +50 -50
- package/dist/fondue-components23.js.map +1 -1
- package/dist/fondue-components24.js +138 -33
- package/dist/fondue-components24.js.map +1 -1
- package/dist/fondue-components25.js +52 -193
- package/dist/fondue-components25.js.map +1 -1
- package/dist/fondue-components26.js +30 -134
- package/dist/fondue-components26.js.map +1 -1
- package/dist/fondue-components27.js +191 -126
- package/dist/fondue-components27.js.map +1 -1
- package/dist/fondue-components28.js +134 -30
- package/dist/fondue-components28.js.map +1 -1
- package/dist/fondue-components29.js +130 -63
- package/dist/fondue-components29.js.map +1 -1
- package/dist/fondue-components3.js +1 -1
- package/dist/fondue-components30.js +31 -101
- package/dist/fondue-components30.js.map +1 -1
- package/dist/fondue-components31.js +64 -30
- package/dist/fondue-components31.js.map +1 -1
- package/dist/fondue-components32.js +98 -52
- package/dist/fondue-components32.js.map +1 -1
- package/dist/fondue-components33.js +30 -20
- package/dist/fondue-components33.js.map +1 -1
- package/dist/fondue-components34.js +56 -23
- package/dist/fondue-components34.js.map +1 -1
- package/dist/fondue-components35.js +20 -7
- package/dist/fondue-components35.js.map +1 -1
- package/dist/fondue-components36.js +23 -6
- package/dist/fondue-components36.js.map +1 -1
- package/dist/fondue-components37.js +8 -32
- package/dist/fondue-components37.js.map +1 -1
- package/dist/fondue-components38.js +5 -3
- package/dist/fondue-components38.js.map +1 -1
- package/dist/fondue-components39.js +32 -12
- package/dist/fondue-components39.js.map +1 -1
- package/dist/fondue-components4.js +3 -3
- package/dist/fondue-components40.js +5 -155
- package/dist/fondue-components40.js.map +1 -1
- package/dist/fondue-components41.js +18 -116
- package/dist/fondue-components41.js.map +1 -1
- package/dist/fondue-components42.js +59 -22
- package/dist/fondue-components42.js.map +1 -1
- package/dist/fondue-components43.js +111 -14
- package/dist/fondue-components43.js.map +1 -1
- package/dist/fondue-components44.js +116 -30
- package/dist/fondue-components44.js.map +1 -1
- package/dist/fondue-components45.js +21 -54
- package/dist/fondue-components45.js.map +1 -1
- package/dist/fondue-components46.js +31 -130
- package/dist/fondue-components46.js.map +1 -1
- package/dist/fondue-components47.js +53 -20
- package/dist/fondue-components47.js.map +1 -1
- package/dist/fondue-components48.js +131 -53
- package/dist/fondue-components48.js.map +1 -1
- package/dist/fondue-components49.js +20 -7
- package/dist/fondue-components49.js.map +1 -1
- package/dist/fondue-components5.js +2 -2
- package/dist/fondue-components50.js +53 -13
- package/dist/fondue-components50.js.map +1 -1
- package/dist/fondue-components51.js +7 -14
- package/dist/fondue-components51.js.map +1 -1
- package/dist/fondue-components52.js +13 -5
- package/dist/fondue-components52.js.map +1 -1
- package/dist/fondue-components53.js +15 -60
- package/dist/fondue-components53.js.map +1 -1
- package/dist/fondue-components54.js +5 -18
- package/dist/fondue-components54.js.map +1 -1
- package/dist/fondue-components55.js +60 -19
- package/dist/fondue-components55.js.map +1 -1
- package/dist/fondue-components56.js +18 -5
- package/dist/fondue-components56.js.map +1 -1
- package/dist/fondue-components57.js +18 -14
- package/dist/fondue-components57.js.map +1 -1
- package/dist/fondue-components58.js +1 -1
- package/dist/fondue-components59.js +10 -16
- package/dist/fondue-components59.js.map +1 -1
- package/dist/fondue-components6.js +4 -4
- package/dist/fondue-components60.js +4 -10
- package/dist/fondue-components60.js.map +1 -1
- package/dist/fondue-components61.js +18 -35
- package/dist/fondue-components61.js.map +1 -1
- package/dist/fondue-components62.js +10 -4
- package/dist/fondue-components62.js.map +1 -1
- package/dist/fondue-components63.js +34 -10
- package/dist/fondue-components63.js.map +1 -1
- package/dist/fondue-components64.js +35 -5
- package/dist/fondue-components64.js.map +1 -1
- package/dist/fondue-components65.js +4 -24
- package/dist/fondue-components65.js.map +1 -1
- package/dist/fondue-components66.js +12 -16
- package/dist/fondue-components66.js.map +1 -1
- package/dist/fondue-components67.js +4 -151
- package/dist/fondue-components67.js.map +1 -1
- package/dist/fondue-components68.js +25 -19
- package/dist/fondue-components68.js.map +1 -1
- package/dist/fondue-components69.js +16 -77
- package/dist/fondue-components69.js.map +1 -1
- package/dist/fondue-components7.js +2 -2
- package/dist/fondue-components70.js +152 -8
- package/dist/fondue-components70.js.map +1 -1
- package/dist/fondue-components71.js +19 -37
- package/dist/fondue-components71.js.map +1 -1
- package/dist/fondue-components72.js +76 -69
- package/dist/fondue-components72.js.map +1 -1
- package/dist/fondue-components73.js +8 -11
- package/dist/fondue-components73.js.map +1 -1
- package/dist/fondue-components74.js +36 -12
- package/dist/fondue-components74.js.map +1 -1
- package/dist/fondue-components75.js +70 -12
- package/dist/fondue-components75.js.map +1 -1
- package/dist/fondue-components76.js +10 -22
- package/dist/fondue-components76.js.map +1 -1
- package/dist/fondue-components77.js +13 -34
- package/dist/fondue-components77.js.map +1 -1
- package/dist/fondue-components78.js +12 -10
- package/dist/fondue-components78.js.map +1 -1
- package/dist/fondue-components79.js +22 -67
- package/dist/fondue-components79.js.map +1 -1
- package/dist/fondue-components8.js +5 -5
- package/dist/fondue-components80.js +34 -15
- package/dist/fondue-components80.js.map +1 -1
- package/dist/fondue-components81.js +9 -24
- package/dist/fondue-components81.js.map +1 -1
- package/dist/fondue-components82.js +67 -18
- package/dist/fondue-components82.js.map +1 -1
- package/dist/fondue-components83.js +14 -22
- package/dist/fondue-components83.js.map +1 -1
- package/dist/fondue-components84.js +24 -6
- package/dist/fondue-components84.js.map +1 -1
- package/dist/fondue-components85.js +18 -19
- package/dist/fondue-components85.js.map +1 -1
- package/dist/fondue-components86.js +21 -5
- package/dist/fondue-components86.js.map +1 -1
- package/dist/fondue-components87.js +8 -4
- package/dist/fondue-components87.js.map +1 -1
- package/dist/fondue-components88.js +19 -4
- package/dist/fondue-components88.js.map +1 -1
- package/dist/fondue-components89.js +4 -14
- package/dist/fondue-components89.js.map +1 -1
- package/dist/fondue-components9.js +5 -5
- package/dist/fondue-components90.js +5 -2
- package/dist/fondue-components90.js.map +1 -1
- package/dist/fondue-components91.js +4 -39
- package/dist/fondue-components91.js.map +1 -1
- package/dist/fondue-components92.js +39 -20
- package/dist/fondue-components92.js.map +1 -1
- package/dist/fondue-components93.js +24 -0
- package/dist/fondue-components93.js.map +1 -0
- package/dist/fondue-components94.js +5 -0
- package/dist/fondue-components94.js.map +1 -0
- package/dist/fondue-components95.js +20 -0
- package/dist/fondue-components95.js.map +1 -0
- package/dist/index.d.ts +116 -3
- package/dist/style.css +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components30.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconCross, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n useEffect,\n useRef,\n useState,\n type ChangeEventHandler,\n type CSSProperties,\n type FocusEventHandler,\n type KeyboardEventHandler,\n type ReactElement,\n type SyntheticEvent,\n} from 'react';\n\nimport styles from './styles/textarea.module.scss';\n\nexport type ExtraAction = {\n icon: ReactElement;\n title: string;\n callback: () => void;\n};\n\ntype Status = 'default' | 'loading' | 'success' | 'error';\n\ntype TextareaProps = {\n /**\n * The id of the textarea\n */\n id?: string;\n /**\n * If `true`, Textarea will have `autoComplete` functionality\n */\n autocomplete?: boolean;\n /**\n * If `true`, component rendered is a auto sizing Textarea\n */\n autosize?: boolean;\n /**\n * Render `clear` button to clear input on click\n */\n clearable?: boolean;\n /**\n * A `ReactElement` that will be rendered at the start of the `Textarea`\n */\n decorator?: ReactElement;\n /**\n * Initial value\n */\n defaultValue?: string;\n disabled?: boolean;\n /**\n * Collection of extra actions the input can preform\n */\n extraActions?: ExtraAction[];\n /**\n * If `true`, Textarea will be focused on mount\n */\n focusOnMount?: boolean;\n /**\n * If autosize is false, this is used as rows property for default textarea\n * @default 1\n */\n minRows?: number;\n /**\n * If `autosize` is `false`, this property is ignored\n */\n maxRows?: number;\n /**\n * Event handler called when the textarea value changes\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when Enter is pressed\n */\n onEnterPressed?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n /**\n * If `true`, Textarea will be required\n */\n required?: boolean;\n /**\n * The test id of the textarea\n */\n 'data-test-id'?: string;\n placeholder?: string;\n readOnly?: boolean;\n resizable?: boolean;\n selectable?: boolean;\n /**\n * The current status of the input. It will trigger the corresponding icon to be appended to the Textarea.\n * @default 'default'\n */\n status?: Status;\n value?: string;\n};\n\nexport const Textarea = ({\n 'data-test-id': dataTestId = 'fondue-textarea',\n autocomplete,\n autosize,\n clearable,\n decorator,\n defaultValue,\n disabled,\n extraActions,\n focusOnMount,\n minRows: rows = 1,\n maxRows,\n onEnterPressed,\n readOnly,\n resizable,\n selectable = true,\n status = 'default',\n value: inputValue,\n ...props\n}: TextareaProps) => {\n const ref = useRef<HTMLTextAreaElement>(null);\n const wasClicked = useRef(false);\n\n const [value, setValue] = useState(inputValue ?? defaultValue ?? '');\n\n const hasTools = extraActions?.length !== undefined || clearable || ['success', 'error'].includes(status);\n\n const clear = () => {\n setValue('');\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (event) => {\n if (event.key === 'Enter') {\n onEnterPressed?.(event);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n setValue(inputValue ?? defaultValue ?? '');\n }, [defaultValue, inputValue]);\n\n useEffect(() => {\n if (focusOnMount) {\n ref.current?.focus();\n }\n }, [focusOnMount]);\n\n return (\n <div\n className={styles.root}\n data-autosize={autosize}\n data-clearable={clearable}\n data-disabled={disabled || readOnly}\n data-has-decorator={decorator ? true : false}\n data-has-tools={hasTools}\n data-replicated-value={value}\n data-resizable={resizable}\n data-status={status}\n data-max-rows={!!maxRows}\n data-test-id={dataTestId}\n style={{ '--max-rows': `${maxRows}` } as CSSProperties}\n >\n {decorator ? <div className={styles.decorator}>{decorator}</div> : null}\n <textarea\n {...props}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n props.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n props.onBlur?.(blurEvent);\n }}\n autoComplete={autocomplete ? 'on' : 'off'}\n className={styles.textarea}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onInput={(event) => setValue(event.currentTarget.value)}\n onSelect={(event) => {\n if (!selectable) {\n event.currentTarget.selectionStart = event.currentTarget.selectionEnd;\n }\n }}\n readOnly={readOnly}\n ref={ref}\n rows={rows}\n value={value}\n ></textarea>\n {status === 'loading' && <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`} />}\n {hasTools && (\n <div className={styles.tools}>\n {status === 'success' && (\n <div className={styles.success}>\n <IconCheckMark size={20} />\n </div>\n )}\n {status === 'error' && (\n <div className={styles[status]}>\n <IconExclamationMarkTriangle size={20} />\n </div>\n )}\n {extraActions?.map(({ icon, title, callback }) => (\n <button\n className={styles.toolsButton}\n disabled={disabled || readOnly}\n key={title}\n onClick={callback}\n title={title}\n >\n {icon}\n </button>\n ))}\n {clearable && (\n <button className={styles.toolsButton} onClick={clear} disabled={disabled || readOnly}>\n <IconCross size={20} fill=\"currentColor\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["Textarea","dataTestId","autocomplete","autosize","clearable","decorator","defaultValue","disabled","extraActions","focusOnMount","rows","maxRows","onEnterPressed","readOnly","resizable","selectable","status","inputValue","props","ref","useRef","wasClicked","value","setValue","useState","hasTools","clear","handleKeyDown","event","_a","useEffect","jsxs","styles","jsx","mouseEvent","focusEvent","blurEvent","IconCheckMark","IconExclamationMarkTriangle","icon","title","callback","IconCross"],"mappings":";;;;AAoHO,MAAMA,IAAW,CAAC;AAAA,EACrB,gBAAgBC,IAAa;AAAA,EAC7B,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC;AAAA,EACA,SAASC,IAAO;AAAA,EAChB,SAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC,IAAa;AAAA,EACb,QAAAC,IAAS;AAAA,EACT,O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,GAAO,UAAAC,QAC/B,gBAAAR;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAWD,EAAO;AAAA,cAClB,UAAUzB,KAAYM;AAAA,cAEtB,SAAS4B;AAAA,cACT,OAAAD;AAAA,cAEC,UAAAD;AAAA,YAAA;AAAA,YAJIC;AAAA,UAAA;AAAA,UAOZpC,KACG,gBAAA6B,EAAC,UAAA,EAAO,WAAWD,EAAO,aAAa,SAASN,GAAO,UAAUnB,KAAYM,GACzE,UAAA,gBAAAoB,EAACS,GAAA,EAAU,MAAM,IAAI,MAAK,gBAAe,EAAA,CAC7C;AAAA,QAAA,EAAA,CAER;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
1
|
+
{"version":3,"file":"fondue-components30.js","sources":["../src/components/Text/Text.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactNode, forwardRef, type ForwardedRef, type HTMLAttributeAnchorTarget } from 'react';\n\nimport { type CommonAriaProps } from '#/helpers/aria';\nimport { cn } from '#/utilities/styleUtilities';\n\nimport styles from './styles/text.module.scss';\n\ntype TextWeight = 'default' | 'strong' | 'x-strong';\ntype TextSize = 'x-small' | 'small' | 'medium' | 'large';\ntype TextColor = 'default' | 'weak' | 'x-weak' | 'disabled' | 'negative' | 'positive' | 'warning' | 'interactive';\ntype BoxColor = 'neutral' | 'selected' | 'disabled' | 'positive' | 'negative' | 'warning';\n\ntype TagType = 'a' | 'abbr' | 'address' | 'em' | 'label' | 'li' | 'span' | 'strong' | 'time' | 'p';\n\nexport type TextProps<TTag extends TagType = 'span'> = CommonAriaProps &\n TagProps<TTag> & {\n /**\n * Id of the element\n */\n id?: string;\n /**\n * Size of the text\n *\n * @default 'medium'\n */\n size?: TextSize;\n /**\n * Weight of the font\n *\n * @default 'default'\n */\n weight?: TextWeight;\n /**\n * The html element used to render\n *\n * @default 'span'\n */\n as?: TTag;\n /**\n * Color of the text\n *\n * @default 'default'\n */\n color?: TextColor;\n /**\n * The texts color when used within a box\n *\n * @description optional color prop that uses the inverse box color when accessibility contrast is needed\n **/\n boxColor?: BoxColor;\n className?: string;\n children?: ReactNode;\n };\n\ntype TagPropMap = {\n a: { href?: string; target: HTMLAttributeAnchorTarget; rel?: string; title?: string };\n abbr: { title?: string };\n address: object;\n em: object;\n label: { for?: string };\n li: { value?: string };\n p: object;\n span: object;\n strong: object;\n time: { dateTime?: string };\n};\ntype TagProps<TTag extends TagType> = TagPropMap[TTag];\n\ntype TextElementMap = {\n a: HTMLAnchorElement;\n abbr: HTMLElement;\n address: HTMLElement;\n em: HTMLElement;\n label: HTMLLabelElement;\n li: HTMLLIElement;\n p: HTMLParagraphElement;\n span: HTMLSpanElement;\n strong: HTMLElement;\n time: HTMLTimeElement;\n};\ntype TextElementType<TTag extends TagType> = TextElementMap[TTag];\n\nexport const Text = forwardRef(\n (\n {\n children,\n as: Tag = 'span',\n size = 'medium',\n weight = 'default',\n color = 'default',\n boxColor,\n className,\n ...props\n },\n ref,\n ) => (\n <Tag\n data-test-id=\"text\"\n className={cn([\n styles.root,\n styles[`size-${size}`],\n styles[`weight-${weight}`],\n styles[boxColor ? `color-box-${boxColor}` : `color-${color}`],\n className,\n ])}\n // @ts-expect-error ref can not be inferred properly by TS\n ref={ref}\n {...props}\n >\n {children}\n </Tag>\n ),\n) as (<TTag extends TagType = 'span'>(\n props: TextProps<TTag> & { ref?: ForwardedRef<TextElementType<TTag>> },\n) => JSX.Element) & { displayName: string };\n\nText.displayName = 'FondueText';\n"],"names":["Text","forwardRef","children","Tag","size","weight","color","boxColor","className","props","ref","jsx","cn","styles"],"mappings":";;;;AAoFO,MAAMA,IAAOC;AAAA,EAChB,CACI;AAAA,IACI,UAAAC;AAAA,IACA,IAAIC,IAAM;AAAA,IACV,MAAAC,IAAO;AAAA,IACP,QAAAC,IAAS;AAAA,IACT,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAEPC,MAEA,gBAAAC;AAAA,IAACR;AAAA,IAAA;AAAA,MACG,gBAAa;AAAA,MACb,WAAWS,EAAG;AAAA,QACVC,EAAO;AAAA,QACPA,EAAO,QAAQT,CAAI,EAAE;AAAA,QACrBS,EAAO,UAAUR,CAAM,EAAE;AAAA,QACzBQ,EAAON,IAAW,aAAaA,CAAQ,KAAK,SAASD,CAAK,EAAE;AAAA,QAC5DE;AAAA,MAAA,CACH;AAAA,MAED,KAAAE;AAAA,MACC,GAAGD;AAAA,MAEH,UAAAP;AAAA,IAAA;AAAA,EAAA;AAGb;AAIAF,EAAK,cAAc;"}
|
|
@@ -1,34 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { IconCheckMark as h, IconExclamationMarkTriangle as S } from "@frontify/fondue-icons";
|
|
3
|
+
import { forwardRef as f, useRef as T } from "react";
|
|
4
|
+
import { cn as u } from "./fondue-components41.js";
|
|
5
|
+
import { LoadingCircle as v } from "./fondue-components19.js";
|
|
6
|
+
import a from "./fondue-components85.js";
|
|
7
|
+
const x = ({
|
|
8
|
+
children: i,
|
|
9
|
+
className: c,
|
|
10
|
+
status: e = "neutral",
|
|
11
|
+
"data-test-id": s = "fondue-text-input",
|
|
12
|
+
"aria-errormessage": N,
|
|
13
|
+
placeholder: d,
|
|
14
|
+
...r
|
|
15
|
+
}, w) => {
|
|
16
|
+
const n = T(!1);
|
|
17
|
+
return /* @__PURE__ */ m("div", { className: u(a.root, c), "data-status": e, "data-test-id": s, children: [
|
|
18
|
+
e === "loading" ? /* @__PURE__ */ t("div", { className: a.loadingStatus, "data-test-id": `${s}-loader`, children: /* @__PURE__ */ t(v, { size: "xx-small" }) }) : null,
|
|
19
|
+
/* @__PURE__ */ m("div", { className: a.inputWrapper, children: [
|
|
20
|
+
d && /* @__PURE__ */ t("div", { className: a.placeholder, children: d }),
|
|
21
|
+
/* @__PURE__ */ t(
|
|
22
|
+
"input",
|
|
23
|
+
{
|
|
24
|
+
onMouseDown: (o) => {
|
|
25
|
+
n.current = !0, o.currentTarget.dataset.showFocusRing = "false";
|
|
26
|
+
},
|
|
27
|
+
type: "text",
|
|
28
|
+
placeholder: d,
|
|
29
|
+
...r,
|
|
30
|
+
onFocus: (o) => {
|
|
31
|
+
var l;
|
|
32
|
+
n.current || (o.target.dataset.showFocusRing = "true"), (l = r.onFocus) == null || l.call(r, o);
|
|
33
|
+
},
|
|
34
|
+
onBlur: (o) => {
|
|
35
|
+
var l;
|
|
36
|
+
o.target.dataset.showFocusRing = "false", n.current = !1, (l = r.onBlur) == null || l.call(r, o);
|
|
37
|
+
},
|
|
38
|
+
ref: w,
|
|
39
|
+
className: a.input,
|
|
40
|
+
"aria-invalid": e === "error",
|
|
41
|
+
"aria-errormessage": e === "error" ? N : void 0
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] }),
|
|
45
|
+
e === "success" ? /* @__PURE__ */ t(h, { size: 16, className: a.iconSuccess, "data-test-id": `${s}-success-icon` }) : null,
|
|
46
|
+
e === "error" ? /* @__PURE__ */ t(
|
|
47
|
+
S,
|
|
48
|
+
{
|
|
49
|
+
size: 16,
|
|
50
|
+
className: a.iconError,
|
|
51
|
+
"data-test-id": `${s}-error-icon`
|
|
52
|
+
}
|
|
53
|
+
) : null,
|
|
54
|
+
i
|
|
55
|
+
] });
|
|
28
56
|
};
|
|
57
|
+
x.displayName = "TextField.Root";
|
|
58
|
+
const F = ({ name: i, className: c, ...e }, s) => /* @__PURE__ */ t("div", { "data-slot": !0, "data-name": i, ...e, ref: s, className: u(a.slot, c) });
|
|
59
|
+
F.displayName = "TextField.Slot";
|
|
60
|
+
const g = f(x), k = f(F), R = g;
|
|
61
|
+
R.Root = g;
|
|
62
|
+
R.Slot = k;
|
|
29
63
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
x as TextFieldRoot,
|
|
65
|
+
F as TextFieldSlot,
|
|
66
|
+
R as TextInput
|
|
33
67
|
};
|
|
34
68
|
//# sourceMappingURL=fondue-components31.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components31.js","sources":["../src/components/
|
|
1
|
+
{"version":3,"file":"fondue-components31.js","sources":["../src/components/TextInput/TextInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n forwardRef,\n useRef,\n type ChangeEvent,\n type FocusEvent,\n type ForwardedRef,\n type KeyboardEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\n\nimport { cn } from '#/utilities/styleUtilities';\n\nimport { LoadingCircle } from '../LoadingCircle/LoadingCircle';\n\nimport styles from './styles/text.module.scss';\n\nexport type TextInputProps = {\n id?: string;\n name?: string;\n /**\n * The place where the input slots are placed\n */\n children?: ReactNode;\n /**\n * The default value of the text input\n * Used for uncontrolled components\n */\n defaultValue?: string | number;\n /**\n * The controlled value of the text input\n */\n value?: string | number;\n /**\n * Type of the text input\n * @default \"text\"\n */\n type?: 'date' | 'email' | 'hidden' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url';\n /**\n * The placeholder in the text input\n */\n placeholder?: string;\n /**\n * Disable the text input\n * @default false\n */\n disabled?: boolean;\n /**\n * Make the text input required in form\n * @default false\n */\n required?: boolean;\n /**\n * Make the text input spell-checkable\n * @default true\n */\n spellCheck?: boolean;\n /**\n * Make the text input read-only\n * @default false\n */\n readOnly?: boolean;\n /**\n * Set the type of input so autocomplete can help the user\n * @default \"on\"\n */\n autoComplete?: string;\n /**\n * The maximum length of the text input\n */\n maxLength?: number;\n /**\n * Status of the text input\n * @default \"neutral\"\n */\n status?: 'neutral' | 'success' | 'error' | 'loading';\n className?: string;\n /**\n * Event handler called when the text input value changes\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: (event: FocusEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => void;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLInputElement>) => void;\n 'data-test-id'?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-errormessage'?: string;\n};\n\nexport const TextFieldRoot = (\n {\n children,\n className,\n status = 'neutral',\n 'data-test-id': dataTestId = 'fondue-text-input',\n 'aria-errormessage': ariaErrormessage,\n placeholder,\n ...inputProps\n }: TextInputProps,\n ref: ForwardedRef<HTMLInputElement>,\n) => {\n const wasClicked = useRef(false);\n\n return (\n <div className={cn(styles.root, className)} data-status={status} data-test-id={dataTestId}>\n {status === 'loading' ? (\n <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`}>\n <LoadingCircle size=\"xx-small\" />\n </div>\n ) : null}\n <div className={styles.inputWrapper}>\n {placeholder && <div className={styles.placeholder}>{placeholder}</div>}\n <input\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n type=\"text\"\n placeholder={placeholder}\n {...inputProps}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n inputProps.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n inputProps.onBlur?.(blurEvent);\n }}\n ref={ref}\n className={styles.input}\n aria-invalid={status === 'error'}\n aria-errormessage={status === 'error' ? ariaErrormessage : undefined}\n />\n </div>\n\n {status === 'success' ? (\n <IconCheckMark size={16} className={styles.iconSuccess} data-test-id={`${dataTestId}-success-icon`} />\n ) : null}\n\n {status === 'error' ? (\n <IconExclamationMarkTriangle\n size={16}\n className={styles.iconError}\n data-test-id={`${dataTestId}-error-icon`}\n />\n ) : null}\n\n {children}\n </div>\n );\n};\nTextFieldRoot.displayName = 'TextField.Root';\n\nexport type TextFieldSlotProps = {\n children: ReactNode;\n name?: 'left' | 'right';\n className?: string;\n};\n\nexport const TextFieldSlot = (\n { name, className, ...slotProps }: TextFieldSlotProps,\n forwardedRef: ForwardedRef<HTMLDivElement>,\n) => {\n return <div data-slot data-name={name} {...slotProps} ref={forwardedRef} className={cn(styles.slot, className)} />;\n};\n\nTextFieldSlot.displayName = 'TextField.Slot';\n\nconst ForwardedRefTextFieldRoot = forwardRef<HTMLInputElement, TextInputProps>(TextFieldRoot);\nconst ForwardedRefTextFieldSlot = forwardRef<HTMLDivElement, TextFieldSlotProps>(TextFieldSlot);\n// @ts-expect-error We support both single component (without slots) and compound components (with slots)\nexport const TextInput: typeof TextFieldRoot & {\n Root: typeof ForwardedRefTextFieldRoot;\n Slot: typeof ForwardedRefTextFieldSlot;\n} = ForwardedRefTextFieldRoot;\nTextInput.Root = ForwardedRefTextFieldRoot;\nTextInput.Slot = ForwardedRefTextFieldSlot;\n"],"names":["TextFieldRoot","children","className","status","dataTestId","ariaErrormessage","placeholder","inputProps","ref","wasClicked","useRef","jsxs","cn","styles","jsx","LoadingCircle","mouseEvent","focusEvent","_a","blurEvent","IconCheckMark","IconExclamationMarkTriangle","TextFieldSlot","name","slotProps","forwardedRef","ForwardedRefTextFieldRoot","forwardRef","ForwardedRefTextFieldSlot","TextInput"],"mappings":";;;;;;AA+GO,MAAMA,IAAgB,CACzB;AAAA,EACI,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,gBAAgBC,IAAa;AAAA,EAC7B,qBAAqBC;AAAA,EACrB,aAAAC;AAAA,EACA,GAAGC;AACP,GACAC,MACC;AACD,QAAMC,IAAaC,EAAO,EAAK;AAE/B,SACI,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAGC,EAAO,MAAMX,CAAS,GAAG,eAAaC,GAAQ,gBAAcC,GAC1E,UAAA;AAAA,IAAAD,MAAW,YACR,gBAAAW,EAAC,OAAA,EAAI,WAAWD,EAAO,eAAe,gBAAc,GAAGT,CAAU,WAC7D,UAAA,gBAAAU,EAACC,GAAA,EAAc,MAAK,WAAA,CAAW,GACnC,IACA;AAAA,IACJ,gBAAAJ,EAAC,OAAA,EAAI,WAAWE,EAAO,cAClB,UAAA;AAAA,MAAAP,KAAe,gBAAAQ,EAAC,OAAA,EAAI,WAAWD,EAAO,aAAc,UAAAP,GAAY;AAAA,MACjE,gBAAAQ;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,aAAa,CAACE,MAAe;AACzB,YAAAP,EAAW,UAAU,IACrBO,EAAW,cAAc,QAAQ,gBAAgB;AAAA,UACrD;AAAA,UACA,MAAK;AAAA,UACL,aAAAV;AAAA,UACC,GAAGC;AAAA,UACJ,SAAS,CAACU,MAAe;;AACrB,YAAKR,EAAW,YACZQ,EAAW,OAAO,QAAQ,gBAAgB,UAE9CC,IAAAX,EAAW,YAAX,QAAAW,EAAA,KAAAX,GAAqBU;AAAA,UACzB;AAAA,UACA,QAAQ,CAACE,MAAc;;AACnB,YAAAA,EAAU,OAAO,QAAQ,gBAAgB,SACzCV,EAAW,UAAU,KACrBS,IAAAX,EAAW,WAAX,QAAAW,EAAA,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-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { jsxs as z, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { IconCheckMark as $, IconExclamationMarkTriangle as b, IconCross as q } from "@frontify/fondue-icons";
|
|
3
|
+
import { useRef as F, useState as x, useEffect as B } from "react";
|
|
4
|
+
import l from "./fondue-components86.js";
|
|
5
|
+
const Q = ({
|
|
6
|
+
"data-test-id": w = "fondue-textarea",
|
|
7
|
+
autocomplete: D,
|
|
8
|
+
autosize: R,
|
|
9
|
+
clearable: i,
|
|
10
|
+
decorator: d,
|
|
11
|
+
defaultValue: u,
|
|
12
|
+
disabled: n,
|
|
13
|
+
extraActions: c,
|
|
14
|
+
focusOnMount: N,
|
|
15
|
+
minRows: S = 1,
|
|
16
|
+
maxRows: k,
|
|
17
|
+
onEnterPressed: m,
|
|
18
|
+
readOnly: r,
|
|
19
|
+
resizable: y,
|
|
20
|
+
selectable: I = !0,
|
|
21
|
+
status: s = "default",
|
|
22
|
+
value: f,
|
|
23
|
+
...t
|
|
24
|
+
}) => {
|
|
25
|
+
const C = F(null), h = F(!1), [v, g] = x(f ?? u ?? ""), T = (c == null ? void 0 : c.length) !== void 0 || i || ["success", "error"].includes(s), K = () => {
|
|
26
|
+
g("");
|
|
27
|
+
}, j = (a) => {
|
|
28
|
+
var e;
|
|
29
|
+
a.key === "Enter" && (m == null || m(a)), (e = t.onKeyDown) == null || e.call(t, a);
|
|
30
|
+
};
|
|
31
|
+
return B(() => {
|
|
32
|
+
g(f ?? u ?? "");
|
|
33
|
+
}, [u, f]), B(() => {
|
|
34
|
+
var a;
|
|
35
|
+
N && ((a = C.current) == null || a.focus());
|
|
36
|
+
}, [N]), /* @__PURE__ */ z(
|
|
37
|
+
"div",
|
|
32
38
|
{
|
|
33
|
-
|
|
34
|
-
"data-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
className: l.root,
|
|
40
|
+
"data-autosize": R,
|
|
41
|
+
"data-clearable": i,
|
|
42
|
+
"data-disabled": n || r,
|
|
43
|
+
"data-has-decorator": !!d,
|
|
44
|
+
"data-has-tools": T,
|
|
45
|
+
"data-replicated-value": v,
|
|
46
|
+
"data-resizable": y,
|
|
47
|
+
"data-status": s,
|
|
48
|
+
"data-max-rows": !!k,
|
|
49
|
+
"data-test-id": w,
|
|
50
|
+
style: { "--max-rows": `${k}` },
|
|
41
51
|
children: [
|
|
42
|
-
|
|
43
|
-
/* @__PURE__ */ o(
|
|
52
|
+
d ? /* @__PURE__ */ o("div", { className: l.decorator, children: d }) : null,
|
|
53
|
+
/* @__PURE__ */ o(
|
|
54
|
+
"textarea",
|
|
55
|
+
{
|
|
56
|
+
...t,
|
|
57
|
+
onMouseDown: (a) => {
|
|
58
|
+
h.current = !0, a.currentTarget.dataset.showFocusRing = "false";
|
|
59
|
+
},
|
|
60
|
+
onFocus: (a) => {
|
|
61
|
+
var e;
|
|
62
|
+
h.current || (a.target.dataset.showFocusRing = "true"), (e = t.onFocus) == null || e.call(t, a);
|
|
63
|
+
},
|
|
64
|
+
onBlur: (a) => {
|
|
65
|
+
var e;
|
|
66
|
+
a.target.dataset.showFocusRing = "false", h.current = !1, (e = t.onBlur) == null || e.call(t, a);
|
|
67
|
+
},
|
|
68
|
+
autoComplete: D ? "on" : "off",
|
|
69
|
+
className: l.textarea,
|
|
70
|
+
disabled: n,
|
|
71
|
+
onKeyDown: j,
|
|
72
|
+
onInput: (a) => g(a.currentTarget.value),
|
|
73
|
+
onSelect: (a) => {
|
|
74
|
+
I || (a.currentTarget.selectionStart = a.currentTarget.selectionEnd);
|
|
75
|
+
},
|
|
76
|
+
readOnly: r,
|
|
77
|
+
ref: C,
|
|
78
|
+
rows: S,
|
|
79
|
+
value: v
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
s === "loading" && /* @__PURE__ */ o("div", { className: l.loadingStatus, "data-test-id": `${w}-loader` }),
|
|
83
|
+
T && /* @__PURE__ */ z("div", { className: l.tools, children: [
|
|
84
|
+
s === "success" && /* @__PURE__ */ o("div", { className: l.success, children: /* @__PURE__ */ o($, { size: 20 }) }),
|
|
85
|
+
s === "error" && /* @__PURE__ */ o("div", { className: l[s], children: /* @__PURE__ */ o(b, { size: 20 }) }),
|
|
86
|
+
c == null ? void 0 : c.map(({ icon: a, title: e, callback: M }) => /* @__PURE__ */ o(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
className: l.toolsButton,
|
|
90
|
+
disabled: n || r,
|
|
91
|
+
onClick: M,
|
|
92
|
+
title: e,
|
|
93
|
+
children: a
|
|
94
|
+
},
|
|
95
|
+
e
|
|
96
|
+
)),
|
|
97
|
+
i && /* @__PURE__ */ o("button", { className: l.toolsButton, onClick: K, disabled: n || r, children: /* @__PURE__ */ o(q, { size: 20, fill: "currentColor" }) })
|
|
98
|
+
] })
|
|
44
99
|
]
|
|
45
100
|
}
|
|
46
|
-
)
|
|
47
|
-
};
|
|
48
|
-
f.displayName = "Tooltip.Content";
|
|
49
|
-
const A = {
|
|
50
|
-
Root: p,
|
|
51
|
-
Trigger: l(m),
|
|
52
|
-
Content: l(f)
|
|
101
|
+
);
|
|
53
102
|
};
|
|
54
103
|
export {
|
|
55
|
-
|
|
56
|
-
f as TooltipContent,
|
|
57
|
-
p as TooltipRoot,
|
|
58
|
-
m as TooltipTrigger
|
|
104
|
+
Q as Textarea
|
|
59
105
|
};
|
|
60
106
|
//# sourceMappingURL=fondue-components32.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components32.js","sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixTooltip from '@radix-ui/react-tooltip';\nimport { forwardRef, type ForwardedRef, type ReactElement, type ReactNode } from 'react';\n\nimport { cn } from '#/utilities/styleUtilities';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport styles from './styles/tooltip.module.scss';\n\nexport type TooltipRootProps = {\n /**\n * Sets the open state of the tooltip.\n */\n open?: boolean;\n /**\n * Callback that is called when the open state of the tooltip changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The delay in milliseconds before the tooltip appears.\n * @default 700\n */\n enterDelay?: number;\n children: Array<ReactElement<TooltipTriggerProps | TooltipContentProps>>;\n};\n\nexport const TooltipRoot = ({ children, enterDelay = 700, open, onOpenChange }: TooltipRootProps) => {\n return (\n <RadixTooltip.Provider>\n <RadixTooltip.Root delayDuration={enterDelay} open={open} onOpenChange={onOpenChange}>\n {children}\n </RadixTooltip.Root>\n </RadixTooltip.Provider>\n );\n};\nTooltipRoot.displayName = 'Tooltip.Root';\n\nexport type TooltipTriggerProps = {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default false\n */\n asChild?: boolean;\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const TooltipTrigger = (\n { asChild = false, children, 'data-test-id': dataTestId = 'fondue-tooltip-trigger' }: TooltipTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixTooltip.Trigger\n data-tooltip-trigger\n data-test-id={dataTestId}\n type={!asChild ? 'button' : undefined}\n asChild={asChild}\n ref={ref}\n >\n {children}\n </RadixTooltip.Trigger>\n );\n};\nTooltipTrigger.displayName = 'Tooltip.Trigger';\n\nexport type TooltipContentProps = {\n /**\n * @default \"spacious\"\n */\n padding?: 'spacious' | 'compact';\n /**\n * Defines the preferred side of the tooltip. It will not be respected if there are collisions with the viewport.\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n maxWidth?: string;\n className?: string;\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const TooltipContent = (\n {\n children,\n className,\n maxWidth,\n 'data-test-id': dataTestId = 'fondue-tooltip-content',\n padding = 'spacious',\n side,\n }: TooltipContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { theme, dir } = useFondueTheme();\n\n const getAdjustedSide = (side?: 'top' | 'right' | 'bottom' | 'left') => {\n if (!side || dir === 'ltr') {\n return side;\n }\n\n if (side === 'left') {\n return 'right';\n }\n if (side === 'right') {\n return 'left';\n }\n\n return side;\n };\n\n return (\n <RadixTooltip.Portal>\n <ThemeProvider theme={theme} dir={dir}>\n <RadixTooltip.Content\n data-test-id={dataTestId}\n data-tooltip-spacing={padding}\n className={cn(styles.root, className)}\n style={{ maxWidth }}\n collisionPadding={16}\n sideOffset={8}\n ref={ref}\n side={getAdjustedSide(side)}\n >\n {children}\n <RadixTooltip.Arrow aria-hidden=\"true\" className={styles.arrow} />\n </RadixTooltip.Content>\n </ThemeProvider>\n </RadixTooltip.Portal>\n );\n};\nTooltipContent.displayName = 'Tooltip.Content';\n\nexport const Tooltip = {\n Root: TooltipRoot,\n Trigger: forwardRef<HTMLButtonElement, TooltipTriggerProps>(TooltipTrigger),\n Content: forwardRef<HTMLDivElement, TooltipContentProps>(TooltipContent),\n};\n"],"names":["TooltipRoot","children","enterDelay","open","onOpenChange","jsx","RadixTooltip","TooltipTrigger","asChild","dataTestId","ref","TooltipContent","className","maxWidth","padding","side","theme","dir","useFondueTheme","getAdjustedSide","ThemeProvider","jsxs","cn","styles","Tooltip","forwardRef"],"mappings":";;;;;;AA4BO,MAAMA,IAAc,CAAC,EAAE,UAAAC,GAAU,YAAAC,IAAa,KAAK,MAAAC,GAAM,cAAAC,QAExD,gBAAAC,EAACC,EAAa,UAAb,EACG,UAAA,gBAAAD,EAACC,EAAa,MAAb,EAAkB,eAAeJ,GAAY,MAAAC,GAAY,cAAAC,GACrD,UAAAH,GACL,GACJ;AAGRD,EAAY,cAAc;AAYnB,MAAMO,IAAiB,CAC1B,EAAE,SAAAC,IAAU,IAAO,UAAAP,GAAU,gBAAgBQ,IAAa,yBAAA,GAC1DC,MAGI,gBAAAL;AAAA,EAACC,EAAa;AAAA,EAAb;AAAA,IACG,wBAAoB;AAAA,IACpB,gBAAcG;AAAA,IACd,MAAOD,IAAqB,SAAX;AAAA,IACjB,SAAAA;AAAA,IACA,KAAAE;AAAA,IAEC,UAAAT;AAAA,EAAA;AAAA;AAIbM,EAAe,cAAc;AAiBtB,MAAMI,IAAiB,CAC1B;AAAA,EACI,UAAAV;AAAA,EACA,WAAAW;AAAA,EACA,UAAAC;AAAA,EACA,gBAAgBJ,IAAa;AAAA,EAC7B,SAAAK,IAAU;AAAA,EACV,MAAAC;AACJ,GACAL,MACC;AACD,QAAM,EAAE,OAAAM,GAAO,KAAAC,EAAA,IAAQC,EAAA,GAEjBC,IAAkB,CAACJ,MACjB,CAACA,KAAQE,MAAQ,QACVF,IAGPA,MAAS,SACF,UAEPA,MAAS,UACF,SAGJA;AAGX,2BACKT,EAAa,QAAb,EACG,UAAA,gBAAAD,EAACe,GAAA,EAAc,OAAAJ,GAAc,KAAAC,GACzB,UAAA,gBAAAI;AAAA,IAACf,EAAa;AAAA,IAAb;AAAA,MACG,gBAAcG;AAAA,MACd,wBAAsBK;AAAA,MACtB,WAAWQ,EAAGC,EAAO,MAAMX,CAAS;AAAA,MACpC,OAAO,EAAE,UAAAC,EAAA;AAAA,MACT,kBAAkB;AAAA,MAClB,YAAY;AAAA,MACZ,KAAAH;AAAA,MACA,MAAMS,EAAgBJ,CAAI;AAAA,MAEzB,UAAA;AAAA,QAAAd;AAAA,QACD,gBAAAI,EAACC,EAAa,OAAb,EAAmB,eAAY,QAAO,WAAWiB,EAAO,MAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAExE,EAAA,CACJ;AAER;AACAZ,EAAe,cAAc;AAEtB,MAAMa,IAAU;AAAA,EACnB,MAAMxB;AAAA,EACN,SAASyB,EAAmDlB,CAAc;AAAA,EAC1E,SAASkB,EAAgDd,CAAc;AAC3E;"}
|
|
1
|
+
{"version":3,"file":"fondue-components32.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { IconCheckMark, IconCross, IconExclamationMarkTriangle } from '@frontify/fondue-icons';\nimport {\n useEffect,\n useRef,\n useState,\n type ChangeEventHandler,\n type CSSProperties,\n type FocusEventHandler,\n type KeyboardEventHandler,\n type ReactElement,\n type SyntheticEvent,\n} from 'react';\n\nimport styles from './styles/textarea.module.scss';\n\nexport type ExtraAction = {\n icon: ReactElement;\n title: string;\n callback: () => void;\n};\n\ntype Status = 'default' | 'loading' | 'success' | 'error';\n\ntype TextareaProps = {\n /**\n * The id of the textarea\n */\n id?: string;\n /**\n * If `true`, Textarea will have `autoComplete` functionality\n */\n autocomplete?: boolean;\n /**\n * If `true`, component rendered is a auto sizing Textarea\n */\n autosize?: boolean;\n /**\n * Render `clear` button to clear input on click\n */\n clearable?: boolean;\n /**\n * A `ReactElement` that will be rendered at the start of the `Textarea`\n */\n decorator?: ReactElement;\n /**\n * Initial value\n */\n defaultValue?: string;\n disabled?: boolean;\n /**\n * Collection of extra actions the input can preform\n */\n extraActions?: ExtraAction[];\n /**\n * If `true`, Textarea will be focused on mount\n */\n focusOnMount?: boolean;\n /**\n * If autosize is false, this is used as rows property for default textarea\n * @default 1\n */\n minRows?: number;\n /**\n * If `autosize` is `false`, this property is ignored\n */\n maxRows?: number;\n /**\n * Event handler called when the textarea value changes\n */\n onChange?: ChangeEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is blurred\n */\n onBlur?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text input is focused\n */\n onFocus?: FocusEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is pressed\n */\n onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when Enter is pressed\n */\n onEnterPressed?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when a key is released\n */\n onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;\n /**\n * Event handler called when the text inside of text input is selected\n */\n onSelect?: (event: SyntheticEvent<HTMLTextAreaElement>) => void;\n /**\n * If `true`, Textarea will be required\n */\n required?: boolean;\n /**\n * The test id of the textarea\n */\n 'data-test-id'?: string;\n placeholder?: string;\n readOnly?: boolean;\n resizable?: boolean;\n selectable?: boolean;\n /**\n * The current status of the input. It will trigger the corresponding icon to be appended to the Textarea.\n * @default 'default'\n */\n status?: Status;\n value?: string;\n};\n\nexport const Textarea = ({\n 'data-test-id': dataTestId = 'fondue-textarea',\n autocomplete,\n autosize,\n clearable,\n decorator,\n defaultValue,\n disabled,\n extraActions,\n focusOnMount,\n minRows: rows = 1,\n maxRows,\n onEnterPressed,\n readOnly,\n resizable,\n selectable = true,\n status = 'default',\n value: inputValue,\n ...props\n}: TextareaProps) => {\n const ref = useRef<HTMLTextAreaElement>(null);\n const wasClicked = useRef(false);\n\n const [value, setValue] = useState(inputValue ?? defaultValue ?? '');\n\n const hasTools = extraActions?.length !== undefined || clearable || ['success', 'error'].includes(status);\n\n const clear = () => {\n setValue('');\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLTextAreaElement> = (event) => {\n if (event.key === 'Enter') {\n onEnterPressed?.(event);\n }\n props.onKeyDown?.(event);\n };\n\n useEffect(() => {\n setValue(inputValue ?? defaultValue ?? '');\n }, [defaultValue, inputValue]);\n\n useEffect(() => {\n if (focusOnMount) {\n ref.current?.focus();\n }\n }, [focusOnMount]);\n\n return (\n <div\n className={styles.root}\n data-autosize={autosize}\n data-clearable={clearable}\n data-disabled={disabled || readOnly}\n data-has-decorator={decorator ? true : false}\n data-has-tools={hasTools}\n data-replicated-value={value}\n data-resizable={resizable}\n data-status={status}\n data-max-rows={!!maxRows}\n data-test-id={dataTestId}\n style={{ '--max-rows': `${maxRows}` } as CSSProperties}\n >\n {decorator ? <div className={styles.decorator}>{decorator}</div> : null}\n <textarea\n {...props}\n onMouseDown={(mouseEvent) => {\n wasClicked.current = true;\n mouseEvent.currentTarget.dataset.showFocusRing = 'false';\n }}\n onFocus={(focusEvent) => {\n if (!wasClicked.current) {\n focusEvent.target.dataset.showFocusRing = 'true';\n }\n props.onFocus?.(focusEvent);\n }}\n onBlur={(blurEvent) => {\n blurEvent.target.dataset.showFocusRing = 'false';\n wasClicked.current = false;\n props.onBlur?.(blurEvent);\n }}\n autoComplete={autocomplete ? 'on' : 'off'}\n className={styles.textarea}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onInput={(event) => setValue(event.currentTarget.value)}\n onSelect={(event) => {\n if (!selectable) {\n event.currentTarget.selectionStart = event.currentTarget.selectionEnd;\n }\n }}\n readOnly={readOnly}\n ref={ref}\n rows={rows}\n value={value}\n ></textarea>\n {status === 'loading' && <div className={styles.loadingStatus} data-test-id={`${dataTestId}-loader`} />}\n {hasTools && (\n <div className={styles.tools}>\n {status === 'success' && (\n <div className={styles.success}>\n <IconCheckMark size={20} />\n </div>\n )}\n {status === 'error' && (\n <div className={styles[status]}>\n <IconExclamationMarkTriangle size={20} />\n </div>\n )}\n {extraActions?.map(({ icon, title, callback }) => (\n <button\n className={styles.toolsButton}\n disabled={disabled || readOnly}\n key={title}\n onClick={callback}\n title={title}\n >\n {icon}\n </button>\n ))}\n {clearable && (\n <button className={styles.toolsButton} onClick={clear} disabled={disabled || readOnly}>\n <IconCross size={20} fill=\"currentColor\" />\n </button>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["Textarea","dataTestId","autocomplete","autosize","clearable","decorator","defaultValue","disabled","extraActions","focusOnMount","rows","maxRows","onEnterPressed","readOnly","resizable","selectable","status","inputValue","props","ref","useRef","wasClicked","value","setValue","useState","hasTools","clear","handleKeyDown","event","_a","useEffect","jsxs","styles","jsx","mouseEvent","focusEvent","blurEvent","IconCheckMark","IconExclamationMarkTriangle","icon","title","callback","IconCross"],"mappings":";;;;AAoHO,MAAMA,IAAW,CAAC;AAAA,EACrB,gBAAgBC,IAAa;AAAA,EAC7B,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAA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W,WACR,gBAAAiB,EAAC,OAAA,EAAI,WAAWD,EAAOhB,CAAM,GACzB,UAAA,gBAAAiB,EAACK,GAAA,EAA4B,MAAM,GAAA,CAAI,GAC3C;AAAA,UAEH9B,KAAA,gBAAAA,EAAc,IAAI,CAAC,EAAE,MAAA+B,GAAM,OAAAC,GAAO,UAAAC,QAC/B,gBAAAR;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,WAAWD,EAAO;AAAA,cAClB,UAAUzB,KAAYM;AAAA,cAEtB,SAAS4B;AAAA,cACT,OAAAD;AAAA,cAEC,UAAAD;AAAA,YAAA;AAAA,YAJIC;AAAA,UAAA;AAAA,UAOZpC,KACG,gBAAA6B,EAAC,UAAA,EAAO,WAAWD,EAAO,aAAa,SAASN,GAAO,UAAUnB,KAAYM,GACzE,UAAA,gBAAAoB,EAACS,GAAA,EAAU,MAAM,IAAI,MAAK,gBAAe,EAAA,CAC7C;AAAA,QAAA,EAAA,CAER;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import p from "./fondue-components87.js";
|
|
3
|
+
import { Slot as u } from "@radix-ui/react-slot";
|
|
4
|
+
import { createContext as a, useContext as d, useMemo as f } from "react";
|
|
5
|
+
import { enUS as n } from "./fondue-components88.js";
|
|
6
|
+
const o = a({
|
|
7
|
+
theme: "light",
|
|
8
|
+
dir: "ltr",
|
|
9
|
+
translations: n
|
|
10
|
+
});
|
|
11
|
+
o.displayName = "ThemeContext";
|
|
12
|
+
const g = () => d(o), y = ({
|
|
13
|
+
children: s,
|
|
14
|
+
theme: e = "light",
|
|
15
|
+
dir: t = "ltr",
|
|
16
|
+
translations: r = n,
|
|
17
|
+
asChild: i = !1
|
|
18
|
+
}) => {
|
|
19
|
+
const l = i ? u : "div", c = f(
|
|
20
|
+
() => ({
|
|
21
|
+
theme: e,
|
|
22
|
+
dir: t,
|
|
23
|
+
translations: r
|
|
24
|
+
}),
|
|
25
|
+
[t, e, r]
|
|
26
|
+
);
|
|
27
|
+
return /* @__PURE__ */ m(o.Provider, { value: c, children: /* @__PURE__ */ m(l, { dir: t, className: `${p[e]} fondue-theme-provider`, children: s }) });
|
|
11
28
|
};
|
|
12
29
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
r as accordionHeader,
|
|
17
|
-
c as accordionItem,
|
|
18
|
-
t as accordionSlot,
|
|
19
|
-
n as accordionTrigger,
|
|
20
|
-
a as accordionTriggerContent,
|
|
21
|
-
_ as default,
|
|
22
|
-
o as root
|
|
30
|
+
o as ThemeContext,
|
|
31
|
+
y as ThemeProvider,
|
|
32
|
+
g as useFondueTheme
|
|
23
33
|
};
|
|
24
34
|
//# sourceMappingURL=fondue-components33.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components33.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fondue-components33.js","sources":["../src/components/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport styles from '@frontify/fondue-tokens/themes';\nimport { Slot } from '@radix-ui/react-slot';\nimport { createContext, useContext, useMemo, type ReactNode } from 'react';\n\nimport { enUS, type Translations } from '../../locales';\n\ntype AvailableTheme = keyof typeof styles;\n\ntype ThemeProviderProps = {\n children: ReactNode;\n /**\n * The theme to apply\n * @default \"light\"\n * */\n theme?: AvailableTheme;\n /**\n * Direction to apply to the theme\n * @default \"ltr\"\n */\n dir?: 'ltr' | 'rtl';\n /**\n * Translations object to use for component strings.\n * Import from '@frontify/fondue/components/locales' or provide your own.\n * Must be a complete Translations object.\n * @default \"enUS\"\n * @example\n * ```tsx\n * import { deDE } from '@frontify/fondue/components/locales';\n * <ThemeProvider translations={deDE}>...</ThemeProvider>\n * ```\n */\n translations?: Translations;\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default false\n */\n asChild?: boolean;\n};\n\ntype ThemeContextValue = {\n theme: AvailableTheme;\n dir: 'ltr' | 'rtl';\n translations: Translations;\n};\n\nexport const ThemeContext = createContext<ThemeContextValue>({\n theme: 'light',\n dir: 'ltr',\n translations: enUS,\n});\nThemeContext.displayName = 'ThemeContext';\n\nexport const useFondueTheme = () => {\n return useContext(ThemeContext);\n};\n\nexport const ThemeProvider = ({\n children,\n theme = 'light',\n dir = 'ltr',\n translations = enUS,\n asChild = false,\n}: ThemeProviderProps) => {\n const Comp = asChild ? Slot : 'div';\n\n const contextValue = useMemo(\n () => ({\n theme,\n dir,\n translations,\n }),\n [dir, theme, translations],\n );\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <Comp dir={dir} className={`${styles[theme]} fondue-theme-provider`}>\n {children}\n </Comp>\n </ThemeContext.Provider>\n );\n};\n"],"names":["ThemeContext","createContext","enUS","useFondueTheme","useContext","ThemeProvider","children","theme","dir","translations","asChild","Comp","Slot","contextValue","useMemo","jsx","styles"],"mappings":";;;;;AA+CO,MAAMA,IAAeC,EAAiC;AAAA,EACzD,OAAO;AAAA,EACP,KAAK;AAAA,EACL,cAAcC;AAClB,CAAC;AACDF,EAAa,cAAc;AAEpB,MAAMG,IAAiB,MACnBC,EAAWJ,CAAY,GAGrBK,IAAgB,CAAC;AAAA,EAC1B,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,KAAAC,IAAM;AAAA,EACN,cAAAC,IAAeP;AAAA,EACf,SAAAQ,IAAU;AACd,MAA0B;AACtB,QAAMC,IAAOD,IAAUE,IAAO,OAExBC,IAAeC;AAAA,IACjB,OAAO;AAAA,MACH,OAAAP;AAAA,MACA,KAAAC;AAAA,MACA,cAAAC;AAAA,IAAA;AAAA,IAEJ,CAACD,GAAKD,GAAOE,CAAY;AAAA,EAAA;AAG7B,2BACKT,EAAa,UAAb,EAAsB,OAAOa,GAC1B,UAAA,gBAAAE,EAACJ,GAAA,EAAK,KAAAH,GAAU,WAAW,GAAGQ,EAAOT,CAAK,CAAC,0BACtC,UAAAD,GACL,GACJ;AAER;"}
|
|
@@ -1,27 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { jsx as o, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import * as r from "@radix-ui/react-tooltip";
|
|
3
|
+
import { forwardRef as l } from "react";
|
|
4
|
+
import { cn as R } from "./fondue-components41.js";
|
|
5
|
+
import { useFondueTheme as N, ThemeProvider as x } from "./fondue-components33.js";
|
|
6
|
+
import s from "./fondue-components89.js";
|
|
7
|
+
const p = ({ children: t, enterDelay: e = 700, open: i, onOpenChange: n }) => /* @__PURE__ */ o(r.Provider, { children: /* @__PURE__ */ o(r.Root, { delayDuration: e, open: i, onOpenChange: n, children: t }) });
|
|
8
|
+
p.displayName = "Tooltip.Root";
|
|
9
|
+
const m = ({ asChild: t = !1, children: e, "data-test-id": i = "fondue-tooltip-trigger" }, n) => /* @__PURE__ */ o(
|
|
10
|
+
r.Trigger,
|
|
11
|
+
{
|
|
12
|
+
"data-tooltip-trigger": !0,
|
|
13
|
+
"data-test-id": i,
|
|
14
|
+
type: t ? void 0 : "button",
|
|
15
|
+
asChild: t,
|
|
16
|
+
ref: n,
|
|
17
|
+
children: e
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
m.displayName = "Tooltip.Trigger";
|
|
21
|
+
const f = ({
|
|
22
|
+
children: t,
|
|
23
|
+
className: e,
|
|
24
|
+
maxWidth: i,
|
|
25
|
+
"data-test-id": n = "fondue-tooltip-content",
|
|
26
|
+
padding: c = "spacious",
|
|
27
|
+
side: g
|
|
28
|
+
}, u) => {
|
|
29
|
+
const { theme: T, dir: d } = N(), h = (a) => !a || d === "ltr" ? a : a === "left" ? "right" : a === "right" ? "left" : a;
|
|
30
|
+
return /* @__PURE__ */ o(r.Portal, { children: /* @__PURE__ */ o(x, { theme: T, dir: d, children: /* @__PURE__ */ y(
|
|
31
|
+
r.Content,
|
|
32
|
+
{
|
|
33
|
+
"data-test-id": n,
|
|
34
|
+
"data-tooltip-spacing": c,
|
|
35
|
+
className: R(s.root, e),
|
|
36
|
+
style: { maxWidth: i },
|
|
37
|
+
collisionPadding: 16,
|
|
38
|
+
sideOffset: 8,
|
|
39
|
+
ref: u,
|
|
40
|
+
side: h(g),
|
|
41
|
+
children: [
|
|
42
|
+
t,
|
|
43
|
+
/* @__PURE__ */ o(r.Arrow, { "aria-hidden": "true", className: s.arrow })
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
) }) });
|
|
47
|
+
};
|
|
48
|
+
f.displayName = "Tooltip.Content";
|
|
49
|
+
const A = {
|
|
50
|
+
Root: p,
|
|
51
|
+
Trigger: l(m),
|
|
52
|
+
Content: l(f)
|
|
23
53
|
};
|
|
24
54
|
export {
|
|
25
|
-
|
|
55
|
+
A as Tooltip,
|
|
56
|
+
f as TooltipContent,
|
|
57
|
+
p as TooltipRoot,
|
|
58
|
+
m as TooltipTrigger
|
|
26
59
|
};
|
|
27
60
|
//# sourceMappingURL=fondue-components34.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fondue-components34.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"fondue-components34.js","sources":["../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport * as RadixTooltip from '@radix-ui/react-tooltip';\nimport { forwardRef, type ForwardedRef, type ReactElement, type ReactNode } from 'react';\n\nimport { cn } from '#/utilities/styleUtilities';\n\nimport { ThemeProvider, useFondueTheme } from '../ThemeProvider/ThemeProvider';\n\nimport styles from './styles/tooltip.module.scss';\n\nexport type TooltipRootProps = {\n /**\n * Sets the open state of the tooltip.\n */\n open?: boolean;\n /**\n * Callback that is called when the open state of the tooltip changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * The delay in milliseconds before the tooltip appears.\n * @default 700\n */\n enterDelay?: number;\n children: Array<ReactElement<TooltipTriggerProps | TooltipContentProps>>;\n};\n\nexport const TooltipRoot = ({ children, enterDelay = 700, open, onOpenChange }: TooltipRootProps) => {\n return (\n <RadixTooltip.Provider>\n <RadixTooltip.Root delayDuration={enterDelay} open={open} onOpenChange={onOpenChange}>\n {children}\n </RadixTooltip.Root>\n </RadixTooltip.Provider>\n );\n};\nTooltipRoot.displayName = 'Tooltip.Root';\n\nexport type TooltipTriggerProps = {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n * @default false\n */\n asChild?: boolean;\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const TooltipTrigger = (\n { asChild = false, children, 'data-test-id': dataTestId = 'fondue-tooltip-trigger' }: TooltipTriggerProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) => {\n return (\n <RadixTooltip.Trigger\n data-tooltip-trigger\n data-test-id={dataTestId}\n type={!asChild ? 'button' : undefined}\n asChild={asChild}\n ref={ref}\n >\n {children}\n </RadixTooltip.Trigger>\n );\n};\nTooltipTrigger.displayName = 'Tooltip.Trigger';\n\nexport type TooltipContentProps = {\n /**\n * @default \"spacious\"\n */\n padding?: 'spacious' | 'compact';\n /**\n * Defines the preferred side of the tooltip. It will not be respected if there are collisions with the viewport.\n */\n side?: 'top' | 'right' | 'bottom' | 'left';\n maxWidth?: string;\n className?: string;\n children: ReactNode;\n 'data-test-id'?: string;\n};\n\nexport const TooltipContent = (\n {\n children,\n className,\n maxWidth,\n 'data-test-id': dataTestId = 'fondue-tooltip-content',\n padding = 'spacious',\n side,\n }: TooltipContentProps,\n ref: ForwardedRef<HTMLDivElement>,\n) => {\n const { theme, dir } = useFondueTheme();\n\n const getAdjustedSide = (side?: 'top' | 'right' | 'bottom' | 'left') => {\n if (!side || dir === 'ltr') {\n return side;\n }\n\n if (side === 'left') {\n return 'right';\n }\n if (side === 'right') {\n return 'left';\n }\n\n return side;\n };\n\n return (\n <RadixTooltip.Portal>\n <ThemeProvider theme={theme} dir={dir}>\n <RadixTooltip.Content\n data-test-id={dataTestId}\n data-tooltip-spacing={padding}\n className={cn(styles.root, className)}\n style={{ maxWidth }}\n collisionPadding={16}\n sideOffset={8}\n ref={ref}\n side={getAdjustedSide(side)}\n >\n {children}\n <RadixTooltip.Arrow aria-hidden=\"true\" className={styles.arrow} />\n </RadixTooltip.Content>\n </ThemeProvider>\n </RadixTooltip.Portal>\n );\n};\nTooltipContent.displayName = 'Tooltip.Content';\n\nexport const Tooltip = {\n Root: TooltipRoot,\n Trigger: forwardRef<HTMLButtonElement, TooltipTriggerProps>(TooltipTrigger),\n Content: forwardRef<HTMLDivElement, TooltipContentProps>(TooltipContent),\n};\n"],"names":["TooltipRoot","children","enterDelay","open","onOpenChange","jsx","RadixTooltip","TooltipTrigger","asChild","dataTestId","ref","TooltipContent","className","maxWidth","padding","side","theme","dir","useFondueTheme","getAdjustedSide","ThemeProvider","jsxs","cn","styles","Tooltip","forwardRef"],"mappings":";;;;;;AA4BO,MAAMA,IAAc,CAAC,EAAE,UAAAC,GAAU,YAAAC,IAAa,KAAK,MAAAC,GAAM,cAAAC,QAExD,gBAAAC,EAACC,EAAa,UAAb,EACG,UAAA,gBAAAD,EAACC,EAAa,MAAb,EAAkB,eAAeJ,GAAY,MAAAC,GAAY,cAAAC,GACrD,UAAAH,GACL,GACJ;AAGRD,EAAY,cAAc;AAYnB,MAAMO,IAAiB,CAC1B,EAAE,SAAAC,IAAU,I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d,CAAc;AAC3E;"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const o = "_root_1wz2l_2", c = "_accordionItem_1wz2l_23", n = "_accordionTrigger_1wz2l_29", r = "_accordionHeader_1wz2l_34", t = "_accordionSlot_1wz2l_42", e = "_accordionCaret_1wz2l_70", a = "_accordionTriggerContent_1wz2l_78", i = "_accordionContent_1wz2l_83", d = "_accordionContentText_1wz2l_112", _ = {
|
|
2
|
+
root: o,
|
|
3
|
+
accordionItem: c,
|
|
4
|
+
accordionTrigger: n,
|
|
5
|
+
accordionHeader: r,
|
|
6
|
+
accordionSlot: t,
|
|
7
|
+
accordionCaret: e,
|
|
8
|
+
accordionTriggerContent: a,
|
|
9
|
+
accordionContent: i,
|
|
10
|
+
accordionContentText: d
|
|
7
11
|
};
|
|
8
12
|
export {
|
|
9
|
-
|
|
13
|
+
e as accordionCaret,
|
|
14
|
+
i as accordionContent,
|
|
15
|
+
d as accordionContentText,
|
|
16
|
+
r as accordionHeader,
|
|
17
|
+
c as accordionItem,
|
|
18
|
+
t as accordionSlot,
|
|
19
|
+
n as accordionTrigger,
|
|
20
|
+
a as accordionTriggerContent,
|
|
21
|
+
_ as default,
|
|
22
|
+
o as root
|
|
10
23
|
};
|
|
11
24
|
//# sourceMappingURL=fondue-components35.js.map
|