@lidofinance/lido-app-ui 1.14.0 → 1.15.0
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/README.md +22 -1
- package/dist/README.md +22 -1
- package/dist/cjs/breadcrumbs/Breadcrumbs.cjs +10 -3
- package/dist/cjs/breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/cjs/button/Button.cjs +7 -7
- package/dist/cjs/button/Button.cjs.map +1 -1
- package/dist/cjs/button/ButtonContent.cjs +0 -2
- package/dist/cjs/button/ButtonContent.cjs.map +1 -1
- package/dist/cjs/button/LinkButton.cjs +6 -35
- package/dist/cjs/button/LinkButton.cjs.map +1 -1
- package/dist/cjs/counter/Counter.module.css.cjs +1 -1
- package/dist/cjs/disclaimer/Disclaimer.cjs +0 -1
- package/dist/cjs/disclaimer/Disclaimer.cjs.map +1 -1
- package/dist/cjs/icon-button/CloseButton.cjs.map +1 -1
- package/dist/cjs/icon-button/IconButton.cjs +7 -7
- package/dist/cjs/icon-button/IconButton.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.css +10 -4
- package/dist/cjs/info-tooltip/InfoTooltip.cjs +4 -4
- package/dist/cjs/info-tooltip/InfoTooltip.cjs.map +1 -1
- package/dist/cjs/info-tooltip/InfoTooltip.module.css.cjs +1 -1
- package/dist/cjs/link-provider/Anchor.cjs +19 -6
- package/dist/cjs/link-provider/Anchor.cjs.map +1 -1
- package/dist/cjs/link-provider/LinkProvider.cjs +1 -1
- package/dist/cjs/link-provider/LinkProvider.cjs.map +1 -1
- package/dist/cjs/logo/Logo.cjs.map +1 -1
- package/dist/cjs/nav-link/NavLink.cjs +7 -3
- package/dist/cjs/nav-link/NavLink.cjs.map +1 -1
- package/dist/cjs/rich-input/RichInput.cjs +23 -3
- package/dist/cjs/rich-input/RichInput.cjs.map +1 -1
- package/dist/cjs/rich-input/RichInput.module.css.cjs +1 -1
- package/dist/cjs/sidebar/SidebarToggle.cjs.map +1 -1
- package/dist/cjs/small-card/SmallCard.cjs.map +1 -1
- package/dist/cjs/tag/Tag.cjs.map +1 -1
- package/dist/cjs/tag/Tag.module.css.cjs +1 -1
- package/dist/cjs/text-link/TextLink.cjs +1 -3
- package/dist/cjs/text-link/TextLink.cjs.map +1 -1
- package/dist/cjs/theme-switcher/ThemeSwitcher.cjs.map +1 -1
- package/dist/cjs/typography/Typography.cjs +21 -8
- package/dist/cjs/typography/Typography.cjs.map +1 -1
- package/dist/cjs/typography/Typography.module.css.cjs +1 -1
- package/dist/cjs/utils/ActionElement.cjs +1 -1
- package/dist/cjs/utils/ActionElement.cjs.map +1 -1
- package/dist/cjs/utils/joinAriaLabel.cjs +8 -0
- package/dist/cjs/utils/joinAriaLabel.cjs.map +1 -0
- package/dist/esm/breadcrumbs/Breadcrumbs.mjs +10 -3
- package/dist/esm/breadcrumbs/Breadcrumbs.mjs.map +1 -1
- package/dist/esm/button/Button.mjs +7 -7
- package/dist/esm/button/Button.mjs.map +1 -1
- package/dist/esm/button/ButtonContent.mjs +1 -2
- package/dist/esm/button/ButtonContent.mjs.map +1 -1
- package/dist/esm/button/LinkButton.mjs +6 -35
- package/dist/esm/button/LinkButton.mjs.map +1 -1
- package/dist/esm/counter/Counter.module.css.mjs +1 -1
- package/dist/esm/disclaimer/Disclaimer.mjs +0 -1
- package/dist/esm/disclaimer/Disclaimer.mjs.map +1 -1
- package/dist/esm/icon-button/CloseButton.mjs.map +1 -1
- package/dist/esm/icon-button/IconButton.mjs +7 -7
- package/dist/esm/icon-button/IconButton.mjs.map +1 -1
- package/dist/esm/index.css +10 -4
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/info-tooltip/InfoTooltip.mjs +4 -4
- package/dist/esm/info-tooltip/InfoTooltip.mjs.map +1 -1
- package/dist/esm/info-tooltip/InfoTooltip.module.css.mjs +1 -1
- package/dist/esm/link-provider/Anchor.mjs +19 -7
- package/dist/esm/link-provider/Anchor.mjs.map +1 -1
- package/dist/esm/link-provider/LinkProvider.mjs +1 -1
- package/dist/esm/link-provider/LinkProvider.mjs.map +1 -1
- package/dist/esm/logo/Logo.mjs.map +1 -1
- package/dist/esm/nav-link/NavLink.mjs +8 -4
- package/dist/esm/nav-link/NavLink.mjs.map +1 -1
- package/dist/esm/rich-input/RichInput.mjs +23 -3
- package/dist/esm/rich-input/RichInput.mjs.map +1 -1
- package/dist/esm/rich-input/RichInput.module.css.mjs +1 -1
- package/dist/esm/sidebar/SidebarToggle.mjs.map +1 -1
- package/dist/esm/small-card/SmallCard.mjs.map +1 -1
- package/dist/esm/tag/Tag.mjs.map +1 -1
- package/dist/esm/tag/Tag.module.css.mjs +1 -1
- package/dist/esm/text-link/TextLink.mjs +1 -3
- package/dist/esm/text-link/TextLink.mjs.map +1 -1
- package/dist/esm/theme-switcher/ThemeSwitcher.mjs.map +1 -1
- package/dist/esm/typography/Typography.mjs +19 -9
- package/dist/esm/typography/Typography.mjs.map +1 -1
- package/dist/esm/typography/Typography.module.css.mjs +1 -1
- package/dist/esm/utils/ActionElement.mjs +1 -1
- package/dist/esm/utils/ActionElement.mjs.map +1 -1
- package/dist/esm/utils/joinAriaLabel.mjs +4 -0
- package/dist/esm/utils/joinAriaLabel.mjs.map +1 -0
- package/dist/index.css +10 -4
- package/dist/styles/typography-mixins.css +14 -4
- package/dist/types/breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/dist/types/breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/dist/types/button/Button.d.ts +4 -10
- package/dist/types/button/Button.d.ts.map +1 -1
- package/dist/types/button/ButtonContent.d.ts +0 -1
- package/dist/types/button/ButtonContent.d.ts.map +1 -1
- package/dist/types/button/LinkButton.d.ts +9 -8
- package/dist/types/button/LinkButton.d.ts.map +1 -1
- package/dist/types/button/index.d.ts +1 -1
- package/dist/types/button/index.d.ts.map +1 -1
- package/dist/types/button/types.d.ts +4 -0
- package/dist/types/button/types.d.ts.map +1 -1
- package/dist/types/icon-button/CloseButton.d.ts +3 -3
- package/dist/types/icon-button/CloseButton.d.ts.map +1 -1
- package/dist/types/icon-button/IconButton.d.ts +4 -38
- package/dist/types/icon-button/IconButton.d.ts.map +1 -1
- package/dist/types/icon-button/index.d.ts +1 -1
- package/dist/types/icon-button/index.d.ts.map +1 -1
- package/dist/types/icon-button/types.d.ts +26 -0
- package/dist/types/icon-button/types.d.ts.map +1 -0
- package/dist/types/info-tooltip/InfoTooltip.d.ts +4 -1
- package/dist/types/info-tooltip/InfoTooltip.d.ts.map +1 -1
- package/dist/types/link-provider/Anchor.d.ts +3 -2
- package/dist/types/link-provider/Anchor.d.ts.map +1 -1
- package/dist/types/link-provider/LinkProvider.d.ts +1 -1
- package/dist/types/link-provider/LinkProvider.d.ts.map +1 -1
- package/dist/types/logo/Logo.d.ts +3 -6
- package/dist/types/logo/Logo.d.ts.map +1 -1
- package/dist/types/nav-link/NavLink.d.ts +2 -2
- package/dist/types/nav-link/NavLink.d.ts.map +1 -1
- package/dist/types/rich-input/RichInput.d.ts +7 -2
- package/dist/types/rich-input/RichInput.d.ts.map +1 -1
- package/dist/types/sidebar/SidebarToggle.d.ts +3 -3
- package/dist/types/sidebar/SidebarToggle.d.ts.map +1 -1
- package/dist/types/small-card/SmallCard.d.ts +2 -8
- package/dist/types/small-card/SmallCard.d.ts.map +1 -1
- package/dist/types/tag/Tag.d.ts +3 -1
- package/dist/types/tag/Tag.d.ts.map +1 -1
- package/dist/types/text-link/TextLink.d.ts +3 -9
- package/dist/types/text-link/TextLink.d.ts.map +1 -1
- package/dist/types/theme-switcher/ThemeSwitcher.d.ts +3 -3
- package/dist/types/theme-switcher/ThemeSwitcher.d.ts.map +1 -1
- package/dist/types/typography/Typography.d.ts +15 -6
- package/dist/types/typography/Typography.d.ts.map +1 -1
- package/dist/types/utils/ActionElement.d.ts +11 -1
- package/dist/types/utils/ActionElement.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/joinAriaLabel.d.ts +2 -0
- package/dist/types/utils/joinAriaLabel.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -7,32 +7,44 @@ const LinkProvider = require('./LinkProvider.cjs');
|
|
|
7
7
|
const jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
|
|
9
9
|
const ABSOLUTE_URL = /^([a-z][a-z\d+.-]*:|\/\/)/i;
|
|
10
|
-
const
|
|
10
|
+
const WEB_URL = /^(https?:)?\/\//i;
|
|
11
|
+
const opensInNewTab = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
href,
|
|
14
|
+
target,
|
|
15
|
+
external
|
|
16
|
+
} = _ref;
|
|
17
|
+
return external ?? (target === undefined && href !== undefined && WEB_URL.test(href));
|
|
18
|
+
};
|
|
19
|
+
const pickLink = (_ref2, href, _ref3) => {
|
|
11
20
|
let {
|
|
12
21
|
component,
|
|
13
22
|
externalComponent
|
|
14
|
-
} =
|
|
23
|
+
} = _ref2;
|
|
15
24
|
let {
|
|
16
25
|
target,
|
|
17
26
|
download
|
|
18
|
-
} =
|
|
27
|
+
} = _ref3;
|
|
19
28
|
if (ABSOLUTE_URL.test(href)) return externalComponent;
|
|
20
29
|
if (href.startsWith('#') || target && target !== '_self' || download != null && download !== false) return undefined;
|
|
21
30
|
return component;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
/** `<a>` that hands in-app hrefs to `LinkProvider`'s `component` and absolute URLs to its `externalComponent`. */
|
|
25
|
-
const Anchor = /*#__PURE__*/react.forwardRef((
|
|
34
|
+
const Anchor = /*#__PURE__*/react.forwardRef((_ref4, ref) => {
|
|
26
35
|
let {
|
|
27
36
|
external,
|
|
28
37
|
disabled,
|
|
29
38
|
linkProps,
|
|
30
39
|
...rest
|
|
31
|
-
} =
|
|
40
|
+
} = _ref4;
|
|
32
41
|
const links = LinkProvider.useLinkComponents();
|
|
33
42
|
const props = {
|
|
34
43
|
...rest,
|
|
35
|
-
...(
|
|
44
|
+
...(!disabled && opensInNewTab({
|
|
45
|
+
...rest,
|
|
46
|
+
external
|
|
47
|
+
}) && {
|
|
36
48
|
target: rest.target ?? '_blank',
|
|
37
49
|
rel: rest.rel ?? 'noopener noreferrer'
|
|
38
50
|
}),
|
|
@@ -66,4 +78,5 @@ const Anchor = /*#__PURE__*/react.forwardRef((_ref3, ref) => {
|
|
|
66
78
|
Anchor.displayName = 'Anchor';
|
|
67
79
|
|
|
68
80
|
exports.Anchor = Anchor;
|
|
81
|
+
exports.opensInNewTab = opensInNewTab;
|
|
69
82
|
//# sourceMappingURL=Anchor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Anchor.cjs","sources":["../../../src/link-provider/Anchor.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes } from 'react'\n\nimport {\n useLinkComponents,\n type LinkComponents,\n type LinkRouterProps,\n} from './LinkProvider'\n\nconst ABSOLUTE_URL = /^([a-z][a-z\\d+.-]*:|\\/\\/)/i\n\nexport type AnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /**
|
|
1
|
+
{"version":3,"file":"Anchor.cjs","sources":["../../../src/link-provider/Anchor.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes } from 'react'\n\nimport {\n useLinkComponents,\n type LinkComponents,\n type LinkRouterProps,\n} from './LinkProvider'\n\nconst ABSOLUTE_URL = /^([a-z][a-z\\d+.-]*:|\\/\\/)/i\nconst WEB_URL = /^(https?:)?\\/\\//i\n\nexport type AnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** @deprecated Absolute http(s) URLs open in a new tab automatically; pass `target` to override. */\n external?: boolean\n /** Renders an href-less `role='link'` with `aria-disabled`, and drops `onClick`. */\n disabled?: boolean\n /** Router-only props (e.g. `prefetch`), passed to `LinkProvider` components and never to a plain `<a>`. */\n linkProps?: LinkRouterProps\n}\n\nexport const opensInNewTab = ({\n href,\n target,\n external,\n}: Pick<AnchorProps, 'href' | 'target' | 'external'>) =>\n external ?? (target === undefined && href !== undefined && WEB_URL.test(href))\n\nconst pickLink = (\n { component, externalComponent }: LinkComponents,\n href: string,\n { target, download }: AnchorHTMLAttributes<HTMLAnchorElement>,\n) => {\n if (ABSOLUTE_URL.test(href)) return externalComponent\n if (\n href.startsWith('#') ||\n (target && target !== '_self') ||\n (download != null && download !== false)\n )\n return undefined\n return component\n}\n\n/** `<a>` that hands in-app hrefs to `LinkProvider`'s `component` and absolute URLs to its `externalComponent`. */\nexport const Anchor = forwardRef<HTMLAnchorElement, AnchorProps>(\n ({ external, disabled, linkProps, ...rest }, ref) => {\n const links = useLinkComponents()\n const props: AnchorHTMLAttributes<HTMLAnchorElement> = {\n ...rest,\n ...(!disabled &&\n opensInNewTab({ ...rest, external }) && {\n target: rest.target ?? '_blank',\n rel: rest.rel ?? 'noopener noreferrer',\n }),\n ...(disabled && {\n href: undefined,\n onClick: undefined,\n tabIndex: undefined,\n role: rest.role ?? 'link',\n 'aria-disabled': true,\n }),\n }\n const { href } = props\n\n if (href !== undefined) {\n const Link = pickLink(links, href, props)\n if (Link) return <Link ref={ref} {...props} {...linkProps} href={href} />\n }\n\n // eslint-disable-next-line jsx-a11y/anchor-has-content -- children arrive via props\n return <a ref={ref} {...props} />\n },\n)\n\nAnchor.displayName = 'Anchor'\n"],"names":["ABSOLUTE_URL","WEB_URL","opensInNewTab","_ref","href","target","external","undefined","test","pickLink","_ref2","_ref3","component","externalComponent","download","startsWith","Anchor","forwardRef","_ref4","ref","disabled","linkProps","rest","links","useLinkComponents","props","rel","onClick","tabIndex","role","Link","_jsx","displayName"],"mappings":";;;;;;;;AAQA,MAAMA,YAAY,GAAG,4BAA4B,CAAA;AACjD,MAAMC,OAAO,GAAG,kBAAkB,CAAA;AAW3B,MAAMC,aAAa,GAAGC,IAAA,IAAA;EAAA,IAAC;IAC5BC,IAAI;IACJC,MAAM;AACNC,IAAAA,QAAAA;AACiD,GAAC,GAAAH,IAAA,CAAA;AAAA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AC;AACJ,IAAA,IAAIN,QAAQ,IAAI;AACdhB,MAAAA,IAAI,EAAEG,SAAS;AACfoB,MAAAA,OAAO,EAAEpB,SAAS;AAClBqB,MAAAA,QAAQ,EAAErB,SAAS;AACnBsB,MAAAA,IAAI,EAAEP,IAAI,CAACO,IAAI,IAAI,MAAM;AACzB,MAAA,eAAe,EAAE,IAAA;KAClB,CAAA;GACF,CAAA;EACD,MAAM;AAAEzB,IAAAA,IAAAA;AAAK,GAAC,GAAGqB,KAAK,CAAA;EAEtB,IAAIrB,IAAI,KAAKG,SAAS,EAAE;IACtB,MAAMuB,IAAI,GAAGrB,QAAQ,CAACc,KAAK,EAAEnB,IAAI,EAAEqB,KAAK,CAAC,CAAA;AACzC,IAAA,IAAIK,IAAI,EAAE,oBAAOC,cAAA,CAACD,IAAI,EAAA;AAACX,MAAAA,GAAG,EAAEA,GAAI;AAAA,MAAA,GAAKM,KAAK;AAAA,MAAA,GAAMJ,SAAS;AAAEjB,MAAAA,IAAI,EAAEA,IAAAA;AAAK,KAAE,CAAC,CAAA;AAC3E,GAAA;;AAEA;AACA,EAAA,oBAAO2B,cAAA,CAAA,GAAA,EAAA;AAAGZ,IAAAA,GAAG,EAAEA,GAAI;IAAA,GAAKM,KAAAA;AAAK,GAAG,CAAC,CAAA;AACnC,CACF,EAAC;AAEDT,MAAM,CAACgB,WAAW,GAAG,QAAQ;;;;;"}
|
|
@@ -6,7 +6,7 @@ const react = require('react');
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
8
|
const LinkContext = /*#__PURE__*/react.createContext({});
|
|
9
|
-
/** Renders app-ui links with your components: `component` for in-app hrefs
|
|
9
|
+
/** Renders app-ui links with your components: `component` for in-app hrefs, `externalComponent` for absolute URLs. Both must be `forwardRef` components forwarding `ref` to an `<a>`, and stable module-level references, or every link remounts each render. */
|
|
10
10
|
const LinkProvider = _ref => {
|
|
11
11
|
let {
|
|
12
12
|
component,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkProvider.cjs","sources":["../../../src/link-provider/LinkProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useMemo,\n type AnchorHTMLAttributes,\n type ReactNode,\n type Ref,\n} from 'react'\n\n/** Augment via `declare module '@lidofinance/lido-app-ui'` to type router-only props (e.g. Next's `prefetch`), set per link with `linkProps`. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface LinkRouterProps {}\n\nexport type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> &\n LinkRouterProps & {\n href: string\n ref?: Ref<HTMLAnchorElement>\n }\n\n/** Wrap adapters in `forwardRef`: under React 18 `ref` arrives as the second argument, never as a prop. */\nexport type LinkComponent = (props: LinkComponentProps) => ReactNode\n\nexport type LinkComponents = {\n /** Renders in-app hrefs (relative, not hash, `download` or non-`_self` `target`). */\n component?: LinkComponent\n /** Renders absolute URLs, including `mailto:` and protocol-relative `//`. */\n externalComponent?: LinkComponent\n}\n\nconst LinkContext = createContext<LinkComponents>({})\n\nexport type LinkProviderProps = LinkComponents & {\n children?: ReactNode\n}\n\n/** Renders app-ui links with your components: `component` for in-app hrefs
|
|
1
|
+
{"version":3,"file":"LinkProvider.cjs","sources":["../../../src/link-provider/LinkProvider.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useMemo,\n type AnchorHTMLAttributes,\n type ReactNode,\n type Ref,\n} from 'react'\n\n/** Augment via `declare module '@lidofinance/lido-app-ui'` to type router-only props (e.g. Next's `prefetch`), set per link with `linkProps`. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface LinkRouterProps {}\n\nexport type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> &\n LinkRouterProps & {\n href: string\n ref?: Ref<HTMLAnchorElement>\n }\n\n/** Wrap adapters in `forwardRef`: under React 18 `ref` arrives as the second argument, never as a prop. */\nexport type LinkComponent = (props: LinkComponentProps) => ReactNode\n\nexport type LinkComponents = {\n /** Renders in-app hrefs (relative, not hash, `download` or non-`_self` `target`). */\n component?: LinkComponent\n /** Renders absolute URLs, including `mailto:` and protocol-relative `//`. */\n externalComponent?: LinkComponent\n}\n\nconst LinkContext = createContext<LinkComponents>({})\n\nexport type LinkProviderProps = LinkComponents & {\n children?: ReactNode\n}\n\n/** Renders app-ui links with your components: `component` for in-app hrefs, `externalComponent` for absolute URLs. Both must be `forwardRef` components forwarding `ref` to an `<a>`, and stable module-level references, or every link remounts each render. */\nexport const LinkProvider = ({\n component,\n externalComponent,\n children,\n}: LinkProviderProps) => {\n const value = useMemo(\n () => ({ component, externalComponent }),\n [component, externalComponent],\n )\n return <LinkContext.Provider value={value}>{children}</LinkContext.Provider>\n}\n\nexport const useLinkComponents = () => useContext(LinkContext)\n"],"names":["LinkContext","createContext","LinkProvider","_ref","component","externalComponent","children","value","useMemo","_jsx","Provider","useLinkComponents","useContext"],"mappings":";;;;;;;AA6BA,MAAMA,WAAW,gBAAGC,mBAAa,CAAiB,EAAE,CAAC,CAAA;AAMrD;AACaC,MAAAA,YAAY,GAAGC,IAAA,IAIH;EAAA,IAJI;IAC3BC,SAAS;IACTC,iBAAiB;AACjBC,IAAAA,QAAAA;AACiB,GAAC,GAAAH,IAAA,CAAA;AAClB,EAAA,MAAMI,KAAK,GAAGC,aAAO,CACnB,OAAO;IAAEJ,SAAS;AAAEC,IAAAA,iBAAAA;AAAkB,GAAC,CAAC,EACxC,CAACD,SAAS,EAAEC,iBAAiB,CAC/B,CAAC,CAAA;AACD,EAAA,oBAAOI,cAAA,CAACT,WAAW,CAACU,QAAQ,EAAA;AAACH,IAAAA,KAAK,EAAEA,KAAM;AAAAD,IAAAA,QAAA,EAAEA,QAAAA;AAAQ,GAAuB,CAAC,CAAA;AAC9E,EAAC;AAEM,MAAMK,iBAAiB,GAAGA,MAAMC,gBAAU,CAACZ,WAAW;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logo.cjs","sources":["../../../src/logo/Logo.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type HTMLAttributes,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport { ActionElement } from '../utils'\nimport styles from './Logo.module.css'\n\nexport type LogoVariant = 'full' | 'compact' | 'auto'\n\nexport type LogoDataTestId = { root?: string; product?: string }\n\nexport type LogoProps = Omit<HTMLAttributes<HTMLElement>, 'children'> &\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'target' | 'download'> & {\n /** `full` shows the wordmark, `compact` drops it, `auto` drops it below `--lido-app-ui-breakpoint-logo` (1024px), overridable per instance with `--lido-app-ui-logo-breakpoint`. */\n variant?: LogoVariant\n /** Product name shown after a divider and added to the accessible name. */\n product?: string\n /** Renders a link; with only `onClick` it renders a button, otherwise a plain `role=\"img\"` element. */\n href?: string\n
|
|
1
|
+
{"version":3,"file":"Logo.cjs","sources":["../../../src/logo/Logo.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type HTMLAttributes,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport type { AnchorProps } from '../link-provider/Anchor'\nimport { ActionElement } from '../utils'\nimport styles from './Logo.module.css'\n\nexport type LogoVariant = 'full' | 'compact' | 'auto'\n\nexport type LogoDataTestId = { root?: string; product?: string }\n\nexport type LogoProps = Omit<HTMLAttributes<HTMLElement>, 'children'> &\n Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'target' | 'download'> & {\n /** `full` shows the wordmark, `compact` drops it, `auto` drops it below `--lido-app-ui-breakpoint-logo` (1024px), overridable per instance with `--lido-app-ui-logo-breakpoint`. */\n variant?: LogoVariant\n /** Product name shown after a divider and added to the accessible name. */\n product?: string\n /** Renders a link; with only `onClick` it renders a button, otherwise a plain `role=\"img\"` element. */\n href?: string\n dataTestId?: LogoDataTestId\n } & Pick<AnchorProps, 'external'>\n\nconst DROPLET = (\n <svg\n className={styles.droplet}\n viewBox='38 26 23 32'\n fill='currentColor'\n aria-hidden='true'\n >\n <path\n fillRule='evenodd'\n clipRule='evenodd'\n d='M49.485 26L57.6 38.398l-8.116 4.613-8.117-4.613L49.485 26zM43.85 37.81l5.634-8.602 5.633 8.601-5.633 3.201-5.634-3.2z'\n />\n <path d='M49.478 45.736l-9.416-5.35-.255.39c-2.896 4.428-2.25 10.226 1.554 13.945 4.48 4.372 11.747 4.372 16.233 0 3.812-3.719 4.458-9.517 1.554-13.945l-.254-.39-9.416 5.35z' />\n </svg>\n)\n\nconst WORDMARK = (\n <span className={styles.wordmark}>\n <svg\n className={styles.wordmarkSvg}\n viewBox='61 26 101 32'\n fill='currentColor'\n aria-hidden='true'\n >\n <path d='M90.17 50.449H79.462V33.551h3.267v13.917h7.441v2.981zm16.422 0h-3.267V33.551h3.267V50.45zm13.242 0V33.551h5.597c.85 0 1.54.029 2.062.093 1.351.156 2.519.624 3.492 1.398.988.773 1.735 1.767 2.244 2.98.515 1.207.769 2.534.769 3.982 0 1.448-.254 2.775-.769 3.988-.516 1.207-1.264 2.193-2.244 2.967-.98.773-2.141 1.242-3.492 1.398-.53.064-1.219.092-2.062.092h-5.597zm5.597-3.002c.85 0 1.474-.043 1.873-.12a3.218 3.218 0 001.801-1.001 5.002 5.002 0 001.082-1.923 7.97 7.97 0 00.363-2.406 7.96 7.96 0 00-.371-2.442c-.239-.76-.602-1.398-1.096-1.916a3.123 3.123 0 00-1.779-.972c-.399-.078-1.023-.12-1.873-.12h-2.279V47.44h2.279v.007zm28.191 3.357c-1.707 0-3.188-.362-4.458-1.093a7.432 7.432 0 01-2.919-3.102c-.675-1.327-1.009-2.867-1.009-4.613 0-1.745.334-3.285 1.009-4.613.683-1.327 1.656-2.356 2.919-3.087 1.263-.738 2.751-1.1 4.458-1.1 1.706 0 3.187.37 4.457 1.1a7.27 7.27 0 012.904 3.087c.683 1.328 1.024 2.868 1.024 4.613 0 1.746-.341 3.286-1.024 4.613-.675 1.328-1.641 2.364-2.904 3.102-1.263.73-2.751 1.093-4.457 1.093zm.094-3.002c1.06 0 1.946-.242 2.664-.717.719-.476 1.264-1.15 1.619-2.016.363-.865.538-1.887.538-3.065 0-1.817-.422-3.237-1.271-4.259-.849-1.021-2.098-1.54-3.746-1.54-1.06 0-1.946.242-2.664.717-.719.476-1.264 1.15-1.619 2.016-.363.865-.538 1.887-.538 3.066 0 1.816.421 3.236 1.271 4.258.849 1.022 2.098 1.54 3.746 1.54z' />\n </svg>\n </span>\n)\n\n/** Lido droplet with wordmark and an optional product name. */\nexport const Logo = forwardRef<HTMLElement, LogoProps>(\n (\n {\n variant = 'full',\n product,\n href,\n external,\n onClick,\n className,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const label = product ? `Lido ${product}` : 'Lido'\n const content = (\n <>\n <span className={styles.mark}>\n {DROPLET}\n {variant === 'compact' ? null : WORDMARK}\n </span>\n {product ? (\n <>\n <span className={styles.divider} aria-hidden='true' />\n <span className={styles.product} data-testid={dataTestId?.product}>\n {product}\n </span>\n </>\n ) : null}\n </>\n )\n const classes = cn(styles.root, styles[variant], className)\n\n if (href || onClick) {\n return (\n <ActionElement\n ref={ref as Ref<HTMLAnchorElement | HTMLButtonElement>}\n className={cn(classes, styles.interactive)}\n aria-label={label}\n data-testid={dataTestId?.root}\n {...{\n href,\n external: href ? external : undefined,\n onClick,\n ...rest,\n }}\n >\n {content}\n </ActionElement>\n )\n }\n\n return (\n <span\n ref={ref as Ref<HTMLSpanElement>}\n role='img'\n aria-label={label}\n className={classes}\n data-testid={dataTestId?.root}\n {...rest}\n >\n {content}\n </span>\n )\n },\n)\n\nLogo.displayName = 'Logo'\n"],"names":["DROPLET","_jsxs","className","styles","droplet","viewBox","fill","children","_jsx","fillRule","clipRule","d","WORDMARK","wordmark","wordmarkSvg","Logo","forwardRef","_ref","ref","variant","product","href","external","onClick","dataTestId","rest","label","content","_Fragment","mark","divider","classes","cn","root","ActionElement","interactive","undefined","role","displayName"],"mappings":";;;;;;;;;;AA4BA,MAAMA,OAAO,gBACXC,eA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AACEU,IAAAA,GAAG,EAAEA,GAA4B;AACjCmB,IAAAA,IAAI,EAAC,KAAK;AACV,IAAA,YAAA,EAAYX,KAAM;AAClBxB,IAAAA,SAAS,EAAE6B,OAAQ;IACnB,aAAaP,EAAAA,UAAU,EAAES,IAAK;AAAA,IAAA,GAC1BR,IAAI;AAAAlB,IAAAA,QAAA,EAEPoB,OAAAA;AAAO,GACJ,CAAC,CAAA;AAEX,CACF,EAAC;AAEDZ,IAAI,CAACuB,WAAW,GAAG,MAAM;;;;"}
|
|
@@ -14,17 +14,21 @@ const NavLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
14
14
|
let {
|
|
15
15
|
active = false,
|
|
16
16
|
icon,
|
|
17
|
-
external
|
|
17
|
+
external,
|
|
18
18
|
className,
|
|
19
19
|
children,
|
|
20
20
|
dataTestId,
|
|
21
21
|
...rest
|
|
22
22
|
} = _ref;
|
|
23
|
+
const newTab = Anchor.opensInNewTab({
|
|
24
|
+
...rest,
|
|
25
|
+
external
|
|
26
|
+
});
|
|
23
27
|
return /*#__PURE__*/jsxRuntime.jsxs(Anchor.Anchor, {
|
|
24
28
|
ref: ref,
|
|
25
29
|
className: cn(NavLink_module.link, active && NavLink_module.active, className),
|
|
26
30
|
"aria-current": active ? 'page' : undefined,
|
|
27
|
-
external:
|
|
31
|
+
external: newTab,
|
|
28
32
|
"data-testid": dataTestId?.root,
|
|
29
33
|
...rest,
|
|
30
34
|
children: [icon != null ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
@@ -32,7 +36,7 @@ const NavLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
32
36
|
"aria-hidden": "true",
|
|
33
37
|
"data-testid": dataTestId?.icon,
|
|
34
38
|
children: icon
|
|
35
|
-
}) : null, children,
|
|
39
|
+
}) : null, children, newTab ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
36
40
|
className: NavLink_module.icon,
|
|
37
41
|
"aria-hidden": "true",
|
|
38
42
|
"data-testid": dataTestId?.externalIcon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavLink.cjs","sources":["../../../src/nav-link/NavLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconLink } from '../icons'\nimport {
|
|
1
|
+
{"version":3,"file":"NavLink.cjs","sources":["../../../src/nav-link/NavLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconLink } from '../icons'\nimport {\n Anchor,\n opensInNewTab,\n type AnchorProps,\n} from '../link-provider/Anchor'\nimport styles from './NavLink.module.css'\n\nexport type NavLinkDataTestId = {\n root?: string\n icon?: string\n externalIcon?: string\n}\n\nexport type NavLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** Marks the current page: sets `aria-current=\"page\"` and the active style. */\n active?: boolean\n /** Leading icon. */\n icon?: ReactNode\n /** @deprecated Absolute http(s) URLs open in a new tab with the arrow automatically; pass `target` to override. */\n external?: boolean\n linkProps?: AnchorProps['linkProps']\n dataTestId?: NavLinkDataTestId\n}\n\n/** Top-navigation link for a Header; pass `aria-current` for sections active on sub-routes (HeaderNav centers any truthy value). */\nexport const NavLink = forwardRef<HTMLAnchorElement, NavLinkProps>(\n (\n {\n active = false,\n icon,\n external,\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const newTab = opensInNewTab({ ...rest, external })\n return (\n <Anchor\n ref={ref}\n className={cn(styles.link, active && styles.active, className)}\n aria-current={active ? 'page' : undefined}\n external={newTab}\n data-testid={dataTestId?.root}\n {...rest}\n >\n {icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null}\n {children}\n {newTab ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.externalIcon}\n >\n <IconLink />\n </span>\n ) : null}\n </Anchor>\n )\n },\n)\n\nNavLink.displayName = 'NavLink'\n"],"names":["NavLink","forwardRef","_ref","ref","active","icon","external","className","children","dataTestId","rest","newTab","opensInNewTab","_jsxs","Anchor","cn","styles","link","undefined","root","_jsx","externalIcon","IconLink","displayName"],"mappings":";;;;;;;;;;;AA6BA;AACO,MAAMA,OAAO,gBAAGC,gBAAU,CAC/B,CAAAC,IAAA,EAUEC,GAAG,KACA;EAAA,IAVH;AACEC,IAAAA,MAAM,GAAG,KAAK;IACdC,IAAI;IACJC,QAAQ;IACRC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAR,IAAA,CAAA;EAGD,MAAMS,MAAM,GAAGC,oBAAa,CAAC;AAAE,IAAA,GAAGF,IAAI;AAAEJ,IAAAA,QAAAA;AAAS,GAAC,CAAC,CAAA;EACnD,oBACEO,eAAA,CAACC,aAAM,EAAA;AACLX,IAAAA,GAAG,EAAEA,GAAI;AACTI,IAAAA,SAAS,EAAEQ,EAAE,CAACC,cAAM,CAACC,IAAI,EAAEb,MAAM,IAAIY,cAAM,CAACZ,MAAM,EAAEG,SAAS,CAAE;AAC/D,IAAA,cAAA,EAAcH,MAAM,GAAG,MAAM,GAAGc,SAAU;AAC1CZ,IAAAA,QAAQ,EAAEK,MAAO;IACjB,aAAaF,EAAAA,UAAU,EAAEU,IAAK;AAAA,IAAA,GAC1BT,IAAI;AAAAF,IAAAA,QAAA,EAEPH,CAAAA,IAAI,IAAI,IAAI,gBACXe,cAAA,CAAA,MAAA,EAAA;MACEb,SAAS,EAAES,cAAM,CAACX,IAAK;AACvB,MAAA,aAAA,EAAY,MAAM;MAClB,aAAaI,EAAAA,UAAU,EAAEJ,IAAK;AAAAG,MAAAA,QAAA,EAE7BH,IAAAA;KACG,CAAC,GACL,IAAI,EACPG,QAAQ,EACRG,MAAM,gBACLS,cAAA,CAAA,MAAA,EAAA;MACEb,SAAS,EAAES,cAAM,CAACX,IAAK;AACvB,MAAA,aAAA,EAAY,MAAM;MAClB,aAAaI,EAAAA,UAAU,EAAEY,YAAa;AAAAb,MAAAA,QAAA,eAEtCY,cAAA,CAACE,iBAAQ,EAAE,EAAA,CAAA;KACP,CAAC,GACL,IAAI,CAAA;AAAA,GACF,CAAC,CAAA;AAEb,CACF,EAAC;AAEDtB,OAAO,CAACuB,WAAW,GAAG,SAAS;;;;"}
|
|
@@ -8,6 +8,7 @@ const RichInput_module = require('./RichInput.module.css.cjs');
|
|
|
8
8
|
const jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
const Tag = require('../tag/Tag.cjs');
|
|
10
10
|
const InfoTooltip = require('../info-tooltip/InfoTooltip.cjs');
|
|
11
|
+
const IconLockKeyhole = require('../icons/components/base/IconLockKeyhole.cjs');
|
|
11
12
|
const Tooltip = require('../tooltip/Tooltip.cjs');
|
|
12
13
|
|
|
13
14
|
// Keep only digits and a single decimal point; comma is treated as the
|
|
@@ -22,7 +23,7 @@ const sanitizeDecimal = raw => {
|
|
|
22
23
|
};
|
|
23
24
|
const noop = () => undefined;
|
|
24
25
|
|
|
25
|
-
/** Amount field for supply and borrow forms: token picker, fiat equivalent, balance and a Max shortcut in one card; input is filtered to decimals as you type. `disabled` dims the card and hides Max. */
|
|
26
|
+
/** Amount field for supply and borrow forms: token picker, fiat equivalent, balance and a Max shortcut in one card; input is filtered to decimals as you type. `disabled` dims the card and hides Max; `locked` makes it read-only without Max. */
|
|
26
27
|
const RichInput = _ref => {
|
|
27
28
|
let {
|
|
28
29
|
label,
|
|
@@ -41,6 +42,9 @@ const RichInput = _ref => {
|
|
|
41
42
|
className,
|
|
42
43
|
id,
|
|
43
44
|
disabled,
|
|
45
|
+
locked,
|
|
46
|
+
lockedTooltip,
|
|
47
|
+
readOnly,
|
|
44
48
|
dataTestId,
|
|
45
49
|
...inputProps
|
|
46
50
|
} = _ref;
|
|
@@ -50,7 +54,7 @@ const RichInput = _ref => {
|
|
|
50
54
|
const hasError = !!error;
|
|
51
55
|
const showErrorMessage = !!errorText;
|
|
52
56
|
const errorId = `${inputId}-error`;
|
|
53
|
-
const showMax = showMaxButton && !disabled;
|
|
57
|
+
const showMax = showMaxButton && !disabled && !locked;
|
|
54
58
|
const hasBottomRow = secondaryValue != null || balance != null || showMax;
|
|
55
59
|
const maxTag = /*#__PURE__*/jsxRuntime.jsx(Tag.Tag, {
|
|
56
60
|
as: "button",
|
|
@@ -90,7 +94,7 @@ const RichInput = _ref => {
|
|
|
90
94
|
className: cn(RichInput_module.root, className),
|
|
91
95
|
"data-testid": dataTestId?.root,
|
|
92
96
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
93
|
-
className: cn(RichInput_module.card, hasError && RichInput_module.error),
|
|
97
|
+
className: cn(RichInput_module.card, hasError && RichInput_module.error, locked && RichInput_module.locked),
|
|
94
98
|
onClick: handleRootClick,
|
|
95
99
|
children: [label != null ? /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
96
100
|
className: RichInput_module.labelRow,
|
|
@@ -102,6 +106,21 @@ const RichInput = _ref => {
|
|
|
102
106
|
}), labelTooltip != null ? /*#__PURE__*/jsxRuntime.jsx(InfoTooltip.InfoTooltip, {
|
|
103
107
|
content: labelTooltip,
|
|
104
108
|
size: 20
|
|
109
|
+
}) : null, locked ? lockedTooltip != null ? /*#__PURE__*/jsxRuntime.jsx(InfoTooltip.InfoTooltip, {
|
|
110
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(IconLockKeyhole.IconLockKeyhole, {
|
|
111
|
+
"aria-hidden": "true"
|
|
112
|
+
}),
|
|
113
|
+
size: 20,
|
|
114
|
+
"aria-label": "Locked",
|
|
115
|
+
content: lockedTooltip,
|
|
116
|
+
className: RichInput_module.lock,
|
|
117
|
+
dataTestId: {
|
|
118
|
+
root: dataTestId?.lock
|
|
119
|
+
}
|
|
120
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(IconLockKeyhole.IconLockKeyhole, {
|
|
121
|
+
"aria-hidden": "true",
|
|
122
|
+
className: cn(RichInput_module.lock, RichInput_module.lockIcon),
|
|
123
|
+
"data-testid": dataTestId?.lock
|
|
105
124
|
}) : null]
|
|
106
125
|
}) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
107
126
|
className: RichInput_module.amountRow,
|
|
@@ -111,6 +130,7 @@ const RichInput = _ref => {
|
|
|
111
130
|
className: RichInput_module.input,
|
|
112
131
|
inputMode: "decimal",
|
|
113
132
|
disabled: disabled,
|
|
133
|
+
readOnly: locked || readOnly,
|
|
114
134
|
"aria-invalid": hasError || undefined,
|
|
115
135
|
"aria-describedby": showErrorMessage ? errorId : undefined,
|
|
116
136
|
onChange: handleChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichInput.cjs","sources":["../../../src/rich-input/RichInput.tsx"],"sourcesContent":["import {\n useId,\n useRef,\n type ChangeEvent,\n type InputHTMLAttributes,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n} from 'react'\n\nimport cn from 'classnames'\nimport { InfoTooltip } from '../info-tooltip'\nimport { Tag } from '../tag'\nimport { Tooltip, type TooltipPosition } from '../tooltip'\n\nimport styles from './RichInput.module.css'\n\nexport type RichInputDataTestId = {\n root?: string\n label?: string\n input?: string\n secondaryValue?: string\n balance?: string\n maxButton?: string\n error?: string\n}\n\nexport type RichInputProps = InputHTMLAttributes<HTMLInputElement> & {\n label?: ReactNode\n labelTooltip?: ReactNode\n /** Fiat equivalent, bottom left. */\n secondaryValue?: ReactNode\n /** Wallet balance, bottom right. */\n balance?: ReactNode\n /** Slot for a `TokenSelector`. */\n tokenSelector?: ReactNode\n /** Marks the card invalid. */\n error?: boolean\n errorText?: ReactNode\n showMaxButton?: boolean\n onMaxClick?: MouseEventHandler<HTMLButtonElement>\n /** Dims the Max shortcut, leaving the field editable. */\n maxDisabled?: boolean\n /** Explains what Max actually fills in. */\n maxTooltip?: ReactNode\n maxTooltipPosition?: TooltipPosition\n dataTestId?: RichInputDataTestId\n}\n\n// Keep only digits and a single decimal point; comma is treated as the\n// decimal separator and normalized to a dot (en-US canonical form).\nconst sanitizeDecimal = (raw: string): string => {\n const normalized = raw.replace(/,/g, '.').replace(/[^\\d.]/g, '')\n const firstDot = normalized.indexOf('.')\n if (firstDot === -1) return normalized\n const head = normalized.slice(0, firstDot + 1)\n const tail = normalized.slice(firstDot + 1).replace(/\\./g, '')\n return head + tail\n}\n\nconst noop = () => undefined\n\n/** Amount field for supply and borrow forms: token picker, fiat equivalent, balance and a Max shortcut in one card; input is filtered to decimals as you type. `disabled` dims the card and hides Max. */\nexport const RichInput = ({\n label,\n labelTooltip,\n secondaryValue,\n balance,\n tokenSelector,\n error,\n errorText,\n showMaxButton = true,\n onMaxClick,\n maxDisabled,\n maxTooltip,\n maxTooltipPosition = 'bottom-left',\n onChange,\n className,\n id,\n disabled,\n dataTestId,\n ...inputProps\n}: RichInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const fallbackId = useId()\n const inputId = id ?? fallbackId\n\n const hasError = !!error\n const showErrorMessage = !!errorText\n const errorId = `${inputId}-error`\n const showMax = showMaxButton && !disabled\n const hasBottomRow = secondaryValue != null || balance != null || showMax\n\n const maxTag = (\n <Tag\n as='button'\n dataTestId={{ root: dataTestId?.maxButton }}\n onClick={onMaxClick ?? noop}\n disabled={maxDisabled}\n >\n Max\n </Tag>\n )\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: rawValue, selectionStart } = event.target\n const sanitized = sanitizeDecimal(rawValue)\n\n if (sanitized !== rawValue) {\n // Rewrite the DOM value before bubbling up so the parent (controlled\n // or not) only ever sees the clean value and no invalid char sticks.\n const removed = rawValue.length - sanitized.length\n event.target.value = sanitized\n if (selectionStart != null) {\n const caret = Math.max(0, selectionStart - removed)\n event.target.setSelectionRange(caret, caret)\n }\n }\n\n onChange?.(event)\n }\n\n const handleRootClick = (event: MouseEvent<HTMLDivElement>) => {\n if (!(event.target instanceof Element)) return\n if (\n event.target.closest('button, input, label, [role=\"listbox\"], [tabindex]')\n ) {\n return\n }\n inputRef.current?.focus()\n }\n\n return (\n <div className={cn(styles.root, className)} data-testid={dataTestId?.root}>\n {/*\n Clicking the padding around the field focuses it — a pointer convenience\n on top of the real control. Keyboard users tab straight to the input.\n */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}\n <div\n className={cn(styles.card, hasError && styles.error)}\n onClick={handleRootClick}\n >\n {label != null ? (\n <span className={styles.labelRow}>\n <label\n data-testid={dataTestId?.label}\n className={styles.label}\n htmlFor={inputId}\n >\n {label}\n </label>\n {labelTooltip != null ? (\n <InfoTooltip content={labelTooltip} size={20} />\n ) : null}\n </span>\n ) : null}\n <div className={styles.amountRow}>\n <input\n ref={inputRef}\n id={inputId}\n className={styles.input}\n inputMode='decimal'\n disabled={disabled}\n aria-invalid={hasError || undefined}\n aria-describedby={showErrorMessage ? errorId : undefined}\n onChange={handleChange}\n data-testid={dataTestId?.input}\n {...inputProps}\n />\n {tokenSelector != null ? (\n <div className={styles.token}>{tokenSelector}</div>\n ) : null}\n </div>\n {hasBottomRow ? (\n <div className={styles.bottomRow}>\n {secondaryValue != null ? (\n <span\n data-testid={dataTestId?.secondaryValue}\n className={styles.secondary}\n >\n {secondaryValue}\n </span>\n ) : null}\n <div className={styles.balanceGroup}>\n {balance != null ? (\n <span\n className={styles.balance}\n data-testid={dataTestId?.balance}\n >\n {balance}\n </span>\n ) : null}\n {showMax && maxTooltip != null ? (\n <Tooltip\n content={maxTooltip}\n position={maxTooltipPosition}\n width={240}\n >\n {maxTag}\n </Tooltip>\n ) : showMax ? (\n maxTag\n ) : null}\n </div>\n </div>\n ) : null}\n </div>\n {showErrorMessage ? (\n <div\n id={errorId}\n className={styles.errorMessage}\n data-testid={dataTestId?.error}\n >\n {errorText}\n </div>\n ) : null}\n </div>\n )\n}\n"],"names":["sanitizeDecimal","raw","normalized","replace","firstDot","indexOf","head","slice","tail","noop","undefined","RichInput","_ref","label","labelTooltip","secondaryValue","balance","tokenSelector","error","errorText","showMaxButton","onMaxClick","maxDisabled","maxTooltip","maxTooltipPosition","onChange","className","id","disabled","dataTestId","inputProps","inputRef","useRef","fallbackId","useId","inputId","hasError","showErrorMessage","errorId","showMax","hasBottomRow","maxTag","_jsx","Tag","as","root","maxButton","onClick","children","handleChange","event","value","rawValue","selectionStart","target","sanitized","removed","length","caret","Math","max","setSelectionRange","handleRootClick","Element","closest","current","focus","_jsxs","cn","styles","card","labelRow","htmlFor","InfoTooltip","content","size","amountRow","ref","input","inputMode","token","bottomRow","secondary","balanceGroup","Tooltip","position","width","errorMessage"],"mappings":";;;;;;;;;;;;AAiDA;AACA;AACA,MAAMA,eAAe,GAAIC,GAAW,IAAa;AAC/C,EAAA,MAAMC,UAAU,GAAGD,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AAChE,EAAA,MAAMC,QAAQ,GAAGF,UAAU,CAACG,OAAO,CAAC,GAAG,CAAC,CAAA;AACxC,EAAA,IAAID,QAAQ,KAAK,CAAC,CAAC,EAAE,OAAOF,UAAU,CAAA;EACtC,MAAMI,IAAI,GAAGJ,UAAU,CAACK,KAAK,CAAC,CAAC,EAAEH,QAAQ,GAAG,CAAC,CAAC,CAAA;AAC9C,EAAA,MAAMI,IAAI,GAAGN,UAAU,CAACK,KAAK,CAACH,QAAQ,GAAG,CAAC,CAAC,CAACD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;EAC9D,OAAOG,IAAI,GAAGE,IAAI,CAAA;AACpB,CAAC,CAAA;AAED,MAAMC,IAAI,GAAGA,MAAMC,SAAS,CAAA;;AAE5B;AACaC,MAAAA,SAAS,GAAGC,IAAA,IAmBH;EAAA,IAnBI;IACxBC,KAAK;IACLC,YAAY;IACZC,cAAc;IACdC,OAAO;IACPC,aAAa;IACbC,KAAK;IACLC,SAAS;AACTC,IAAAA,aAAa,GAAG,IAA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tsx"],"sourcesContent":["import {\n useId,\n useRef,\n type ChangeEvent,\n type InputHTMLAttributes,\n type MouseEvent,\n type MouseEventHandler,\n type ReactNode,\n} from 'react'\n\nimport cn from 'classnames'\nimport { IconLockKeyhole } from '../icons'\nimport { InfoTooltip } from '../info-tooltip'\nimport { Tag } from '../tag'\nimport { Tooltip, type TooltipPosition } from '../tooltip'\n\nimport styles from './RichInput.module.css'\n\nexport type RichInputDataTestId = {\n root?: string\n label?: string\n input?: string\n secondaryValue?: string\n balance?: string\n maxButton?: string\n error?: string\n lock?: string\n}\n\nexport type RichInputProps = InputHTMLAttributes<HTMLInputElement> & {\n label?: ReactNode\n labelTooltip?: ReactNode\n /** Fiat equivalent, bottom left. */\n secondaryValue?: ReactNode\n /** Wallet balance, bottom right. */\n balance?: ReactNode\n /** Slot for a `TokenSelector`. */\n tokenSelector?: ReactNode\n /** Marks the card invalid. */\n error?: boolean\n errorText?: ReactNode\n showMaxButton?: boolean\n onMaxClick?: MouseEventHandler<HTMLButtonElement>\n /** Dims the Max shortcut, leaving the field editable. */\n maxDisabled?: boolean\n /** Explains what Max actually fills in. */\n maxTooltip?: ReactNode\n maxTooltipPosition?: TooltipPosition\n /** Value can't be edited. */\n locked?: boolean\n /** Tooltip on the lock icon. */\n lockedTooltip?: ReactNode\n dataTestId?: RichInputDataTestId\n}\n\n// Keep only digits and a single decimal point; comma is treated as the\n// decimal separator and normalized to a dot (en-US canonical form).\nconst sanitizeDecimal = (raw: string): string => {\n const normalized = raw.replace(/,/g, '.').replace(/[^\\d.]/g, '')\n const firstDot = normalized.indexOf('.')\n if (firstDot === -1) return normalized\n const head = normalized.slice(0, firstDot + 1)\n const tail = normalized.slice(firstDot + 1).replace(/\\./g, '')\n return head + tail\n}\n\nconst noop = () => undefined\n\n/** Amount field for supply and borrow forms: token picker, fiat equivalent, balance and a Max shortcut in one card; input is filtered to decimals as you type. `disabled` dims the card and hides Max; `locked` makes it read-only without Max. */\nexport const RichInput = ({\n label,\n labelTooltip,\n secondaryValue,\n balance,\n tokenSelector,\n error,\n errorText,\n showMaxButton = true,\n onMaxClick,\n maxDisabled,\n maxTooltip,\n maxTooltipPosition = 'bottom-left',\n onChange,\n className,\n id,\n disabled,\n locked,\n lockedTooltip,\n readOnly,\n dataTestId,\n ...inputProps\n}: RichInputProps) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const fallbackId = useId()\n const inputId = id ?? fallbackId\n\n const hasError = !!error\n const showErrorMessage = !!errorText\n const errorId = `${inputId}-error`\n const showMax = showMaxButton && !disabled && !locked\n const hasBottomRow = secondaryValue != null || balance != null || showMax\n\n const maxTag = (\n <Tag\n as='button'\n dataTestId={{ root: dataTestId?.maxButton }}\n onClick={onMaxClick ?? noop}\n disabled={maxDisabled}\n >\n Max\n </Tag>\n )\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n const { value: rawValue, selectionStart } = event.target\n const sanitized = sanitizeDecimal(rawValue)\n\n if (sanitized !== rawValue) {\n // Rewrite the DOM value before bubbling up so the parent (controlled\n // or not) only ever sees the clean value and no invalid char sticks.\n const removed = rawValue.length - sanitized.length\n event.target.value = sanitized\n if (selectionStart != null) {\n const caret = Math.max(0, selectionStart - removed)\n event.target.setSelectionRange(caret, caret)\n }\n }\n\n onChange?.(event)\n }\n\n const handleRootClick = (event: MouseEvent<HTMLDivElement>) => {\n if (!(event.target instanceof Element)) return\n if (\n event.target.closest('button, input, label, [role=\"listbox\"], [tabindex]')\n ) {\n return\n }\n inputRef.current?.focus()\n }\n\n return (\n <div className={cn(styles.root, className)} data-testid={dataTestId?.root}>\n {/*\n Clicking the padding around the field focuses it — a pointer convenience\n on top of the real control. Keyboard users tab straight to the input.\n */}\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}\n <div\n className={cn(\n styles.card,\n hasError && styles.error,\n locked && styles.locked,\n )}\n onClick={handleRootClick}\n >\n {label != null ? (\n <span className={styles.labelRow}>\n <label\n data-testid={dataTestId?.label}\n className={styles.label}\n htmlFor={inputId}\n >\n {label}\n </label>\n {labelTooltip != null ? (\n <InfoTooltip content={labelTooltip} size={20} />\n ) : null}\n {locked ? (\n lockedTooltip != null ? (\n <InfoTooltip\n icon={<IconLockKeyhole aria-hidden='true' />}\n size={20}\n aria-label='Locked'\n content={lockedTooltip}\n className={styles.lock}\n dataTestId={{ root: dataTestId?.lock }}\n />\n ) : (\n <IconLockKeyhole\n aria-hidden='true'\n className={cn(styles.lock, styles.lockIcon)}\n data-testid={dataTestId?.lock}\n />\n )\n ) : null}\n </span>\n ) : null}\n <div className={styles.amountRow}>\n <input\n ref={inputRef}\n id={inputId}\n className={styles.input}\n inputMode='decimal'\n disabled={disabled}\n readOnly={locked || readOnly}\n aria-invalid={hasError || undefined}\n aria-describedby={showErrorMessage ? errorId : undefined}\n onChange={handleChange}\n data-testid={dataTestId?.input}\n {...inputProps}\n />\n {tokenSelector != null ? (\n <div className={styles.token}>{tokenSelector}</div>\n ) : null}\n </div>\n {hasBottomRow ? (\n <div className={styles.bottomRow}>\n {secondaryValue != null ? (\n <span\n data-testid={dataTestId?.secondaryValue}\n className={styles.secondary}\n >\n {secondaryValue}\n </span>\n ) : null}\n <div className={styles.balanceGroup}>\n {balance != null ? (\n <span\n className={styles.balance}\n data-testid={dataTestId?.balance}\n >\n {balance}\n </span>\n ) : null}\n {showMax && maxTooltip != null ? (\n <Tooltip\n content={maxTooltip}\n position={maxTooltipPosition}\n width={240}\n >\n {maxTag}\n </Tooltip>\n ) : showMax ? (\n maxTag\n ) : null}\n </div>\n </div>\n ) : null}\n </div>\n {showErrorMessage ? (\n <div\n id={errorId}\n className={styles.errorMessage}\n data-testid={dataTestId?.error}\n >\n {errorText}\n </div>\n ) : null}\n </div>\n )\n}\n"],"names":["sanitizeDecimal","raw","normalized","replace","firstDot","indexOf","head","slice","tail","noop","undefined","RichInput","_ref","label","labelTooltip","secondaryValue","balance","tokenSelector","error","errorText","showMaxButton","onMaxClick","maxDisabled","maxTooltip","maxTooltipPosition","onChange","className","id","disabled","locked","lockedTooltip","readOnly","dataTestId","inputProps","inputRef","useRef","fallbackId","useId","inputId","hasError","showErrorMessage","errorId","showMax","hasBottomRow","maxTag","_jsx","Tag","as","root","maxButton","onClick","children","handleChange","event","value","rawValue","selectionStart","target","sanitized","removed","length","caret","Math","max","setSelectionRange","handleRootClick","Element","closest","current","focus","_jsxs","cn","styles","card","labelRow","htmlFor","InfoTooltip","content","size","icon","IconLockKeyhole","lock","lockIcon","amountRow","ref","input","inputMode","token","bottomRow","secondary","balanceGroup","Tooltip","position","width","errorMessage"],"mappings":";;;;;;;;;;;;;AAuDA;AACA;AACA,MAAMA,eAAe,GAAIC,GAAW,IAAa;AAC/C,EAAA,MAAMC,UAAU,GAAGD,GAAG,CAACE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;AAChE,EAAA,MAAMC,QAAQ,GAAGF,UAAU,CAACG,OAAO,CAAC,GAAG,CAAC,CAAA;AACxC,EAAA,IAAID,QAAQ,KAAK,CAAC,CAAC,EAAE,OAAOF,UAAU,CAAA;EACtC,MAAMI,IAAI,GAAGJ,UAAU,CAACK,KAAK,CAAC,CAAC,EAAEH,QAAQ,GAAG,CAAC,CAAC,CAAA;AAC9C,EAAA,MAAMI,IAAI,GAAGN,UAAU,CAACK,KAAK,CAACH,QAAQ,GAAG,CAAC,CAAC,CAACD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;EAC9D,OAAOG,IAAI,GAAGE,IAAI,CAAA;AACpB,CAAC,CAAA;AAED,MAAMC,IAAI,GAAGA,MAAMC,SAAS,CAAA;;AAE5B;AACaC,MAAAA,SAAS,GAAGC,IAAA,IAsBH;EAAA,IAtBI;IACxBC,KAAK;IACLC,YAAY;IACZC,cAAc;IACdC,OAAO;IACPC,aAAa;IACbC,KAAK;IACLC,SAAS;AACTC,IAAAA,aAAa,GAAG,IAAI;IACpBC,UA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AEhB,OAAQ;AAAAmC,YAAAA,QAAA,EAEhCnC,OAAAA;AAAO,WACJ,CAAC,GACL,IAAI,EACP0B,OAAO,IAAInB,UAAU,IAAI,IAAI,gBAC5BsB,cAAA,CAAC8C,eAAO,EAAA;AACNd,YAAAA,OAAO,EAAEtD,UAAW;AACpBqE,YAAAA,QAAQ,EAAEpE,kBAAmB;AAC7BqE,YAAAA,KAAK,EAAE,GAAI;AAAA1C,YAAAA,QAAA,EAEVP,MAAAA;AAAM,WACA,CAAC,GACRF,OAAO,GACTE,MAAM,GACJ,IAAI,CAAA;AAAA,SACL,CAAC,CAAA;OACH,CAAC,GACJ,IAAI,CAAA;AAAA,KACL,CAAC,EACLJ,gBAAgB,gBACfK,cAAA,CAAA,KAAA,EAAA;AACElB,MAAAA,EAAE,EAAEc,OAAQ;MACZf,SAAS,EAAE8C,gBAAM,CAACsB,YAAa;MAC/B,aAAa9D,EAAAA,UAAU,EAAEd,KAAM;AAAAiC,MAAAA,QAAA,EAE9BhC,SAAAA;KACE,CAAC,GACJ,IAAI,CAAA;AAAA,GACL,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const styles = {"root":"RichInput-module_root__2RrAF","card":"RichInput-module_card__wDqv1","error":"RichInput-module_error__iuacN","input":"RichInput-module_input__G69-P","labelRow":"RichInput-module_labelRow__bh0KF","label":"RichInput-module_label__FNaLW","amountRow":"RichInput-module_amountRow__GWqIG","token":"RichInput-module_token__qSEX1","bottomRow":"RichInput-module_bottomRow__2SnLx","secondary":"RichInput-module_secondary__pftTQ","balanceGroup":"RichInput-module_balanceGroup__q4-lT","balance":"RichInput-module_balance__y-Ukz","errorMessage":"RichInput-module_errorMessage__axdve"};
|
|
3
|
+
const styles = {"root":"RichInput-module_root__2RrAF","card":"RichInput-module_card__wDqv1","locked":"RichInput-module_locked__fGImq","error":"RichInput-module_error__iuacN","input":"RichInput-module_input__G69-P","lock":"RichInput-module_lock__adGaA","lockIcon":"RichInput-module_lockIcon__wJpHd","labelRow":"RichInput-module_labelRow__bh0KF","label":"RichInput-module_label__FNaLW","amountRow":"RichInput-module_amountRow__GWqIG","token":"RichInput-module_token__qSEX1","bottomRow":"RichInput-module_bottomRow__2SnLx","secondary":"RichInput-module_secondary__pftTQ","balanceGroup":"RichInput-module_balanceGroup__q4-lT","balance":"RichInput-module_balance__y-Ukz","errorMessage":"RichInput-module_errorMessage__axdve"};
|
|
4
4
|
|
|
5
5
|
module.exports = styles;
|
|
6
6
|
//# sourceMappingURL=RichInput.module.css.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarToggle.cjs","sources":["../../../src/sidebar/SidebarToggle.tsx"],"sourcesContent":["import { forwardRef, useContext, type MouseEvent } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconButton, type
|
|
1
|
+
{"version":3,"file":"SidebarToggle.cjs","sources":["../../../src/sidebar/SidebarToggle.tsx"],"sourcesContent":["import { forwardRef, useContext, type MouseEvent } from 'react'\n\nimport cn from 'classnames'\n\nimport { IconButton, type IconButtonAsButtonProps } from '../icon-button'\nimport { IconMenu } from '../icons'\nimport { SidebarContext } from './SidebarContext'\nimport styles from './SidebarToggle.module.css'\n\nexport type SidebarToggleProps = Omit<\n IconButtonAsButtonProps,\n 'icon' | 'aria-label'\n> & {\n 'aria-label'?: string\n}\n\n/**\n * Burger that opens the Sidebar drawer; visible only at `sidebar-down` widths.\n * Inside a SidebarLayout it wires `aria-*` (explicit props win) and toggles after your\n * `onClick`, unless that calls `event.preventDefault()`.\n */\nexport const SidebarToggle = forwardRef<HTMLButtonElement, SidebarToggleProps>(\n (\n { className, 'aria-label': ariaLabel = 'Open menu', onClick, ...rest },\n ref,\n ) => {\n const toggleProps = useContext(SidebarContext)?.toggleProps\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (!event.defaultPrevented) toggleProps?.onClick()\n }\n return (\n <IconButton\n ref={ref}\n variant='ghost'\n icon={<IconMenu />}\n aria-label={ariaLabel}\n {...toggleProps}\n {...rest}\n onClick={handleClick}\n className={cn(styles.toggle, className)}\n />\n )\n },\n)\n\nSidebarToggle.displayName = 'SidebarToggle'\n"],"names":["SidebarToggle","forwardRef","_ref","ref","className","ariaLabel","onClick","rest","toggleProps","useContext","SidebarContext","handleClick","event","defaultPrevented","_jsx","IconButton","variant","icon","IconMenu","cn","styles","toggle","displayName"],"mappings":";;;;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACO,MAAMA,aAAa,gBAAGC,gBAAU,CACrC,CAAAC,IAAA,EAEEC,GAAG,KACA;EAAA,IAFH;IAAEC,SAAS;IAAE,YAAY,EAAEC,SAAS,GAAG,WAAW;IAAEC,OAAO;IAAE,GAAGC,IAAAA;AAAK,GAAC,GAAAL,IAAA,CAAA;AAGtE,EAAA,MAAMM,WAAW,GAAGC,gBAAU,CAACC,6BAAc,CAAC,EAAEF,WAAW,CAAA;EAC3D,MAAMG,WAAW,GAAIC,KAAoC,IAAK;IAC5DN,OAAO,GAAGM,KAAK,CAAC,CAAA;IAChB,IAAI,CAACA,KAAK,CAACC,gBAAgB,EAAEL,WAAW,EAAEF,OAAO,EAAE,CAAA;GACpD,CAAA;EACD,oBACEQ,cAAA,CAACC,qBAAU,EAAA;AACTZ,IAAAA,GAAG,EAAEA,GAAI;AACTa,IAAAA,OAAO,EAAC,OAAO;AACfC,IAAAA,IAAI,eAAEH,cAAA,CAACI,iBAAQ,IAAE,CAAE;AACnB,IAAA,YAAA,EAAYb,SAAU;AAAA,IAAA,GAClBG,WAAW;AAAA,IAAA,GACXD,IAAI;AACRD,IAAAA,OAAO,EAAEK,WAAY;AACrBP,IAAAA,SAAS,EAAEe,EAAE,CAACC,oBAAM,CAACC,MAAM,EAAEjB,SAAS,CAAA;AAAE,GACzC,CAAC,CAAA;AAEN,CACF,EAAC;AAEDJ,aAAa,CAACsB,WAAW,GAAG,eAAe;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmallCard.cjs","sources":["../../../src/small-card/SmallCard.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './SmallCard.module.css'\n\nexport type SmallCardDataTestId = {\n root?: string\n image?: string\n logo?: string\n icon?: string\n title?: string\n description?: string\n footer?: string\n}\n\nexport type SmallCardProps = Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n 'title'\n> & {\n /** Fixed-height (120px) media slot above the header — an image or illustration. */\n image?: ReactNode\n logo?: ReactNode\n /** Trailing glyph next to the title — an external-link arrow, a badge, etc. */\n icon?: ReactNode\n title: ReactNode\n
|
|
1
|
+
{"version":3,"file":"SmallCard.cjs","sources":["../../../src/small-card/SmallCard.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './SmallCard.module.css'\n\nexport type SmallCardDataTestId = {\n root?: string\n image?: string\n logo?: string\n icon?: string\n title?: string\n description?: string\n footer?: string\n}\n\nexport type SmallCardProps = Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n 'title'\n> & {\n /** Fixed-height (120px) media slot above the header — an image or illustration. */\n image?: ReactNode\n logo?: ReactNode\n /** Trailing glyph next to the title — an external-link arrow, a badge, etc. */\n icon?: ReactNode\n title: ReactNode\n description?: ReactNode\n /** Arbitrary content below the description — wraps in a row, e.g. a list of `Tag`s. */\n footer?: ReactNode\n dataTestId?: SmallCardDataTestId\n} & Pick<AnchorProps, 'external' | 'linkProps'>\n\n/** Clickable card that always renders as a link: optional `image`, `logo`, title with trailing `icon`, `description` and `footer`; title and description wrap instead of truncating. */\nexport const SmallCard = forwardRef<HTMLAnchorElement, SmallCardProps>(\n (\n {\n image,\n logo,\n icon,\n title,\n description,\n footer,\n className,\n dataTestId,\n ...rest\n },\n ref,\n ) => (\n <Anchor\n ref={ref}\n className={cn(styles.card, className)}\n data-testid={dataTestId?.root}\n {...rest}\n >\n <div className={styles.content}>\n {image != null ? (\n <div className={styles.image} data-testid={dataTestId?.image}>\n {image}\n </div>\n ) : null}\n <div className={styles.header}>\n {logo != null ? (\n <span className={styles.logo} data-testid={dataTestId?.logo}>\n {logo}\n </span>\n ) : null}\n <span className={styles.title} data-testid={dataTestId?.title}>\n {title}\n </span>\n {icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null}\n </div>\n {description != null ? (\n <p\n className={styles.description}\n data-testid={dataTestId?.description}\n >\n {description}\n </p>\n ) : null}\n </div>\n {footer != null ? (\n <div className={styles.footer} data-testid={dataTestId?.footer}>\n {footer}\n </div>\n ) : null}\n </Anchor>\n ),\n)\n\nSmallCard.displayName = 'SmallCard'\n"],"names":["SmallCard","forwardRef","_ref","ref","image","logo","icon","title","description","footer","className","dataTestId","rest","_jsxs","Anchor","cn","styles","card","root","children","content","_jsx","header","displayName"],"mappings":";;;;;;;;;;AAiCA;AACO,MAAMA,SAAS,gBAAGC,gBAAU,CACjC,CAAAC,IAAA,EAYEC,GAAG,KAAA;EAAA,IAXH;IACEC,KAAK;IACLC,IAAI;IACJC,IAAI;IACJC,KAAK;IACLC,WAAW;IACXC,MAAM;IACNC,SAAS;IACTC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAV,IAAA,CAAA;EAAA,oBAGDW,eAAA,CAACC,aAAM,EAAA;AACLX,IAAAA,GAAG,EAAEA,GAAI;IACTO,SAAS,EAAEK,EAAE,CAACC,gBAAM,CAACC,IAAI,EAAEP,SAAS,CAAE;IACtC,aAAaC,EAAAA,UAAU,EAAEO,IAAK;AAAA,IAAA,GAC1BN,IAAI;AAAAO,IAAAA,QAAA,gBAERN,eAAA,CAAA,KAAA,EAAA;MAA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A,CAAA,KAAA,EAAA;MAAKX,SAAS,EAAEM,gBAAM,CAACP,MAAO;MAAC,aAAaE,EAAAA,UAAU,EAAEF,MAAO;AAAAU,MAAAA,QAAA,EAC5DV,MAAAA;KACE,CAAC,GACJ,IAAI,CAAA;AAAA,GACF,CAAC,CAAA;AAAA,CAEb,EAAC;AAEDT,SAAS,CAACuB,WAAW,GAAG,WAAW;;;;"}
|
package/dist/cjs/tag/Tag.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.cjs","sources":["../../../src/tag/Tag.tsx"],"sourcesContent":["import {\n forwardRef,\n useId,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport { IconCross } from '../icons'\nimport { ActionElement, type ActionElementProps } from '../utils'\nimport styles from './Tag.module.css'\n\nexport type TagVariant =\n | 'default'\n | 'neutral'\n | 'success'\n | 'warning'\n | 'error'\n | 'info'\n | 'active'\n | 'action'\n\nexport type TagDataTestId = {\n root?: string\n icon?: string\n closeButton?: string\n}\n\nexport type TagIconPosition = 'left' | 'right'\n\nexport type TagProps = Omit<HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n variant?: TagVariant\n /** Shows the variant-coloured active border. */\n active?: boolean\n icon?: ReactNode\n iconPosition?: TagIconPosition\n /** Renders a trailing close button when set. */\n onClose?: () => void\n /** Renders a link (`<a>` via LinkProvider) instead of a span. */\n href?: string\n /** Click handler; a span with it becomes a keyboard-operable `role=\"button\"`, except with `onClose` where it stays passive. */\n onClick?: MouseEventHandler<HTMLElement>\n /** Disables the button or link form; on its own always renders a native disabled button, whatever `as` is. Ignored with `onClose`. */\n disabled?: boolean\n /** `button` renders a native `<button>` only together with `onClick`; the default `span` (`role=\"button\"` with `onClick`) avoids nesting a button inside another button or link. `href` and `disabled` always render the native form. */\n as?: 'span' | 'button'\n dataTestId?: TagDataTestId\n}\n\n/** Compact pill for filters, labels and removable selections; text only by default, with room for a leading icon and a trailing close button. */\nexport const Tag = forwardRef<HTMLElement, TagProps>(\n (\n {\n variant = 'default',\n active = false,\n icon,\n iconPosition = 'left',\n onClose,\n href,\n onClick,\n disabled,\n as = 'span',\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const labelId = useId()\n const iconElement =\n icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null\n\n const isAction =\n !onClose &&\n (href != null || disabled || (as === 'button' && onClick != null))\n const isSpanAction = !onClose && !isAction && onClick != null\n const classes = cn(\n styles.tag,\n styles[variant],\n (isAction || isSpanAction) && styles.interactive,\n active && styles.isActive,\n className,\n )\n\n const content = (\n <>\n {iconPosition === 'left' ? iconElement : null}\n {onClose ? <span id={labelId}>{children}</span> : children}\n {iconPosition === 'right' ? iconElement : null}\n {onClose ? (\n <button\n type='button'\n className={styles.closeButton}\n aria-label='Remove'\n aria-describedby={labelId}\n onClick={(event) => {\n event.stopPropagation()\n onClose()\n }}\n data-testid={dataTestId?.closeButton}\n >\n <IconCross aria-hidden='true' className={styles.crossIcon} />\n </button>\n ) : null}\n </>\n )\n\n if (isAction) {\n return (\n <ActionElement\n ref={ref as Ref<HTMLAnchorElement | HTMLButtonElement>}\n className={classes}\n data-testid={dataTestId?.root}\n {...({ href, onClick, disabled, ...rest } as ActionElementProps)}\n >\n {content}\n </ActionElement>\n )\n }\n\n if (isSpanAction) {\n const { onKeyDown, tabIndex = 0, ...spanRest } = rest\n return (\n <span\n ref={ref as Ref<HTMLSpanElement>}\n role='button'\n tabIndex={tabIndex}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented || event.target !== event.currentTarget)\n return\n if (event.key !== 'Enter' && event.key !== ' ') return\n event.preventDefault()\n event.currentTarget.click()\n }}\n {...spanRest}\n >\n {content}\n </span>\n )\n }\n\n return (\n // removable tags keep a passive onClick; the close button is the control\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <span\n ref={ref as Ref<HTMLSpanElement>}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n {...rest}\n >\n {content}\n </span>\n )\n },\n)\n\nTag.displayName = 'Tag'\n"],"names":["Tag","forwardRef","_ref","ref","variant","active","icon","iconPosition","onClose","href","onClick","disabled","as","className","children","dataTestId","rest","labelId","useId","iconElement","_jsx","styles","isAction","isSpanAction","classes","cn","tag","interactive","isActive","content","_jsxs","_Fragment","id","type","closeButton","event","stopPropagation","IconCross","crossIcon","ActionElement","root","onKeyDown","tabIndex","spanRest","role","defaultPrevented","target","currentTarget","key","preventDefault","click","displayName"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Tag.cjs","sources":["../../../src/tag/Tag.tsx"],"sourcesContent":["import {\n forwardRef,\n useId,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react'\n\nimport cn from 'classnames'\n\nimport { IconCross } from '../icons'\nimport { ActionElement, type ActionElementProps } from '../utils'\nimport styles from './Tag.module.css'\n\nexport type TagVariant =\n | 'default'\n | 'neutral'\n | 'success'\n | 'warning'\n | 'error'\n | 'info'\n | 'active'\n | 'action'\n | 'custom'\n\nexport type TagDataTestId = {\n root?: string\n icon?: string\n closeButton?: string\n}\n\nexport type TagIconPosition = 'left' | 'right'\n\nexport type TagProps = Omit<HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n /** `custom` takes colors from the `--lido-app-ui-tag-*` CSS vars. */\n variant?: TagVariant\n /** Shows the variant-coloured active border. */\n active?: boolean\n icon?: ReactNode\n iconPosition?: TagIconPosition\n /** Renders a trailing close button when set. */\n onClose?: () => void\n /** Renders a link (`<a>` via LinkProvider) instead of a span. */\n href?: string\n /** Click handler; a span with it becomes a keyboard-operable `role=\"button\"`, except with `onClose` where it stays passive. */\n onClick?: MouseEventHandler<HTMLElement>\n /** Disables the button or link form; on its own always renders a native disabled button, whatever `as` is. Ignored with `onClose`. */\n disabled?: boolean\n /** `button` renders a native `<button>` only together with `onClick`; the default `span` (`role=\"button\"` with `onClick`) avoids nesting a button inside another button or link. `href` and `disabled` always render the native form. */\n as?: 'span' | 'button'\n dataTestId?: TagDataTestId\n}\n\n/** Compact pill for filters, labels and removable selections; text only by default, with room for a leading icon and a trailing close button. */\nexport const Tag = forwardRef<HTMLElement, TagProps>(\n (\n {\n variant = 'default',\n active = false,\n icon,\n iconPosition = 'left',\n onClose,\n href,\n onClick,\n disabled,\n as = 'span',\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => {\n const labelId = useId()\n const iconElement =\n icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null\n\n const isAction =\n !onClose &&\n (href != null || disabled || (as === 'button' && onClick != null))\n const isSpanAction = !onClose && !isAction && onClick != null\n const classes = cn(\n styles.tag,\n styles[variant],\n (isAction || isSpanAction) && styles.interactive,\n active && styles.isActive,\n className,\n )\n\n const content = (\n <>\n {iconPosition === 'left' ? iconElement : null}\n {onClose ? <span id={labelId}>{children}</span> : children}\n {iconPosition === 'right' ? iconElement : null}\n {onClose ? (\n <button\n type='button'\n className={styles.closeButton}\n aria-label='Remove'\n aria-describedby={labelId}\n onClick={(event) => {\n event.stopPropagation()\n onClose()\n }}\n data-testid={dataTestId?.closeButton}\n >\n <IconCross aria-hidden='true' className={styles.crossIcon} />\n </button>\n ) : null}\n </>\n )\n\n if (isAction) {\n return (\n <ActionElement\n ref={ref as Ref<HTMLAnchorElement | HTMLButtonElement>}\n className={classes}\n data-testid={dataTestId?.root}\n {...({ href, onClick, disabled, ...rest } as ActionElementProps)}\n >\n {content}\n </ActionElement>\n )\n }\n\n if (isSpanAction) {\n const { onKeyDown, tabIndex = 0, ...spanRest } = rest\n return (\n <span\n ref={ref as Ref<HTMLSpanElement>}\n role='button'\n tabIndex={tabIndex}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n onKeyDown={(event: KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (event.defaultPrevented || event.target !== event.currentTarget)\n return\n if (event.key !== 'Enter' && event.key !== ' ') return\n event.preventDefault()\n event.currentTarget.click()\n }}\n {...spanRest}\n >\n {content}\n </span>\n )\n }\n\n return (\n // removable tags keep a passive onClick; the close button is the control\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <span\n ref={ref as Ref<HTMLSpanElement>}\n className={classes}\n data-testid={dataTestId?.root}\n onClick={onClick}\n {...rest}\n >\n {content}\n </span>\n )\n },\n)\n\nTag.displayName = 'Tag'\n"],"names":["Tag","forwardRef","_ref","ref","variant","active","icon","iconPosition","onClose","href","onClick","disabled","as","className","children","dataTestId","rest","labelId","useId","iconElement","_jsx","styles","isAction","isSpanAction","classes","cn","tag","interactive","isActive","content","_jsxs","_Fragment","id","type","closeButton","event","stopPropagation","IconCross","crossIcon","ActionElement","root","onKeyDown","tabIndex","spanRest","role","defaultPrevented","target","currentTarget","key","preventDefault","click","displayName"],"mappings":";;;;;;;;;;;AAuDA;AACO,MAAMA,GAAG,gBAAGC,gBAAU,CAC3B,CAAAC,IAAA,EAgBEC,GAAG,KACA;EAAA,IAhBH;AACEC,IAAAA,OAAO,GAAG,SAAS;AACnBC,IAAAA,MAAM,GAAG,KAAK;IACdC,IAAI;AACJC,IAAAA,YAAY,GAAG,MAAM;IACrBC,OAAO;IACPC,IAAI;IACJC,OAAO;IACPC,QAAQ;AACRC,IAAAA,EAAE,GAAG,MAAM;IACXC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAd,IAAA,CAAA;AAGD,EAAA,MAAMe,OAAO,GAAGC,WAAK,EAAE,CAAA;AACvB,EAAA,MAAMC,W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AG,KAAK,OAAO,IAAIb,KAAK,CAACa,GAAG,KAAK,GAAG,EAAE,OAAA;QAChDb,KAAK,CAACc,cAAc,EAAE,CAAA;AACtBd,QAAAA,KAAK,CAACY,aAAa,CAACG,KAAK,EAAE,CAAA;OAC3B;AAAA,MAAA,GACEP,QAAQ;AAAA7B,MAAAA,QAAA,EAEXe,OAAAA;AAAO,KACJ,CAAC,CAAA;AAEX,GAAA;AAEA,EAAA;AAAA;AACE;AACA;IACAT,cAAA,CAAA,MAAA,EAAA;AACEjB,MAAAA,GAAG,EAAEA,GAA4B;AACjCU,MAAAA,SAAS,EAAEW,OAAQ;MACnB,aAAaT,EAAAA,UAAU,EAAEyB,IAAK;AAC9B9B,MAAAA,OAAO,EAAEA,OAAQ;AAAA,MAAA,GACbM,IAAI;AAAAF,MAAAA,QAAA,EAEPe,OAAAA;KACG,CAAA;AAAC,IAAA;AAEX,CACF,EAAC;AAED7B,GAAG,CAACmD,WAAW,GAAG,KAAK;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const styles = {"tag":"Tag-module_tag__dpq60","interactive":"Tag-module_interactive__jpb40","closeButton":"Tag-module_closeButton__d5-N3","isActive":"Tag-module_isActive__h4p9Z","icon":"Tag-module_icon__7I-oU","crossIcon":"Tag-module_crossIcon__LDgT7","neutral":"Tag-module_neutral__D18sJ","success":"Tag-module_success__JX1nP","warning":"Tag-module_warning__0pWSo","error":"Tag-module_error__o3vZs","info":"Tag-module_info__TJ9YE","active":"Tag-module_active__C6eCL","action":"Tag-module_action__6xjY6"};
|
|
3
|
+
const styles = {"tag":"Tag-module_tag__dpq60","interactive":"Tag-module_interactive__jpb40","closeButton":"Tag-module_closeButton__d5-N3","isActive":"Tag-module_isActive__h4p9Z","icon":"Tag-module_icon__7I-oU","crossIcon":"Tag-module_crossIcon__LDgT7","neutral":"Tag-module_neutral__D18sJ","success":"Tag-module_success__JX1nP","warning":"Tag-module_warning__0pWSo","error":"Tag-module_error__o3vZs","info":"Tag-module_info__TJ9YE","active":"Tag-module_active__C6eCL","action":"Tag-module_action__6xjY6","custom":"Tag-module_custom__NO3kN"};
|
|
4
4
|
|
|
5
5
|
module.exports = styles;
|
|
6
6
|
//# sourceMappingURL=Tag.module.css.cjs.map
|
|
@@ -8,13 +8,12 @@ const Anchor = require('../link-provider/Anchor.cjs');
|
|
|
8
8
|
const TextLink_module = require('./TextLink.module.css.cjs');
|
|
9
9
|
const jsxRuntime = require('react/jsx-runtime');
|
|
10
10
|
|
|
11
|
-
/** Inline link, blue by default. `
|
|
11
|
+
/** Inline link, blue by default. Absolute `http(s)` URLs open in a new tab; `LinkProvider` sends relative hrefs to `component` and absolute ones to `externalComponent`. */
|
|
12
12
|
const TextLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
13
13
|
let {
|
|
14
14
|
variant = 'primary',
|
|
15
15
|
size = 'body',
|
|
16
16
|
icon,
|
|
17
|
-
external = false,
|
|
18
17
|
disabled = false,
|
|
19
18
|
className,
|
|
20
19
|
children,
|
|
@@ -24,7 +23,6 @@ const TextLink = /*#__PURE__*/react.forwardRef((_ref, ref) => {
|
|
|
24
23
|
return /*#__PURE__*/jsxRuntime.jsxs(Anchor.Anchor, {
|
|
25
24
|
ref: ref,
|
|
26
25
|
className: cn(TextLink_module.link, TextLink_module[variant], TextLink_module[size], icon != null && TextLink_module.withIcon, className),
|
|
27
|
-
external: external,
|
|
28
26
|
disabled: disabled,
|
|
29
27
|
"data-testid": dataTestId?.root,
|
|
30
28
|
...rest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextLink.cjs","sources":["../../../src/text-link/TextLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './TextLink.module.css'\n\nexport type TextLinkVariant = 'primary' | 'secondary'\n\nexport type TextLinkSize = 'body' | 'inherit'\n\nexport type TextLinkDataTestId = {\n root?: string\n icon?: string\n}\n\nexport type TextLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** `secondary` is muted gray, blue on hover; for footers and meta links. */\n variant?: TextLinkVariant\n /** `inherit` takes font and display from the surrounding text so the link wraps with it; `body` is 14/24. */\n size?: TextLinkSize\n /** Trailing icon (e.g. arrow). */\n icon?: ReactNode\n /**
|
|
1
|
+
{"version":3,"file":"TextLink.cjs","sources":["../../../src/text-link/TextLink.tsx"],"sourcesContent":["import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react'\n\nimport cn from 'classnames'\n\nimport { Anchor, type AnchorProps } from '../link-provider/Anchor'\nimport styles from './TextLink.module.css'\n\nexport type TextLinkVariant = 'primary' | 'secondary'\n\nexport type TextLinkSize = 'body' | 'inherit'\n\nexport type TextLinkDataTestId = {\n root?: string\n icon?: string\n}\n\nexport type TextLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {\n /** `secondary` is muted gray, blue on hover; for footers and meta links. */\n variant?: TextLinkVariant\n /** `inherit` takes font and display from the surrounding text so the link wraps with it; `body` is 14/24. */\n size?: TextLinkSize\n /** Trailing icon (e.g. arrow). */\n icon?: ReactNode\n /** Drops the href and blocks clicks and keyboard focus. */\n disabled?: boolean\n dataTestId?: TextLinkDataTestId\n} & Pick<AnchorProps, 'external' | 'linkProps'>\n\n/** Inline link, blue by default. Absolute `http(s)` URLs open in a new tab; `LinkProvider` sends relative hrefs to `component` and absolute ones to `externalComponent`. */\nexport const TextLink = forwardRef<HTMLAnchorElement, TextLinkProps>(\n (\n {\n variant = 'primary',\n size = 'body',\n icon,\n disabled = false,\n className,\n children,\n dataTestId,\n ...rest\n },\n ref,\n ) => (\n <Anchor\n ref={ref}\n className={cn(\n styles.link,\n styles[variant],\n styles[size],\n icon != null && styles.withIcon,\n className,\n )}\n disabled={disabled}\n data-testid={dataTestId?.root}\n {...rest}\n >\n {children}\n {icon != null ? (\n <span\n className={styles.icon}\n aria-hidden='true'\n data-testid={dataTestId?.icon}\n >\n {icon}\n </span>\n ) : null}\n </Anchor>\n ),\n)\n\nTextLink.displayName = 'TextLink'\n"],"names":["TextLink","forwardRef","_ref","ref","variant","size","icon","disabled","className","children","dataTestId","rest","_jsxs","Anchor","cn","styles","link","withIcon","root","_jsx","displayName"],"mappings":";;;;;;;;;;AA4BA;AACO,MAAMA,QAAQ,gBAAGC,gBAAU,CAChC,CAAAC,IAAA,EAWEC,GAAG,KAAA;EAAA,IAVH;AACEC,IAAAA,OAAO,GAAG,SAAS;AACnBC,IAAAA,IAAI,GAAG,MAAM;IACbC,IAAI;AACJC,IAAAA,QAAQ,GAAG,KAAK;IAChBC,SAAS;IACTC,QAAQ;IACRC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAAT,IAAA,CAAA;EAAA,oBAGDU,eAAA,CAACC,aAAM,EAAA;AACLV,IAAAA,GAAG,EAAEA,GAAI;IACTK,SAAS,EAAEM,EAAE,CACXC,eAAM,CAACC,IAAI,EACXD,eAAM,CAACX,OAAO,CAAC,EACfW,eAAM,CAACV,IAAI,CAAC,EACZC,IAAI,IAAI,IAAI,IAAIS,eAAM,CAACE,QAAQ,EAC/BT,SACF,CAAE;AACFD,IAAAA,QAAQ,EAAEA,QAAS;IACnB,aAAaG,EAAAA,UAAU,EAAEQ,IAAK;AAAA,IAAA,GAC1BP,IAAI;AAAAF,IAAAA,QAAA,GAEPA,QAAQ,EACRH,IAAI,IAAI,IAAI,gBACXa,cAAA,CAAA,MAAA,EAAA;MACEX,SAAS,EAAEO,eAAM,CAACT,IAAK;AACvB,MAAA,aAAA,EAAY,MAAM;MAClB,aAAaI,EAAAA,UAAU,EAAEJ,IAAK;AAAAG,MAAAA,QAAA,EAE7BH,IAAAA;KACG,CAAC,GACL,IAAI,CAAA;AAAA,GACF,CAAC,CAAA;AAAA,CAEb,EAAC;AAEDN,QAAQ,CAACoB,WAAW,GAAG,UAAU;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeSwitcher.cjs","sources":["../../../src/theme-switcher/ThemeSwitcher.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react'\n\nimport { ThemeName, useThemeToggle } from '@lidofinance/lido-shared-ui'\n\nimport { IconButton, type
|
|
1
|
+
{"version":3,"file":"ThemeSwitcher.cjs","sources":["../../../src/theme-switcher/ThemeSwitcher.tsx"],"sourcesContent":["import { forwardRef, type MouseEvent } from 'react'\n\nimport { ThemeName, useThemeToggle } from '@lidofinance/lido-shared-ui'\n\nimport { IconButton, type IconButtonAsButtonProps } from '../icon-button'\nimport { IconDay, IconNight } from '../icons'\nimport styles from './ThemeSwitcher.module.css'\n\nexport type ThemeSwitcherProps = Omit<\n IconButtonAsButtonProps,\n 'icon' | 'variant' | 'aria-label'\n> & {\n /** Overrides the default English label, e.g. for localization. */\n 'aria-label'?: string\n}\n\n/** Round icon button that toggles the light/dark theme; needs `CookieThemeProvider`, without it the click does nothing. The icon follows the theme in CSS, the label follows the provider state, so pass `initialThemeName` from the request cookie in SSR apps. */\nexport const ThemeSwitcher = forwardRef<HTMLButtonElement, ThemeSwitcherProps>(\n ({ onClick, 'aria-label': ariaLabel, ...rest }, ref) => {\n const { themeName, toggleTheme } = useThemeToggle()\n const isDark = themeName === ThemeName.dark\n\n const handleClick = (event: MouseEvent<HTMLButtonElement>) => {\n toggleTheme?.()\n onClick?.(event)\n }\n\n return (\n <IconButton\n {...rest}\n ref={ref}\n variant='surface'\n aria-label={\n ariaLabel ??\n (isDark ? 'Switch to light theme' : 'Switch to dark theme')\n }\n icon={\n <>\n <IconNight className={styles.toDark} />\n <IconDay className={styles.toLight} />\n </>\n }\n onClick={handleClick}\n />\n )\n },\n)\n\nThemeSwitcher.displayName = 'ThemeSwitcher'\n"],"names":["ThemeSwitcher","forwardRef","_ref","ref","onClick","ariaLabel","rest","themeName","toggleTheme","useThemeToggle","isDark","ThemeName","dark","handleClick","event","_jsx","IconButton","variant","icon","_jsxs","_Fragment","children","IconNight","className","styles","toDark","IconDay","toLight","displayName"],"mappings":";;;;;;;;;;;;AAgBA;AACO,MAAMA,aAAa,gBAAGC,gBAAU,CACrC,CAAAC,IAAA,EAAgDC,GAAG,KAAK;EAAA,IAAvD;IAAEC,OAAO;AAAE,IAAA,YAAY,EAAEC,SAAS;IAAE,GAAGC,IAAAA;AAAK,GAAC,GAAAJ,IAAA,CAAA;EAC5C,MAAM;IAAEK,SAAS;AAAEC,IAAAA,WAAAA;GAAa,GAAGC,2BAAc,EAAE,CAAA;AACnD,EAAA,MAAMC,MAAM,GAAGH,SAAS,KAAKI,sBAAS,CAACC,IAAI,CAAA;EAE3C,MAAMC,WAAW,GAAIC,KAAoC,IAAK;AAC5DN,IAAAA,WAAW,IAAI,CAAA;IACfJ,OAAO,GAAGU,KAAK,CAAC,CAAA;GACjB,CAAA;EAED,oBACEC,cAAA,CAACC,qBAAU,EAAA;AAAA,IAAA,GACLV,IAAI;AACRH,IAAAA,GAAG,EAAEA,GAAI;AACTc,IAAAA,OAAO,EAAC,SAAS;AACjB,IAAA,YAAA,EACEZ,SAAS,KACRK,MAAM,GAAG,uBAAuB,GAAG,sBAAsB,CAC3D;IACDQ,IAAI,eACFC,eAAA,CAAAC,mBAAA,EAAA;MAAAC,QAAA,EAAA,cACEN,cAAA,CAACO,mBAAS,EAAA;QAACC,SAAS,EAAEC,oBAAM,CAACC,MAAAA;AAAO,OAAE,CAAC,eACvCV,cAAA,CAACW,eAAO,EAAA;QAACH,SAAS,EAAEC,oBAAM,CAACG,OAAAA;AAAQ,OAAE,CAAC,CAAA;AAAA,KACtC,CACH;AACDvB,IAAAA,OAAO,EAAES,WAAAA;AAAY,GACtB,CAAC,CAAA;AAEN,CACF,EAAC;AAEDb,aAAa,CAAC4B,WAAW,GAAG,eAAe;;;;"}
|