@doist/reactist 24.2.0-beta → 25.0.0-beta.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/reactist.cjs.development.js +336 -261
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/avatar/avatar.js.map +1 -1
- package/es/banner/banner.js.map +1 -1
- package/es/box/box.js +94 -19
- package/es/box/box.js.map +1 -1
- package/es/button/button.js +93 -18
- package/es/button/button.js.map +1 -1
- package/es/button/button.module.css.js +4 -0
- package/es/button/button.module.css.js.map +1 -0
- package/es/checkbox-field/checkbox-field.js.map +1 -1
- package/es/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/es/components/deprecated-input/input.js +5 -1
- package/es/components/deprecated-input/input.js.map +1 -1
- package/es/heading/heading.js.map +1 -1
- package/es/index.js +2 -3
- package/es/index.js.map +1 -1
- package/es/loading/loading.js.map +1 -1
- package/es/menu/menu.js +56 -34
- package/es/menu/menu.js.map +1 -1
- package/es/modal/modal.js +18 -16
- package/es/modal/modal.js.map +1 -1
- package/es/password-field/password-field.js +2 -2
- package/es/password-field/password-field.js.map +1 -1
- package/es/prose/prose.js.map +1 -1
- package/es/select-field/select-field.js.map +1 -1
- package/es/switch-field/switch-field.js.map +1 -1
- package/es/tabs/tabs.js +26 -32
- package/es/tabs/tabs.js.map +1 -1
- package/es/text-area/text-area.js.map +1 -1
- package/es/text-field/text-field.js.map +1 -1
- package/es/toast/static-toast.js +2 -2
- package/es/toast/static-toast.js.map +1 -1
- package/es/tooltip/tooltip.js +13 -12
- package/es/tooltip/tooltip.js.map +1 -1
- package/es/utils/polymorphism.js +1 -1
- package/es/utils/polymorphism.js.map +1 -1
- package/lib/alert/alert.d.ts +1 -1
- package/lib/avatar/avatar.d.ts +4 -4
- package/lib/avatar/avatar.js.map +1 -1
- package/lib/badge/badge.d.ts +2 -2
- package/lib/banner/banner.d.ts +2 -2
- package/lib/banner/banner.js.map +1 -1
- package/lib/base-field/base-field.d.ts +3 -3
- package/lib/box/box.d.ts +2 -1
- package/lib/box/box.js +1 -1
- package/lib/box/box.js.map +1 -1
- package/lib/button/button.d.ts +123 -11
- package/lib/button/button.js +1 -1
- package/lib/button/button.js.map +1 -1
- package/lib/button/button.module.css.js +2 -0
- package/lib/button/button.module.css.js.map +1 -0
- package/lib/checkbox-field/checkbox-field.d.ts +29 -17
- package/lib/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/checkbox-field/checkbox-icon.d.ts +1 -1
- package/lib/components/color-picker/color-picker.d.ts +2 -2
- package/lib/components/deprecated-dropdown/dropdown.d.ts +5 -5
- package/lib/components/deprecated-dropdown/dropdown.js.map +1 -1
- package/lib/components/deprecated-input/input.d.ts +6 -6
- package/lib/components/deprecated-input/input.js +1 -1
- package/lib/components/deprecated-input/input.js.map +1 -1
- package/lib/components/deprecated-select/select.d.ts +2 -2
- package/lib/components/icons/CloseIcon.svg.d.ts +2 -2
- package/lib/components/icons/ThinQuestionMarkIcon.svg.d.ts +2 -2
- package/lib/components/icons/ThreeDotsIcon.svg.d.ts +2 -2
- package/lib/components/keyboard-shortcut/keyboard-shortcut.d.ts +1 -1
- package/lib/components/progress-bar/progress-bar.d.ts +2 -2
- package/lib/components/time/time.d.ts +1 -1
- package/lib/divider/divider.d.ts +2 -2
- package/lib/heading/heading.d.ts +4 -12
- package/lib/heading/heading.js.map +1 -1
- package/lib/icons/alert-icon.d.ts +2 -2
- package/lib/icons/close-icon.d.ts +2 -2
- package/lib/icons/password-hidden-icon.d.ts +2 -2
- package/lib/icons/password-visible-icon.d.ts +2 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -1
- package/lib/loading/loading.d.ts +6 -7
- package/lib/loading/loading.js.map +1 -1
- package/lib/menu/menu.d.ts +20 -20
- package/lib/menu/menu.js +1 -1
- package/lib/menu/menu.js.map +1 -1
- package/lib/modal/modal-stories-components.d.ts +9 -9
- package/lib/modal/modal.d.ts +24 -35
- package/lib/modal/modal.js +1 -1
- package/lib/modal/modal.js.map +1 -1
- package/lib/notice/notice.d.ts +1 -1
- package/lib/password-field/password-field.d.ts +3 -8
- package/lib/password-field/password-field.js +1 -1
- package/lib/password-field/password-field.js.map +1 -1
- package/lib/prose/prose.d.ts +4 -7
- package/lib/prose/prose.js.map +1 -1
- package/lib/select-field/select-field.d.ts +3 -7
- package/lib/select-field/select-field.js.map +1 -1
- package/lib/spinner/spinner.d.ts +2 -2
- package/lib/switch-field/switch-field.d.ts +12 -11
- package/lib/switch-field/switch-field.js.map +1 -1
- package/lib/tabs/tabs.d.ts +24 -16
- package/lib/tabs/tabs.js +1 -1
- package/lib/tabs/tabs.js.map +1 -1
- package/lib/text-area/text-area.d.ts +3 -8
- package/lib/text-area/text-area.js.map +1 -1
- package/lib/text-field/text-field.d.ts +5 -10
- package/lib/text-field/text-field.js.map +1 -1
- package/lib/toast/static-toast.js +1 -1
- package/lib/toast/static-toast.js.map +1 -1
- package/lib/toast/use-toasts.d.ts +1 -1
- package/lib/tooltip/tooltip.d.ts +4 -7
- package/lib/tooltip/tooltip.js +1 -1
- package/lib/tooltip/tooltip.js.map +1 -1
- package/lib/utils/common-types.d.ts +19 -0
- package/lib/utils/polymorphism.d.ts +5 -21
- package/lib/utils/polymorphism.js.map +1 -1
- package/lib/utils/test-helpers.d.ts +2 -2
- package/package.json +3 -3
- package/styles/alert.css +2 -2
- package/styles/{base-button.css → button.css} +2 -2
- package/styles/button.module.css.css +1 -0
- package/styles/modal.css +2 -2
- package/styles/password-field.css +2 -2
- package/styles/reactist.css +1 -1
- package/styles/static-toast.css +2 -2
- package/styles/use-toasts.css +2 -2
- package/es/base-button/base-button.js +0 -75
- package/es/base-button/base-button.js.map +0 -1
- package/es/base-button/base-button.module.css.js +0 -4
- package/es/base-button/base-button.module.css.js.map +0 -1
- package/es/button-link/button-link.js +0 -38
- package/es/button-link/button-link.js.map +0 -1
- package/lib/base-button/base-button.d.ts +0 -80
- package/lib/base-button/base-button.js +0 -2
- package/lib/base-button/base-button.js.map +0 -1
- package/lib/base-button/base-button.module.css.js +0 -2
- package/lib/base-button/base-button.module.css.js.map +0 -1
- package/lib/base-button/index.d.ts +0 -1
- package/lib/button-link/button-link-story-wrapper.d.ts +0 -7
- package/lib/button-link/button-link.d.ts +0 -13
- package/lib/button-link/button-link.js +0 -2
- package/lib/button-link/button-link.js.map +0 -1
- package/lib/button-link/button-link.test.d.ts +0 -1
- package/lib/button-link/index.d.ts +0 -1
- package/styles/base-button.module.css.css +0 -1
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FieldComponentProps } from '../base-field';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare type DeprecatedProps = 'crossOrigin' | 'onPointerEnterCapture' | 'onPointerLeaveCapture';
|
|
8
|
-
declare type SwitchFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth' | 'aria-describedby' | 'aria-label' | 'aria-labelledby' | DeprecatedProps> & {
|
|
9
|
-
/** Identifies the element (or elements) that describes the switch for assistive technologies. */
|
|
3
|
+
interface SwitchFieldProps extends Omit<FieldComponentProps<HTMLInputElement>, 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth' | 'aria-describedby' | 'aria-label' | 'aria-labelledby'> {
|
|
4
|
+
/**
|
|
5
|
+
* Identifies the element (or elements) that describes the switch for assistive technologies.
|
|
6
|
+
*/
|
|
10
7
|
'aria-describedby'?: string;
|
|
11
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Defines a string value that labels the current switch for assistive technologies.
|
|
10
|
+
*/
|
|
12
11
|
'aria-label'?: string;
|
|
13
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Identifies the element (or elements) that labels the current switch for assistive technologies.
|
|
14
|
+
*/
|
|
14
15
|
'aria-labelledby'?: string;
|
|
15
|
-
}
|
|
16
|
-
declare const SwitchField: React.ForwardRefExoticComponent<
|
|
16
|
+
}
|
|
17
|
+
declare const SwitchField: React.ForwardRefExoticComponent<Omit<SwitchFieldProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
17
18
|
export { SwitchField };
|
|
18
19
|
export type { SwitchFieldProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-field.js","sources":["../../src/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../utils/common-helpers'\nimport styles from './switch-field.module.css'\n\
|
|
1
|
+
{"version":3,"file":"switch-field.js","sources":["../../src/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../utils/common-helpers'\nimport styles from './switch-field.module.css'\n\ninterface SwitchFieldProps\n extends Omit<\n FieldComponentProps<HTMLInputElement>,\n | 'type'\n | 'secondaryLabel'\n | 'auxiliaryLabel'\n | 'maxWidth'\n | 'aria-describedby'\n | 'aria-label'\n | 'aria-labelledby'\n > {\n /**\n * Identifies the element (or elements) that describes the switch for assistive technologies.\n */\n 'aria-describedby'?: string\n\n /**\n * Defines a string value that labels the current switch for assistive technologies.\n */\n 'aria-label'?: string\n\n /**\n * Identifies the element (or elements) that labels the current switch for assistive technologies.\n */\n 'aria-labelledby'?: string\n}\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n 'aria-label': originalAriaLabel,\n 'aria-labelledby': originalAriaLabelledby,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const ariaLabel = originalAriaLabel ?? undefined\n const ariaLabelledBy = originalAriaLabelledby ?? undefined\n\n const [keyFocused, setKeyFocused] = React.useState(false)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n keyFocused ? styles.keyFocused : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n onBlur={(event) => {\n setKeyFocused(false)\n props?.onBlur?.(event)\n }}\n onKeyUp={(event) => {\n setKeyFocused(true)\n props?.onKeyUp?.(event)\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["React","ref","label","hint","disabled","hidden","defaultChecked","id","originalId","aria-describedby","originalAriaDescribedBy","aria-label","originalAriaLabel","aria-labelledby","originalAriaLabelledby","onChange","props","useId","hintId","ariaDescribedBy","undefined","ariaLabel","ariaLabelledBy","keyFocused","setKeyFocused","checkedState","setChecked","checked","isChecked","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","onBlur","onKeyUp","handle","Text","exceptionallySetClassName","FieldHint"],"mappings":"0iBAoCoBA,cAAqD,WAcrEC,iBAbAC,MACIA,EADJC,KAEIA,EAFJC,SAGIA,GAAW,EAHfC,OAIIA,EAJJC,eAKIA,EACAC,GAAIC,EACJC,mBAAoBC,EACpBC,aAAcC,EACdC,kBAAmBC,EATvBC,SAUIA,KACGC,iCAIP,MAAMT,EAAKU,QAAMT,GACXU,EAASD,UAETE,QAAkBT,EAAAA,EAA4BP,EAAOe,OAASE,EAC9DC,QAAYT,EAAAA,OAAqBQ,EACjCE,QAAiBR,EAAAA,OAA0BM,GAE1CG,EAAYC,GAAiBxB,YAAe,IAC5CyB,EAAcC,GAAc1B,6BAAegB,EAAMW,WAAWrB,OAC7DsB,WAAYZ,EAAMW,WAAWF,EAEnC,OACIzB,gBAAC6B,SAAMC,MAAM,QAAQzB,OAAQA,GACzBL,gBAAC+B,OACGC,UAAW,CACPC,UAAOC,UACP9B,EAAW6B,UAAO7B,SAAW,KAC7BwB,EAAYK,UAAON,QAAU,KAC7BJ,EAAaU,UAAOV,WAAa,MAErCY,GAAG,QACHC,QAAQ,OACRC,WAAW,UAEXrC,gBAAC+B,OACGO,SAAS,WACTF,QAAQ,cACRG,SAAS,UACTC,YAAY,QACZC,WAAY,EACZT,UAAWC,UAAOS,QAElB1C,gBAAC2C,sBACG3C,2DACQgB,OACJT,GAAIA,EACJqC,KAAK,WACLxC,SAAUA,qBACQe,eACNE,oBACKC,EACjBrB,IAAKA,EACL0B,QAASC,EACTb,SAAW8B,UACP9B,GAAAA,EAAW8B,GACNA,EAAMC,kBACPpB,EAAWmB,EAAME,cAAcpB,UAGvCqB,OAASH,IACLrB,GAAc,SACdR,SAAAA,EAAOgC,QAAPhC,EAAOgC,OAASH,IAEpBI,QAAUJ,IACNrB,GAAc,SACdR,SAAAA,EAAOiC,SAAPjC,EAAOiC,QAAUJ,QAI7B7C,wBAAMgC,UAAWC,UAAOiB,UAE5BlD,gBAACmD,QAAKC,0BAA2BnB,UAAO/B,OAAQA,IAEnDC,EAAOH,gBAACqD,aAAU9C,GAAIW,GAASf,GAAoB"}
|
package/lib/tabs/tabs.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { TabPanelProps as BaseTabPanelProps, RoleProps } from '@ariakit/react';
|
|
3
|
+
import type { ObfuscatedClassName, Space } from '../utils/common-types';
|
|
4
|
+
interface TabsProps {
|
|
5
|
+
/**
|
|
6
|
+
* The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>`
|
|
7
|
+
* components
|
|
8
|
+
*/
|
|
5
9
|
children: React.ReactNode;
|
|
6
10
|
/**
|
|
7
|
-
* Determines the look and feel of the tabs
|
|
11
|
+
* Determines the look and feel of the tabs
|
|
8
12
|
*/
|
|
9
13
|
variant?: 'themed' | 'neutral';
|
|
10
14
|
/**
|
|
11
|
-
* The id of the selected tab. Assigning a value makes this a
|
|
12
|
-
* controlled component
|
|
15
|
+
* The id of the selected tab. Assigning a value makes this a controlled component
|
|
13
16
|
*/
|
|
14
17
|
selectedId?: string | null;
|
|
15
18
|
/**
|
|
@@ -21,21 +24,26 @@ declare type TabsProps = {
|
|
|
21
24
|
* Called with the tab id when a tab is selected
|
|
22
25
|
*/
|
|
23
26
|
onSelectedIdChange?: (selectedId: string | null | undefined) => void;
|
|
24
|
-
}
|
|
27
|
+
}
|
|
25
28
|
/**
|
|
26
29
|
* Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.
|
|
27
30
|
*/
|
|
28
31
|
declare function Tabs({ children, selectedId, defaultSelectedId, variant, onSelectedIdChange, }: TabsProps): React.ReactElement;
|
|
29
|
-
|
|
30
|
-
/**
|
|
32
|
+
interface TabProps extends ObfuscatedClassName, Pick<RoleProps, 'render'> {
|
|
33
|
+
/**
|
|
34
|
+
* The content to render inside of the tab button
|
|
35
|
+
*/
|
|
31
36
|
children: React.ReactNode;
|
|
32
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* The tab's identifier. This must match its corresponding `<TabPanel>`'s id
|
|
39
|
+
*/
|
|
33
40
|
id: string;
|
|
34
|
-
|
|
41
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
42
|
+
}
|
|
35
43
|
/**
|
|
36
44
|
* Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.
|
|
37
45
|
*/
|
|
38
|
-
declare const Tab:
|
|
46
|
+
declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>;
|
|
39
47
|
declare type TabListProps = ({
|
|
40
48
|
/** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */
|
|
41
49
|
'aria-label': string;
|
|
@@ -64,7 +72,7 @@ declare type TabListProps = ({
|
|
|
64
72
|
* A component used to group `<Tab>` elements together.
|
|
65
73
|
*/
|
|
66
74
|
declare function TabList({ children, space, ...props }: TabListProps): React.ReactElement | null;
|
|
67
|
-
|
|
75
|
+
interface TabPanelProps extends React.HTMLAttributes<HTMLDivElement>, Pick<BaseTabPanelProps, 'render'> {
|
|
68
76
|
/** The content to be rendered inside the tab */
|
|
69
77
|
children?: React.ReactNode;
|
|
70
78
|
/** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */
|
|
@@ -75,13 +83,13 @@ declare type TabPanelProps = {
|
|
|
75
83
|
* meaning while inactive tab panels will not be rendered initially, they will remain mounted
|
|
76
84
|
* once they are active until the entire Tabs tree is unmounted.
|
|
77
85
|
*/
|
|
78
|
-
|
|
79
|
-
}
|
|
86
|
+
renderMode?: 'always' | 'active' | 'lazy';
|
|
87
|
+
}
|
|
80
88
|
/**
|
|
81
89
|
* Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a
|
|
82
90
|
* corresponding `<Tab>` component.
|
|
83
91
|
*/
|
|
84
|
-
declare const TabPanel:
|
|
92
|
+
declare const TabPanel: React.ForwardRefExoticComponent<TabPanelProps & React.RefAttributes<HTMLDivElement>>;
|
|
85
93
|
declare type TabAwareSlotProps = {
|
|
86
94
|
/**
|
|
87
95
|
* Render prop used to provide the content to be rendered inside the slot. The render prop will
|
package/lib/tabs/tabs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),n=(e(r),e(require("classnames"))),a=require("../box/box.js"),l=require("../inline/inline.js"),o=require("@ariakit/react"),s=require("./tabs.module.css.js");const u=["children","space"],c=["children","id","renderMode"],d=r.createContext(null),i=r.forwardRef((function({children:e,id:t,exceptionallySetClassName:a,render:l},u){const c=r.useContext(d);if(!c)return null;const{variant:i,tabStore:b}=c,f=n(a,s.default.tab,s.default["tab-"+i]);return r.createElement(o.Tab,{render:l,className:f,id:t,store:b,ref:u},e)})),b=r.forwardRef((function(e,n){let{children:a,id:l,renderMode:s="always"}=e,u=t.objectWithoutProperties(e,c);const i=r.useContext(d),[b,f]=r.useState(!1),p=(null==i?void 0:i.tabStore.useState("selectedId"))===l;if(r.useEffect((function(){!b&&p&&f(!0)}),[b,p]),!i)return null;const{tabStore:S}=i;return"always"===s||"active"===s&&p||"lazy"===s&&(p||b)?r.createElement(o.TabPanel,t.objectSpread2(t.objectSpread2({},u),{},{tabId:l,store:S,ref:n}),a):null}));exports.Tab=i,exports.TabAwareSlot=function({children:e}){const t=r.useContext(d),n=null==t?void 0:t.tabStore.useState("selectedId");return t?e({selectedId:n}):null},exports.TabList=function(e){let{children:n,space:c}=e,i=t.objectWithoutProperties(e,u);const b=r.useContext(d);if(!b)return null;const{tabStore:f,variant:p}=b;return r.createElement("div",null,r.createElement(o.TabList,t.objectSpread2({store:f,render:r.createElement(a.Box,{position:"relative",width:"maxContent"})},i),r.createElement(a.Box,{className:[s.default.track,s.default["track-"+p]]}),r.createElement(l.Inline,{space:c},n)))},exports.TabPanel=b,exports.Tabs=function({children:e,selectedId:t,defaultSelectedId:n,variant:a="neutral",onSelectedIdChange:l}){const s=o.useTabStore({defaultSelectedId:n,selectedId:t,setSelectedId:l}),u=s.useState("selectedId"),c=r.useMemo(()=>{var e;return{tabStore:s,variant:a,selectedId:null!=(e=null!=t?t:u)?e:null}},[a,s,t,u]);return r.createElement(d.Provider,{value:c},e)};
|
|
2
2
|
//# sourceMappingURL=tabs.js.map
|
package/lib/tabs/tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sources":["../../src/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabStore,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStore,\n} from '@ariakit/react'\nimport { Inline } from '../inline'\nimport
|
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../src/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabStore,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabPanelProps as BaseTabPanelProps,\n TabStore,\n RoleProps,\n} from '@ariakit/react'\nimport { Inline } from '../inline'\nimport type { ObfuscatedClassName, Space } from '../utils/common-types'\n\nimport styles from './tabs.module.css'\nimport { Box } from '../box'\n\ntype TabsContextValue = Required<Pick<TabsProps, 'variant'>> & {\n tabStore: TabStore\n}\n\nconst TabsContext = React.createContext<TabsContextValue | null>(null)\n\ninterface TabsProps {\n /**\n * The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>`\n * components\n */\n children: React.ReactNode\n\n /**\n * Determines the look and feel of the tabs\n */\n variant?: 'themed' | 'neutral'\n\n /**\n * The id of the selected tab. Assigning a value makes this a controlled component\n */\n selectedId?: string | null\n\n /**\n * The tab to initially select. This can be used if the component should not\n * be a controlled component but needs to have a tab selected\n */\n defaultSelectedId?: string | null\n\n /**\n * Called with the tab id when a tab is selected\n */\n onSelectedIdChange?: (selectedId: string | null | undefined) => void\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nfunction Tabs({\n children,\n selectedId,\n defaultSelectedId,\n variant = 'neutral',\n onSelectedIdChange,\n}: TabsProps): React.ReactElement {\n const tabStore = useTabStore({\n defaultSelectedId,\n selectedId,\n setSelectedId: onSelectedIdChange,\n })\n const actualSelectedId = tabStore.useState('selectedId')\n\n const memoizedTabState = React.useMemo(\n () => ({ tabStore, variant, selectedId: selectedId ?? actualSelectedId ?? null }),\n [variant, tabStore, selectedId, actualSelectedId],\n )\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ninterface TabProps extends ObfuscatedClassName, Pick<RoleProps, 'render'> {\n /**\n * The content to render inside of the tab button\n */\n children: React.ReactNode\n\n /**\n * The tab's identifier. This must match its corresponding `<TabPanel>`'s id\n */\n id: string\n\n onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nconst Tab = React.forwardRef<HTMLButtonElement, TabProps>(function Tab(\n { children, id, exceptionallySetClassName, render },\n ref,\n): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n if (!tabContextValue) return null\n\n const { variant, tabStore } = tabContextValue\n const className = classNames(exceptionallySetClassName, styles.tab, styles[`tab-${variant}`])\n\n return (\n <BaseTab render={render} className={className} id={id} store={tabStore} ref={ref}>\n {children}\n </BaseTab>\n )\n})\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: Space\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nfunction TabList({ children, space, ...props }: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { tabStore, variant } = tabContextValue\n\n return (\n // The extra <div> prevents <Inline>'s negative margins from collapsing when used in a flex container\n // which will render the track with the wrong height\n <div>\n <BaseTabList\n store={tabStore}\n render={<Box position=\"relative\" width=\"maxContent\" />}\n {...props}\n >\n <Box className={[styles.track, styles[`track-${variant}`]]} />\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n </div>\n )\n}\n\ninterface TabPanelProps\n extends React.HTMLAttributes<HTMLDivElement>,\n Pick<BaseTabPanelProps, 'render'> {\n /** The content to be rendered inside the tab */\n children?: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This\n * behaviour can be changed to 'active', which renders only when the tab is active, and 'lazy',\n * meaning while inactive tab panels will not be rendered initially, they will remain mounted\n * once they are active until the entire Tabs tree is unmounted.\n */\n renderMode?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a\n * corresponding `<Tab>` component.\n */\nconst TabPanel = React.forwardRef<HTMLDivElement, TabPanelProps>(function TabPanel(\n { children, id, renderMode = 'always', ...props },\n ref,\n): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const selectedId = tabContextValue?.tabStore.useState('selectedId')\n const tabIsActive = selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { tabStore } = tabContextValue\n const shouldRender =\n renderMode === 'always' ||\n (renderMode === 'active' && tabIsActive) ||\n (renderMode === 'lazy' && (tabIsActive || tabRendered))\n\n return shouldRender ? (\n <BaseTabPanel {...props} tabId={id} store={tabStore} ref={ref}>\n {children}\n </BaseTabPanel>\n ) : null\n})\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will\n * be called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the\n * TabPanel component. Can be placed freely within the main `<Tabs>` component.\n */\nfunction TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const selectedId = tabContextValue?.tabStore.useState('selectedId')\n return tabContextValue ? children({ selectedId }) : null\n}\n\nexport { Tab, Tabs, TabList, TabPanel, TabAwareSlot }\n"],"names":["TabsContext","React","Tab","children","id","exceptionallySetClassName","render","ref","tabContextValue","variant","tabStore","className","classNames","styles","tab","BaseTab","store","TabPanel","renderMode","props","tabRendered","setTabRendered","tabIsActive","useState","BaseTabPanel","tabId","selectedId","space","BaseTabList","Box","position","width","track","Inline","defaultSelectedId","onSelectedIdChange","useTabStore","setSelectedId","actualSelectedId","memoizedTabState","Provider","value"],"mappings":"ibAqBMA,EAAcC,gBAA6C,MAwE3DC,EAAMD,cAA8C,UACtDE,SAAEA,EAAFC,GAAYA,EAAZC,0BAAgBA,EAAhBC,OAA2CA,GAC3CC,GAEA,MAAMC,EAAkBP,aAAiBD,GACzC,IAAKQ,EAAiB,OAAO,KAE7B,MAAMC,QAAEA,EAAFC,SAAWA,GAAaF,EACxBG,EAAYC,EAAWP,EAA2BQ,UAAOC,IAAKD,iBAAcJ,IAElF,OACIR,gBAACc,OAAQT,OAAQA,EAAQK,UAAWA,EAAWP,GAAIA,EAAIY,MAAON,EAAUH,IAAKA,GACxEJ,MAqFPc,EAAWhB,cAAgD,WAE7DM,OADAJ,SAAEA,EAAFC,GAAYA,EAAZc,WAAgBA,EAAa,YAAaC,iCAG1C,MAAMX,EAAkBP,aAAiBD,IAClCoB,EAAaC,GAAkBpB,YAAe,GAE/CqB,SADad,SAAAA,EAAiBE,SAASa,SAAS,iBACnBnB,EAWnC,GATAH,aACI,YACSmB,GAAeE,GAChBD,GAAe,KAGvB,CAACD,EAAaE,KAGbd,EACD,OAAO,KAGX,MAAME,SAAEA,GAAaF,EAMrB,MAJmB,WAAfU,GACgB,WAAfA,GAA2BI,GACZ,SAAfJ,IAA0BI,GAAeF,GAG1CnB,gBAACuB,8CAAiBL,OAAOM,MAAOrB,EAAIY,MAAON,EAAUH,IAAKA,IACrDJ,GAEL,2CAeR,UAAsBA,SAAEA,IACpB,MAAMK,EAAkBP,aAAiBD,GACnC0B,QAAalB,SAAAA,EAAiBE,SAASa,SAAS,cACtD,OAAOf,EAAkBL,EAAS,CAAEuB,WAAAA,IAAgB,sBAjGxD,gBAAiBvB,SAAEA,EAAFwB,MAAYA,KAAUR,iCACnC,MAAMX,EAAkBP,aAAiBD,GAEzC,IAAKQ,EACD,OAAO,KAGX,MAAME,SAAEA,EAAFD,QAAYA,GAAYD,EAE9B,OAGIP,2BACIA,gBAAC2B,2BACGZ,MAAON,EACPJ,OAAQL,gBAAC4B,OAAIC,SAAS,WAAWC,MAAM,gBACnCZ,GAEJlB,gBAAC4B,OAAIlB,UAAW,CAACE,UAAOmB,MAAOnB,mBAAgBJ,MAC/CR,gBAACgC,UAAON,MAAOA,GAAQxB,sCA3GvC,UAAcA,SACVA,EADUuB,WAEVA,EAFUQ,kBAGVA,EAHUzB,QAIVA,EAAU,UAJA0B,mBAKVA,IAEA,MAAMzB,EAAW0B,cAAY,CACzBF,kBAAAA,EACAR,WAAAA,EACAW,cAAeF,IAEbG,EAAmB5B,EAASa,SAAS,cAErCgB,EAAmBtC,UACrB,KAAA,MAAA,MAAO,CAAES,SAAAA,EAAUD,QAAAA,EAASiB,0BAAYA,EAAAA,EAAcY,KAAoB,OAC1E,CAAC7B,EAASC,EAAUgB,EAAYY,IAEpC,OAAOrC,gBAACD,EAAYwC,UAASC,MAAOF,GAAmBpC"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseFieldVariantProps, FieldComponentProps } from '../base-field';
|
|
3
|
-
|
|
4
|
-
* FIXME: This is a workaround for consumers that are using newer versions of React types that no longer have these props.
|
|
5
|
-
* Once we upgrade Reactist to the newest React types, we should be able to remove these.
|
|
6
|
-
*/
|
|
7
|
-
declare type DeprecatedProps = 'crossOrigin' | 'onPointerEnterCapture' | 'onPointerLeaveCapture';
|
|
8
|
-
declare type TextAreaProps = Omit<FieldComponentProps<HTMLTextAreaElement>, DeprecatedProps> & BaseFieldVariantProps & {
|
|
3
|
+
interface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {
|
|
9
4
|
/**
|
|
10
5
|
* The number of visible text lines for the text area.
|
|
11
6
|
*
|
|
@@ -23,7 +18,7 @@ declare type TextAreaProps = Omit<FieldComponentProps<HTMLTextAreaElement>, Depr
|
|
|
23
18
|
* If `true`, the textarea will auto-expand or shrink vertically to fit the content.
|
|
24
19
|
*/
|
|
25
20
|
autoExpand?: boolean;
|
|
26
|
-
}
|
|
27
|
-
declare const TextArea: React.ForwardRefExoticComponent<
|
|
21
|
+
}
|
|
22
|
+
declare const TextArea: React.ForwardRefExoticComponent<Omit<TextAreaProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
28
23
|
export { TextArea };
|
|
29
24
|
export type { TextAreaProps };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\
|
|
1
|
+
{"version":3,"file":"text-area.js","sources":["../../src/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMergeRefs } from 'use-callback-ref'\nimport { BaseField, BaseFieldVariantProps, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ninterface TextAreaProps extends FieldComponentProps<HTMLTextAreaElement>, BaseFieldVariantProps {\n /**\n * The number of visible text lines for the text area.\n *\n * If it is specified, it must be a positive integer. If it is not specified, the default\n * value is 2 (set by the browser).\n *\n * When `autoExpand` is true, this value serves the purpose of specifying the minimum number\n * of rows that the textarea will shrink to when the content is not large enough to make it\n * expand.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-rows\n */\n rows?: number\n\n /**\n * If `true`, the textarea will auto-expand or shrink vertically to fit the content.\n */\n autoExpand?: boolean\n}\n\nconst TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n rows,\n autoExpand = false,\n ...props\n },\n ref,\n) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const internalRef = React.useRef<HTMLTextAreaElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n React.useEffect(\n function setupAutoExpand() {\n const containerElement = containerRef.current\n\n function handleAutoExpand(value: string) {\n if (containerElement) {\n containerElement.dataset.replicatedValue = value\n }\n }\n\n function handleInput(event: Event) {\n handleAutoExpand((event.currentTarget as HTMLTextAreaElement).value)\n }\n\n const textAreaElement = internalRef.current\n if (!textAreaElement || !autoExpand) {\n return undefined\n }\n\n // Apply change initially, in case the text area has a non-empty initial value\n handleAutoExpand(textAreaElement.value)\n\n textAreaElement.addEventListener('input', handleInput)\n return () => textAreaElement.removeEventListener('input', handleInput)\n },\n [autoExpand],\n )\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n className={[\n styles.textAreaContainer,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box\n width=\"full\"\n display=\"flex\"\n className={styles.innerContainer}\n ref={containerRef}\n >\n <textarea\n {...props}\n {...extraProps}\n ref={combinedRef}\n rows={rows}\n className={autoExpand ? styles.autoExpand : undefined}\n />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","maxWidth","hidden","aria-describedby","ariaDescribedBy","rows","autoExpand","props","containerRef","internalRef","combinedRef","useMergeRefs","containerElement","current","handleAutoExpand","value","dataset","replicatedValue","handleInput","event","currentTarget","textAreaElement","addEventListener","removeEventListener","BaseField","className","styles","textAreaContainer","error","bordered","extraProps","Box","width","display","innerContainer","undefined"],"mappings":"icA2BiBA,cAAqD,WAiBlEC,OAhBAC,QACIA,EAAU,UADdC,GAEIA,EAFJC,MAGIA,EAHJC,eAIIA,EAJJC,eAKIA,EALJC,KAMIA,EANJC,QAOIA,EAPJC,KAQIA,EARJC,SASIA,EATJC,OAUIA,EACAC,mBAAoBC,EAXxBC,KAYIA,EAZJC,WAaIA,GAAa,KACVC,iCAIP,MAAMC,EAAejB,SAA6B,MAC5CkB,EAAclB,SAAkC,MAChDmB,EAAcC,eAAa,CAACnB,EAAKiB,IA8BvC,OA5BAlB,aACI,WACI,MAAMqB,EAAmBJ,EAAaK,QAEtC,SAASC,EAAiBC,GAClBH,IACAA,EAAiBI,QAAQC,gBAAkBF,GAInD,SAASG,EAAYC,GACjBL,EAAkBK,EAAMC,cAAsCL,OAGlE,MAAMM,EAAkBZ,EAAYI,QACpC,GAAKQ,GAAoBf,EAQzB,OAHAQ,EAAiBO,EAAgBN,OAEjCM,EAAgBC,iBAAiB,QAASJ,GACnC,IAAMG,EAAgBE,oBAAoB,QAASL,KAE9D,CAACZ,IAIDf,gBAACiC,aACG/B,QAASA,EACTC,GAAIA,EACJC,MAAOA,EACPC,eAAgBA,EAChBC,eAAgBA,EAChBC,KAAMA,EACNC,QAASA,EACTC,KAAMA,EACNE,OAAQA,qBACUE,EAClBqB,UAAW,CACPC,UAAOC,kBACE,UAAT3B,EAAmB0B,UAAOE,MAAQ,KACtB,aAAZnC,EAAyBiC,UAAOG,SAAW,MAE/C5B,SAAUA,GAER6B,GACEvC,gBAACwC,OACGC,MAAM,OACNC,QAAQ,OACRR,UAAWC,UAAOQ,eAClB1C,IAAKgB,GAELjB,8EACQgB,GACAuB,OACJtC,IAAKkB,EACLL,KAAMA,EACNoB,UAAWnB,EAAaoB,UAAOpB,gBAAa6B"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BaseFieldVariantProps } from '../base-field';
|
|
3
3
|
import type { FieldComponentProps } from '../base-field';
|
|
4
|
-
/**
|
|
5
|
-
* FIXME: This is a workaround for consumers that are using newer versions of React types that no longer have these props.
|
|
6
|
-
* Once we upgrade Reactist to the newest React types, we should be able to remove these.
|
|
7
|
-
*/
|
|
8
|
-
declare type DeprecatedProps = 'crossOrigin' | 'onPointerEnterCapture' | 'onPointerLeaveCapture';
|
|
9
4
|
declare type TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url';
|
|
10
|
-
|
|
5
|
+
interface TextFieldProps extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>, BaseFieldVariantProps {
|
|
11
6
|
type?: TextFieldType;
|
|
12
|
-
startSlot?: React.
|
|
13
|
-
endSlot?: React.
|
|
14
|
-
}
|
|
15
|
-
declare const TextField: React.ForwardRefExoticComponent<
|
|
7
|
+
startSlot?: React.ReactElement | string | number;
|
|
8
|
+
endSlot?: React.ReactElement | string | number;
|
|
9
|
+
}
|
|
10
|
+
declare const TextField: React.ForwardRefExoticComponent<Omit<TextFieldProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
16
11
|
export { TextField };
|
|
17
12
|
export type { TextFieldProps, TextFieldType };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\
|
|
1
|
+
{"version":3,"file":"text-field.js","sources":["../../src/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, BaseFieldVariantProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\nimport { useMergeRefs } from 'use-callback-ref'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ninterface TextFieldProps\n extends Omit<FieldComponentProps<HTMLInputElement>, 'type'>,\n BaseFieldVariantProps {\n type?: TextFieldType\n startSlot?: React.ReactElement | string | number\n endSlot?: React.ReactElement | string | number\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n variant = 'default',\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n message,\n tone,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n startSlot,\n endSlot,\n ...props\n },\n ref,\n) {\n const internalRef = React.useRef<HTMLInputElement>(null)\n const combinedRef = useMergeRefs([ref, internalRef])\n\n function handleClick(event: React.MouseEvent) {\n if (event.currentTarget === combinedRef.current) return\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n variant={variant}\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n message={message}\n tone={tone}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[\n styles.inputWrapper,\n tone === 'error' ? styles.error : null,\n variant === 'bordered' ? styles.bordered : null,\n ]}\n onClick={handleClick}\n >\n {startSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n marginLeft={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n >\n {startSlot}\n </Box>\n ) : null}\n <input {...props} {...extraProps} type={type} ref={combinedRef} />\n {endSlot ? (\n <Box\n className={styles.slot}\n display=\"flex\"\n marginRight={variant === 'bordered' ? '-xsmall' : 'xsmall'}\n marginLeft={variant === 'bordered' ? 'xsmall' : '-xsmall'}\n >\n {endSlot}\n </Box>\n ) : null}\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["React","ref","variant","id","label","secondaryLabel","auxiliaryLabel","hint","message","tone","type","maxWidth","hidden","aria-describedby","ariaDescribedBy","startSlot","endSlot","props","internalRef","combinedRef","useMergeRefs","handleClick","event","currentTarget","current","focus","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","error","bordered","onClick","slot","marginRight","marginLeft"],"mappings":"4cAiBkBA,cAAmD,WAkBjEC,OAjBAC,QACIA,EAAU,UADdC,GAEIA,EAFJC,MAGIA,EAHJC,eAIIA,EAJJC,eAKIA,EALJC,KAMIA,EANJC,QAOIA,EAPJC,KAQIA,EARJC,KASIA,EAAO,OATXC,SAUIA,EAVJC,OAWIA,EACAC,mBAAoBC,EAZxBC,UAaIA,EAbJC,QAcIA,KACGC,iCAIP,MAAMC,EAAclB,SAA+B,MAC7CmB,EAAcC,eAAa,CAACnB,EAAKiB,IAEvC,SAASG,EAAYC,SACbA,EAAMC,gBAAkBJ,EAAYK,mBACxCN,EAAYM,YAASC,SAGzB,OACIzB,gBAAC0B,aACGxB,QAASA,EACTC,GAAIA,EACJC,MAAOA,EACPC,eAAgBA,EAChBC,eAAgBA,EAChBC,KAAMA,EACNC,QAASA,EACTC,KAAMA,EACNE,SAAUA,EACVC,OAAQA,qBACUE,GAEhBa,GACE3B,gBAAC4B,OACGC,QAAQ,OACRC,WAAW,SACXC,UAAW,CACPC,UAAOC,aACE,UAATxB,EAAmBuB,UAAOE,MAAQ,KACtB,aAAZhC,EAAyB8B,UAAOG,SAAW,MAE/CC,QAASf,GAERN,EACGf,gBAAC4B,OACGG,UAAWC,UAAOK,KAClBR,QAAQ,OACRS,YAAyB,aAAZpC,EAAyB,SAAW,UACjDqC,WAAwB,aAAZrC,EAAyB,UAAY,UAEhDa,GAEL,KACJf,2EAAWiB,GAAWU,OAAYjB,KAAMA,EAAMT,IAAKkB,KAClDH,EACGhB,gBAAC4B,OACGG,UAAWC,UAAOK,KAClBR,QAAQ,OACRS,YAAyB,aAAZpC,EAAyB,UAAY,SAClDqC,WAAwB,aAAZrC,EAAyB,SAAW,WAE/Cc,GAEL"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("../_virtual/_rollupPluginBabelHelpers.js"),l=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("../box/box.js"),r=require("../stack/stack.js"),a=require("../button/button.js"),i=require("../icons/close-icon.js"),o=require("../text/text.js"),s=require("./toast.module.css.js");const c=["message","description","icon","action","onDismiss","dismissLabel"];function u(e){return null!=e&&"object"==typeof e&&"label"in e&&"onClick"in e&&"string"==typeof e.label&&"function"==typeof e.onClick}function m({children:e}){return l.createElement(n.Box,{display:"flex",alignItems:"center",justifyContent:"center",marginX:"-xsmall",marginY:"-medium",className:s.default.slot},e)}exports.StaticToast=l.forwardRef((function(e,d){let{message:f,description:b,icon:p,action:x,onDismiss:j,dismissLabel:E="Close"}=e,g=t.objectWithoutProperties(e,c);return l.createElement(n.Box,t.objectSpread2({ref:d,role:"alert","aria-live":"polite",borderRadius:"full",width:"fitContent",background:"toast",display:"flex",padding:"large",alignItems:"center",className:s.default.toastContainer},g),p?l.createElement(m,null,p):null,l.createElement(n.Box,{flexGrow:1,maxWidth:"small"},b?l.createElement(r.Stack,{space:"small"},l.createElement(o.Text,{weight:"bold"},f," "),l.createElement(o.Text,null,b)):l.createElement(o.Text,null,f)),x?l.createElement(m,null,u(x)?l.createElement(a.Button,{variant:"tertiary",size:"small",onClick:x.onClick},x.label):x):null,j?l.createElement(m,null,l.createElement(a.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("../_virtual/_rollupPluginBabelHelpers.js"),l=(e=require("react"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("../box/box.js"),r=require("../stack/stack.js"),a=require("../button/button.js"),i=require("../icons/close-icon.js"),o=require("../text/text.js"),s=require("./toast.module.css.js");const c=["message","description","icon","action","onDismiss","dismissLabel"];function u(e){return null!=e&&"object"==typeof e&&"label"in e&&"onClick"in e&&"string"==typeof e.label&&"function"==typeof e.onClick}function m({children:e}){return l.createElement(n.Box,{display:"flex",alignItems:"center",justifyContent:"center",marginX:"-xsmall",marginY:"-medium",className:s.default.slot},e)}exports.StaticToast=l.forwardRef((function(e,d){let{message:f,description:b,icon:p,action:x,onDismiss:j,dismissLabel:E="Close"}=e,g=t.objectWithoutProperties(e,c);return l.createElement(n.Box,t.objectSpread2({ref:d,role:"alert","aria-live":"polite",borderRadius:"full",width:"fitContent",background:"toast",display:"flex",padding:"large",alignItems:"center",className:s.default.toastContainer},g),p?l.createElement(m,null,p):null,l.createElement(n.Box,{flexGrow:1,maxWidth:"small"},b?l.createElement(r.Stack,{space:"small"},l.createElement(o.Text,{weight:"bold"},f," "),l.createElement(o.Text,null,b)):l.createElement(o.Text,null,f)),x?l.createElement(m,null,u(x)?l.createElement(a.Button,{variant:"tertiary",size:"small",onClick:x.onClick},x.label):x):null,j?l.createElement(m,null,l.createElement(a.IconButton,{variant:"quaternary",size:"small",onClick:j,"aria-label":E,icon:l.createElement(i.CloseIcon,null)})):null)})),exports.isActionObject=u;
|
|
2
2
|
//# sourceMappingURL=static-toast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-toast.js","sources":["../../src/toast/static-toast.tsx"],"sourcesContent":["import React from 'react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Box } from '../box'\nimport { Button } from '../button'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\n\nimport styles from './toast.module.css'\n\ntype ToastActionObject = {\n label: string\n onClick: () => void\n}\n\ntype StaticToastProps = {\n /**\n * The message shown in the toast.\n */\n message: NonNullable<React.ReactNode>\n\n /**\n * An optional extra description that complements the main message shown in the toast.\n */\n description?: React.ReactNode\n\n /**\n * An icon to be shown in front of the message.\n */\n icon?: React.ReactNode\n\n /**\n * The action to call when the user clicks on the dismiss button. If omitted, the dismiss button\n * does not appear.\n */\n onDismiss?: () => void\n\n /**\n * The label for the button that dismisses the toast.\n */\n dismissLabel?: string\n\n /**\n * What to render in the action slot. Usually a button or link.\n *\n * You can also pass an object that containst the action label, and a function that performs the\n * action. This is used by the toast component to render a button for you.\n *\n * In general, you should prefer the action object most of the time. But it is possible to pass\n * a React element instead, if you need more control over what to render. For instance, you may\n * want to render a link instead of a button.\n *\n * Keep in mind, though, that the default button rendered uses `variant=\"tertiary\"` and\n * `size=\"small\"`. In most cases you should stick to the variants `tertiary` or `primary`, which\n * are the ones that look better in the toast's dark background. And in all cases you should use\n * size `small`.\n */\n action?: React.ReactElement | ToastActionObject\n}\n\n/**\n * A toast that shows a message, and an optional action associated with it.\n *\n * This component is generally not meant to be used directly. Most of the time you'll want to use\n * toasts generated via `useToasts` instead. However, this component is available in case you need\n * to take control of rendering a toast under different circumstances than that of notification-like\n * floating toasts.\n *\n * This component makes no assumptions outwardly about how it is positioned on the screen. That is,\n * it will not be shown floating or fixed to the viewport edges, as toasts normally show up. It only\n * provides the toast look and feel, but you are responsible for positioning it as you want.\n *\n * @see useToasts\n */\nconst StaticToast = React.forwardRef<HTMLDivElement, StaticToastProps>(function Toast(\n { message, description, icon, action, onDismiss, dismissLabel = 'Close', ...props },\n ref,\n) {\n return (\n <Box\n ref={ref}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n width=\"fitContent\"\n background=\"toast\"\n display=\"flex\"\n padding=\"large\"\n alignItems=\"center\"\n className={styles.toastContainer}\n {...props}\n >\n {icon ? <ToastContentSlot>{icon}</ToastContentSlot> : null}\n\n <Box flexGrow={1} maxWidth=\"small\">\n {description ? (\n <Stack space=\"small\">\n <Text weight=\"bold\">{message} </Text>\n <Text>{description}</Text>\n </Stack>\n ) : (\n <Text>{message}</Text>\n )}\n </Box>\n\n {action ? (\n <ToastContentSlot>\n {isActionObject(action) ? (\n <Button variant=\"tertiary\" size=\"small\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : (\n action\n )}\n </ToastContentSlot>\n ) : null}\n\n {onDismiss ? (\n <ToastContentSlot>\n <
|
|
1
|
+
{"version":3,"file":"static-toast.js","sources":["../../src/toast/static-toast.tsx"],"sourcesContent":["import React from 'react'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Box } from '../box'\nimport { IconButton, Button } from '../button'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\n\nimport styles from './toast.module.css'\n\ntype ToastActionObject = {\n label: string\n onClick: () => void\n}\n\ntype StaticToastProps = {\n /**\n * The message shown in the toast.\n */\n message: NonNullable<React.ReactNode>\n\n /**\n * An optional extra description that complements the main message shown in the toast.\n */\n description?: React.ReactNode\n\n /**\n * An icon to be shown in front of the message.\n */\n icon?: React.ReactNode\n\n /**\n * The action to call when the user clicks on the dismiss button. If omitted, the dismiss button\n * does not appear.\n */\n onDismiss?: () => void\n\n /**\n * The label for the button that dismisses the toast.\n */\n dismissLabel?: string\n\n /**\n * What to render in the action slot. Usually a button or link.\n *\n * You can also pass an object that containst the action label, and a function that performs the\n * action. This is used by the toast component to render a button for you.\n *\n * In general, you should prefer the action object most of the time. But it is possible to pass\n * a React element instead, if you need more control over what to render. For instance, you may\n * want to render a link instead of a button.\n *\n * Keep in mind, though, that the default button rendered uses `variant=\"tertiary\"` and\n * `size=\"small\"`. In most cases you should stick to the variants `tertiary` or `primary`, which\n * are the ones that look better in the toast's dark background. And in all cases you should use\n * size `small`.\n */\n action?: React.ReactElement | ToastActionObject\n}\n\n/**\n * A toast that shows a message, and an optional action associated with it.\n *\n * This component is generally not meant to be used directly. Most of the time you'll want to use\n * toasts generated via `useToasts` instead. However, this component is available in case you need\n * to take control of rendering a toast under different circumstances than that of notification-like\n * floating toasts.\n *\n * This component makes no assumptions outwardly about how it is positioned on the screen. That is,\n * it will not be shown floating or fixed to the viewport edges, as toasts normally show up. It only\n * provides the toast look and feel, but you are responsible for positioning it as you want.\n *\n * @see useToasts\n */\nconst StaticToast = React.forwardRef<HTMLDivElement, StaticToastProps>(function Toast(\n { message, description, icon, action, onDismiss, dismissLabel = 'Close', ...props },\n ref,\n) {\n return (\n <Box\n ref={ref}\n role=\"alert\"\n aria-live=\"polite\"\n borderRadius=\"full\"\n width=\"fitContent\"\n background=\"toast\"\n display=\"flex\"\n padding=\"large\"\n alignItems=\"center\"\n className={styles.toastContainer}\n {...props}\n >\n {icon ? <ToastContentSlot>{icon}</ToastContentSlot> : null}\n\n <Box flexGrow={1} maxWidth=\"small\">\n {description ? (\n <Stack space=\"small\">\n <Text weight=\"bold\">{message} </Text>\n <Text>{description}</Text>\n </Stack>\n ) : (\n <Text>{message}</Text>\n )}\n </Box>\n\n {action ? (\n <ToastContentSlot>\n {isActionObject(action) ? (\n <Button variant=\"tertiary\" size=\"small\" onClick={action.onClick}>\n {action.label}\n </Button>\n ) : (\n action\n )}\n </ToastContentSlot>\n ) : null}\n\n {onDismiss ? (\n <ToastContentSlot>\n <IconButton\n variant=\"quaternary\"\n size=\"small\"\n onClick={onDismiss}\n aria-label={dismissLabel}\n icon={<CloseIcon />}\n />\n </ToastContentSlot>\n ) : null}\n </Box>\n )\n})\n\nfunction isActionObject(action: StaticToastProps['action']): action is ToastActionObject {\n return (\n action != null &&\n typeof action === 'object' &&\n 'label' in action &&\n 'onClick' in action &&\n typeof action.label === 'string' &&\n typeof action.onClick === 'function'\n )\n}\n\nfunction ToastContentSlot({ children }: { children: React.ReactNode }) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n justifyContent=\"center\"\n marginX=\"-xsmall\"\n marginY=\"-medium\"\n className={styles.slot}\n >\n {children}\n </Box>\n )\n}\n\nexport { StaticToast, isActionObject }\nexport type { StaticToastProps }\n"],"names":["isActionObject","action","label","onClick","ToastContentSlot","children","React","Box","display","alignItems","justifyContent","marginX","marginY","className","styles","slot","forwardRef","ref","message","description","icon","onDismiss","dismissLabel","props","role","borderRadius","width","background","padding","toastContainer","flexGrow","maxWidth","Stack","space","Text","weight","Button","variant","size","IconButton","CloseIcon"],"mappings":"kdAoIA,SAASA,EAAeC,GACpB,OACc,MAAVA,GACkB,iBAAXA,GACP,UAAWA,GACX,YAAaA,GACW,iBAAjBA,EAAOC,OACY,mBAAnBD,EAAOE,QAItB,SAASC,GAAiBC,SAAEA,IACxB,OACIC,gBAACC,OACGC,QAAQ,OACRC,WAAW,SACXC,eAAe,SACfC,QAAQ,UACRC,QAAQ,UACRC,UAAWC,UAAOC,MAEjBV,uBA/EOC,EAAMU,YAA6C,WAEnEC,OADAC,QAAEA,EAAFC,YAAWA,EAAXC,KAAwBA,EAAxBnB,OAA8BA,EAA9BoB,UAAsCA,EAAtCC,aAAiDA,EAAe,WAAYC,iCAG5E,OACIjB,gBAACC,uBACGU,IAAKA,EACLO,KAAK,oBACK,SACVC,aAAa,OACbC,MAAM,aACNC,WAAW,QACXnB,QAAQ,OACRoB,QAAQ,QACRnB,WAAW,SACXI,UAAWC,UAAOe,gBACdN,GAEHH,EAAOd,gBAACF,OAAkBgB,GAA2B,KAEtDd,gBAACC,OAAIuB,SAAU,EAAGC,SAAS,SACtBZ,EACGb,gBAAC0B,SAAMC,MAAM,SACT3B,gBAAC4B,QAAKC,OAAO,QAAQjB,OACrBZ,gBAAC4B,YAAMf,IAGXb,gBAAC4B,YAAMhB,IAIdjB,EACGK,gBAACF,OACIJ,EAAeC,GACZK,gBAAC8B,UAAOC,QAAQ,WAAWC,KAAK,QAAQnC,QAASF,EAAOE,SACnDF,EAAOC,OAGZD,GAGR,KAEHoB,EACGf,gBAACF,OACGE,gBAACiC,cACGF,QAAQ,aACRC,KAAK,QACLnC,QAASkB,eACGC,EACZF,KAAMd,gBAACkC,qBAGf"}
|
|
@@ -78,7 +78,7 @@ declare type ToastsProviderProps = {
|
|
|
78
78
|
*
|
|
79
79
|
* @see useToasts
|
|
80
80
|
*/
|
|
81
|
-
declare function ToastsProvider({ children, padding, defaultAutoDismissDelay, defaultDismissLabel, containerClassName, }: ToastsProviderProps): JSX.Element;
|
|
81
|
+
declare function ToastsProvider({ children, padding, defaultAutoDismissDelay, defaultDismissLabel, containerClassName, }: ToastsProviderProps): React.JSX.Element;
|
|
82
82
|
/**
|
|
83
83
|
* Provides a function `showToast` that shows a new toast every time you call it.
|
|
84
84
|
*
|
package/lib/tooltip/tooltip.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { TooltipStoreState } from '@ariakit/react';
|
|
3
|
-
|
|
3
|
+
import type { ObfuscatedClassName } from '../utils/common-types';
|
|
4
|
+
interface TooltipProps extends ObfuscatedClassName {
|
|
4
5
|
/**
|
|
5
6
|
* The element that triggers the tooltip. Generally a button or link.
|
|
6
7
|
*
|
|
@@ -49,11 +50,7 @@ declare type TooltipProps = {
|
|
|
49
50
|
* @default false
|
|
50
51
|
*/
|
|
51
52
|
withArrow?: boolean;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
exceptionallySetClassName?: string;
|
|
56
|
-
};
|
|
57
|
-
declare function Tooltip({ children, content, position, gapSize, withArrow, exceptionallySetClassName, }: TooltipProps): JSX.Element | null;
|
|
53
|
+
}
|
|
54
|
+
declare function Tooltip({ children, content, position, gapSize, withArrow, exceptionallySetClassName, }: TooltipProps): React.JSX.Element | null;
|
|
58
55
|
export type { TooltipProps };
|
|
59
56
|
export { Tooltip };
|
package/lib/tooltip/tooltip.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../box/box.js"),r=require("@ariakit/react"),o=require("./tooltip.module.css.js");exports.Tooltip=function({children:n,content:i,position:l="top",gapSize:a=3,withArrow:s=!1,exceptionallySetClassName:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../box/box.js"),r=require("@ariakit/react"),o=require("./tooltip.module.css.js");exports.Tooltip=function({children:n,content:i,position:l="top",gapSize:a=3,withArrow:s=!1,exceptionallySetClassName:d}){const u=r.useTooltipStore({placement:l,showTimeout:500,hideTimeout:100}),c=u.useState("open"),p=e.Children.only(n);if(!p)return p;if("string"==typeof p.ref)throw new Error("Tooltip: String refs cannot be used as they cannot be forwarded");return e.createElement(e.Fragment,null,e.createElement(r.TooltipAnchor,{render:p,store:u,ref:p.ref}),c&&i?e.createElement(r.Tooltip,{store:u,gutter:a,render:e.createElement(t.Box,{className:[o.default.tooltip,d],background:"toast",borderRadius:"standard",paddingX:"small",paddingY:"xsmall",maxWidth:"medium",width:"fitContent",overflow:"hidden",textAlign:"center"})},s?e.createElement(r.TooltipArrow,null):null,"function"==typeof i?i():i):null)};
|
|
2
2
|
//# sourceMappingURL=tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\n\
|
|
1
|
+
{"version":3,"file":"tooltip.js","sources":["../../src/tooltip/tooltip.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n useTooltipStore,\n Tooltip as AriakitTooltip,\n TooltipAnchor,\n TooltipArrow,\n} from '@ariakit/react'\nimport { Box } from '../box'\n\nimport type { TooltipStoreState } from '@ariakit/react'\n\nimport styles from './tooltip.module.css'\nimport type { ObfuscatedClassName } from '../utils/common-types'\n\ninterface TooltipProps extends ObfuscatedClassName {\n /**\n * The element that triggers the tooltip. Generally a button or link.\n *\n * It should be an interactive element accessible both via mouse and keyboard interactions.\n */\n children: React.ReactNode\n\n /**\n * The content to show in the tooltip.\n *\n * It can be rich content provided via React elements, or string content. It should not include\n * interactive elements inside it. This includes links or buttons.\n *\n * You can provide a function instead of the content itself. In this case, the function should\n * return the desired content. This is useful if the content is expensive to generate. It can\n * also be useful if the content dynamically changes often, so every time you trigger the\n * tooltip the content may have changed (e.g. if you show a ticking time clock in the tooltip).\n *\n * The trigger element will be associated to this content via `aria-describedby`. This means\n * that the tooltip content will be read by assistive technologies such as screen readers. It\n * will likely read this content right after reading the trigger element label.\n */\n content: React.ReactNode | (() => React.ReactNode)\n\n /**\n * How to place the tooltip relative to its trigger element.\n *\n * The possible values are \"top\", \"bottom\", \"left\", \"right\". Additionally, any of these values\n * can be combined with `-start` or `-end` for even more control. For instance `top-start` will\n * place the tooltip at the top, but with the start (e.g. left) side of the toolip and the\n * trigger aligned. If neither `-start` or `-end` are provided, the tooltip is centered along\n * the vertical or horizontal axis with the trigger.\n *\n * The position is enforced whenever possible, but tooltips can appear in different positions\n * if the specified one would make the tooltip intersect with the viewport edges.\n *\n * @default 'top'\n */\n position?: TooltipStoreState['placement']\n\n /**\n * The separation (in pixels) between the trigger element and the tooltip.\n * @default 3\n */\n gapSize?: number\n\n /**\n * Whether to show an arrow-like element attached to the tooltip, and pointing towards the\n * trigger element.\n * @default false\n */\n withArrow?: boolean\n}\n\nfunction Tooltip({\n children,\n content,\n position = 'top',\n gapSize = 3,\n withArrow = false,\n exceptionallySetClassName,\n}: TooltipProps) {\n const tooltip = useTooltipStore({ placement: position, showTimeout: 500, hideTimeout: 100 })\n const isOpen = tooltip.useState('open')\n\n const child = React.Children.only(\n children as React.FunctionComponentElement<JSX.IntrinsicElements['div']> | null,\n )\n\n if (!child) {\n return child\n }\n\n if (typeof child.ref === 'string') {\n throw new Error('Tooltip: String refs cannot be used as they cannot be forwarded')\n }\n\n return (\n <>\n <TooltipAnchor render={child} store={tooltip} ref={child.ref} />\n {isOpen && content ? (\n <AriakitTooltip\n store={tooltip}\n gutter={gapSize}\n render={\n <Box\n className={[styles.tooltip, exceptionallySetClassName]}\n background=\"toast\"\n borderRadius=\"standard\"\n paddingX=\"small\"\n paddingY=\"xsmall\"\n maxWidth=\"medium\"\n width=\"fitContent\"\n overflow=\"hidden\"\n textAlign=\"center\"\n />\n }\n >\n {withArrow ? <TooltipArrow /> : null}\n {typeof content === 'function' ? content() : content}\n </AriakitTooltip>\n ) : null}\n </>\n )\n}\n\nexport type { TooltipProps }\nexport { Tooltip }\n"],"names":["children","content","position","gapSize","withArrow","exceptionallySetClassName","tooltip","useTooltipStore","placement","showTimeout","hideTimeout","isOpen","useState","child","React","only","ref","Error","TooltipAnchor","render","store","AriakitTooltip","gutter","Box","className","styles","background","borderRadius","paddingX","paddingY","maxWidth","width","overflow","textAlign","TooltipArrow"],"mappings":"uMAsEA,UAAiBA,SACbA,EADaC,QAEbA,EAFaC,SAGbA,EAAW,MAHEC,QAIbA,EAAU,EAJGC,UAKbA,GAAY,EALCC,0BAMbA,IAEA,MAAMC,EAAUC,kBAAgB,CAAEC,UAAWN,EAAUO,YAAa,IAAKC,YAAa,MAChFC,EAASL,EAAQM,SAAS,QAE1BC,EAAQC,WAAeC,KACzBf,GAGJ,IAAKa,EACD,OAAOA,EAGX,GAAyB,iBAAdA,EAAMG,IACb,MAAM,IAAIC,MAAM,mEAGpB,OACIH,gCACIA,gBAACI,iBAAcC,OAAQN,EAAOO,MAAOd,EAASU,IAAKH,EAAMG,MACxDL,GAAUV,EACPa,gBAACO,WACGD,MAAOd,EACPgB,OAAQnB,EACRgB,OACIL,gBAACS,OACGC,UAAW,CAACC,UAAOnB,QAASD,GAC5BqB,WAAW,QACXC,aAAa,WACbC,SAAS,QACTC,SAAS,SACTC,SAAS,SACTC,MAAM,aACNC,SAAS,SACTC,UAAU,YAIjB7B,EAAYU,gBAACoB,qBAAkB,KACZ,mBAAZjC,EAAyBA,IAAYA,GAEjD"}
|
|
@@ -20,4 +20,23 @@ export interface OpenInNewTab {
|
|
|
20
20
|
target?: never;
|
|
21
21
|
rel?: never;
|
|
22
22
|
}
|
|
23
|
+
export declare type ObfuscatedClassName = {
|
|
24
|
+
/**
|
|
25
|
+
* Used internally to set the `className` prop of the main container element for this component.
|
|
26
|
+
*
|
|
27
|
+
* Aside from the different name, the prop behaves the same as the native `className`. The only
|
|
28
|
+
* reason for the name change is to discourage applying custom CSS to the design system
|
|
29
|
+
* components, which are supposed to _eventually_ provide all the styling features we may need.
|
|
30
|
+
*
|
|
31
|
+
* This prop is meant to be used only in certain circumstances, when you really need a escape
|
|
32
|
+
* hatch to apply custom styles to a component. Before reaching for this feature, try harder to
|
|
33
|
+
* see if you can solve your needs with what the design system provides.
|
|
34
|
+
*
|
|
35
|
+
* For instance, instead of applying layout-related styles to a non-layout component, consider
|
|
36
|
+
* wrapping it inside a layout component.
|
|
37
|
+
*
|
|
38
|
+
* @see PolymorphicComponent
|
|
39
|
+
*/
|
|
40
|
+
exceptionallySetClassName?: string;
|
|
41
|
+
};
|
|
23
42
|
export {};
|