@harnessio/ui 0.3.1 → 0.3.2

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/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { i as s } from "./index-DQP0ebPn.js";
2
- import { i as e } from "./index-D9MCxZk4.js";
3
- import { i as a } from "./index-C-U12ygm.js";
4
- import { i as m } from "./index-B_zaq-X5.js";
2
+ import { i as e } from "./index-y8kg2_tQ.js";
3
+ import { i as a } from "./index-CVsvJ9_l.js";
4
+ import { i as m } from "./index-D9zYGNBh.js";
5
5
  import { i as f } from "./index-yGuTXfMI.js";
6
6
  import { i as l } from "./index-B0RdQPnM.js";
7
7
  export {
@@ -0,0 +1,130 @@
1
+ import { jsx as i, Fragment as d } from "react/jsx-runtime";
2
+ import { useContext as N, createContext as C, forwardRef as v, Children as O, isValidElement as T } from "react";
3
+ function y() {
4
+ }
5
+ const S = (t) => typeof t == "string" ? t : t.pathname || "/", p = v(({ to: t, children: n, ...a }, e) => {
6
+ const r = S(t), {
7
+ reloadDocument: s,
8
+ replace: o,
9
+ state: c,
10
+ preventScrollReset: l,
11
+ relative: u,
12
+ viewTransition: f,
13
+ ...m
14
+ } = a;
15
+ return /* @__PURE__ */ i("a", { href: r, ...m, ref: e, children: n });
16
+ });
17
+ p.displayName = "LinkDefault";
18
+ const h = v(
19
+ ({ to: t, children: n, className: a, style: e, ...r }, s) => {
20
+ const o = S(t), c = new URL(o, window.location.origin).pathname === window.location.pathname, l = typeof a == "function" ? a({ isActive: c, isPending: !1, isTransitioning: !1 }) : a, u = typeof e == "function" ? e({ isActive: c, isPending: !1, isTransitioning: !1 }) : e, {
21
+ reloadDocument: f,
22
+ replace: m,
23
+ state: j,
24
+ preventScrollReset: V,
25
+ relative: b,
26
+ viewTransition: G,
27
+ activeClassName: H,
28
+ activeStyle: I,
29
+ exact: X,
30
+ strict: q,
31
+ isActive: z,
32
+ ...k
33
+ } = r;
34
+ return /* @__PURE__ */ i("a", { ref: s, href: o, className: l, style: u, ...k, children: n });
35
+ }
36
+ );
37
+ h.displayName = "NavLinkDefault";
38
+ const A = ({ children: t }) => /* @__PURE__ */ i(d, { children: t }), w = ({ children: t }) => {
39
+ const n = window.location.pathname, a = O.toArray(t);
40
+ for (const e of a)
41
+ if (T(e))
42
+ if ("path" in e.props) {
43
+ const r = e.props.path;
44
+ if (!r) continue;
45
+ if (!!e.props.exact ? n === r : n.includes(r)) return e;
46
+ } else
47
+ return e;
48
+ return null;
49
+ }, _ = ({ render: t, children: n, ...a }) => n ? /* @__PURE__ */ i(d, { children: n }) : t ? /* @__PURE__ */ i(d, { children: t(a) }) : null, g = (t) => {
50
+ typeof t == "number" ? window.history.go(t) : window.location.href = t.toString();
51
+ }, D = () => {
52
+ const t = y;
53
+ return [new URLSearchParams(), t];
54
+ }, P = () => [], R = () => ({}), x = { ...window.location, state: {}, key: "" }, L = C({
55
+ Link: p,
56
+ NavLink: h,
57
+ Switch: w,
58
+ Route: _,
59
+ location: x,
60
+ navigate: g,
61
+ useSearchParams: D,
62
+ useMatches: P,
63
+ useParams: R
64
+ }), K = () => {
65
+ const { Outlet: t, ...n } = N(L);
66
+ return {
67
+ ...n,
68
+ isRouterVersion5: !t,
69
+ Outlet: t ?? A
70
+ };
71
+ }, Q = ({
72
+ children: t,
73
+ Link: n = p,
74
+ NavLink: a = h,
75
+ Outlet: e,
76
+ Switch: r = w,
77
+ Route: s = _,
78
+ location: o = x,
79
+ navigate: c = g,
80
+ useSearchParams: l = D,
81
+ useMatches: u = P,
82
+ useParams: f = R
83
+ }) => /* @__PURE__ */ i(
84
+ L.Provider,
85
+ {
86
+ value: {
87
+ Link: n,
88
+ NavLink: a,
89
+ Outlet: e,
90
+ Switch: r,
91
+ Route: s,
92
+ location: o,
93
+ navigate: c,
94
+ useSearchParams: l,
95
+ useMatches: u,
96
+ useParams: f
97
+ },
98
+ children: t
99
+ }
100
+ );
101
+ var F = /* @__PURE__ */ ((t) => (t.Dark = "dark", t.Light = "light", t.System = "system", t))(F || {}), M = /* @__PURE__ */ ((t) => (t.Standard = "std", t.Tritanopia = "tri", t.Protanopia = "pro", t.Deuteranopia = "deu", t))(M || {}), E = /* @__PURE__ */ ((t) => (t.Standard = "std", t.Low = "low", t.High = "high", t))(E || {});
102
+ const W = "dark-std-std", U = {
103
+ std: null,
104
+ pro: "protanopia",
105
+ deu: "deuteranopia",
106
+ tri: "tritanopia"
107
+ }, $ = {
108
+ std: null,
109
+ low: "dimmer",
110
+ high: "high-contrast"
111
+ };
112
+ function Y(t) {
113
+ const [n, a, e] = t.split("-");
114
+ if (a === "std" && e === "std") return null;
115
+ const r = [n], s = $[e];
116
+ s && r.push(s);
117
+ const o = U[a];
118
+ return o && r.push(o), r.join("-");
119
+ }
120
+ export {
121
+ E as C,
122
+ F as M,
123
+ Q as R,
124
+ M as a,
125
+ W as d,
126
+ Y as g,
127
+ y as n,
128
+ K as u
129
+ };
130
+ //# sourceMappingURL=types-lL2O4vS0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-lL2O4vS0.js","sources":["../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.js","../src/context/router-context.tsx","../src/context/theme/types.ts"],"sourcesContent":["/**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\nfunction noop() {\n // No operation performed.\n}\n\nexport default noop;\n","import {\n Children,\n ComponentPropsWithRef,\n ComponentType,\n createContext,\n forwardRef,\n isValidElement,\n ReactNode,\n useContext\n} from 'react'\nimport type {\n LinkProps,\n Location,\n NavigateFunction,\n NavLinkProps,\n OutletProps,\n Params,\n SetURLSearchParams,\n UIMatch\n} from 'react-router-dom'\n\nimport { noop } from 'lodash-es'\n\n// Props from react-router that shouldn't be passed to native anchor elements\ntype RouterLinkExcludedProps = Partial<\n Pick<LinkProps, 'reloadDocument' | 'replace' | 'state' | 'preventScrollReset' | 'relative'>\n> & {\n viewTransition?: boolean\n}\n\n// Additional v5 props that NavLink might receive at runtime\ntype RouterNavLinkV5Props = {\n activeClassName?: string\n activeStyle?: React.CSSProperties\n exact?: boolean\n strict?: boolean\n isActive?: (match: unknown, location: unknown) => boolean\n}\n\ninterface SwitchProps {\n children?: React.ReactNode\n location?: Location\n}\n\nconst resolveTo = (to: LinkProps['to']) => (typeof to === 'string' ? to : to.pathname || '/')\n\nconst LinkDefault = forwardRef<HTMLAnchorElement, LinkProps>(({ to, children, ...props }, ref) => {\n const href = resolveTo(to)\n // Filter out react-router specific props that shouldn't be passed to the DOM\n // These are destructured and prefixed with _ to exclude them from domSafeProps\n const {\n reloadDocument: _reloadDocument,\n replace: _replace,\n state: _state,\n preventScrollReset: _preventScrollReset,\n relative: _relative,\n viewTransition: _viewTransition,\n ...domSafeProps\n } = props as Omit<LinkProps, 'to' | 'children'> & RouterLinkExcludedProps\n return (\n <a href={href} {...domSafeProps} ref={ref}>\n {children}\n </a>\n )\n})\nLinkDefault.displayName = 'LinkDefault'\n\nconst NavLinkDefault = forwardRef<HTMLAnchorElement, NavLinkProps>(\n ({ to, children, className, style, ...props }, ref) => {\n const href = resolveTo(to)\n const isActive = new URL(href, window.location.origin).pathname === window.location.pathname\n\n const finalClassName =\n typeof className === 'function' ? className({ isActive, isPending: false, isTransitioning: false }) : className\n\n const finalStyle =\n typeof style === 'function' ? style({ isActive, isPending: false, isTransitioning: false }) : style\n\n // Filter out react-router v5/v6 specific props that shouldn't be passed to the DOM\n // These are destructured and prefixed with _ to exclude them from domSafeProps\n const {\n reloadDocument: _reloadDocument,\n replace: _replace,\n state: _state,\n preventScrollReset: _preventScrollReset,\n relative: _relative,\n viewTransition: _viewTransition,\n activeClassName: _activeClassName,\n activeStyle: _activeStyle,\n exact: _exact,\n strict: _strict,\n isActive: _isActive,\n ...domSafeProps\n } = props as Omit<NavLinkProps, 'to' | 'children' | 'className' | 'style'> &\n RouterLinkExcludedProps &\n RouterNavLinkV5Props\n\n return (\n <a ref={ref} href={href} className={finalClassName} style={finalStyle} {...domSafeProps}>\n {children}\n </a>\n )\n }\n)\nNavLinkDefault.displayName = 'NavLinkDefault'\n\nconst OutletDefault: ComponentType<OutletProps> = ({ children }) => <>{children}</>\n\nconst SwitchDefault: ComponentType<SwitchProps> = ({ children }) => {\n const currentPath = window.location.pathname\n const childrenArray = Children.toArray(children)\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue\n\n if ('path' in child.props) {\n const pathProp = child.props.path\n if (!pathProp) continue\n\n const exactProp = !!child.props.exact\n const isMatch = exactProp ? currentPath === pathProp : currentPath.includes(pathProp)\n\n if (isMatch) return child\n } else {\n return child\n }\n }\n\n return null\n}\n\ninterface ExtendedRouteProps {\n path?: string\n exact?: boolean\n render?: (props: object) => ReactNode\n children?: ReactNode\n}\n\nconst RouteDefault: ComponentType<ExtendedRouteProps> = ({ render, children, ...props }) => {\n if (children) {\n return <>{children}</>\n }\n\n if (render) {\n return <>{render(props)}</>\n }\n\n return null\n}\n\nconst navigateFnDefault: NavigateFunction = to => {\n if (typeof to === 'number') {\n window.history.go(to) // Supports navigate(-1), navigate(1), etc.\n } else {\n window.location.href = to.toString()\n }\n}\n\nconst useSearchParamsDefault = () => {\n const setSearchParams: SetURLSearchParams = noop\n return [new URLSearchParams(), setSearchParams] as const\n}\n\nconst useMatchesDefault = (): UIMatch[] => {\n return []\n}\n\nconst useParamsDefault = (): Params => {\n return {}\n}\n\nconst defaultLocation: Location = { ...window.location, state: {}, key: '' }\n\ninterface RouterContextType {\n Link: ComponentType<ComponentPropsWithRef<typeof LinkDefault>>\n NavLink: ComponentType<ComponentPropsWithRef<typeof NavLinkDefault>>\n Outlet?: ComponentType<OutletProps>\n Switch: ComponentType<SwitchProps>\n Route: ComponentType<ExtendedRouteProps>\n location: Location\n navigate: NavigateFunction\n useSearchParams: typeof useSearchParamsDefault\n useMatches: typeof useMatchesDefault\n useParams: typeof useParamsDefault\n}\n\ntype UseRouterContextType = Required<RouterContextType> & { isRouterVersion5: boolean }\n\nconst RouterContext = createContext<RouterContextType>({\n Link: LinkDefault,\n NavLink: NavLinkDefault,\n Switch: SwitchDefault,\n Route: RouteDefault,\n location: defaultLocation,\n navigate: navigateFnDefault,\n useSearchParams: useSearchParamsDefault,\n useMatches: useMatchesDefault,\n useParams: useParamsDefault\n})\n\nexport const useRouterContext = (): UseRouterContextType => {\n const { Outlet, ...ctx } = useContext(RouterContext)\n\n return {\n ...ctx,\n isRouterVersion5: !Outlet,\n Outlet: Outlet ?? OutletDefault\n }\n}\n\nexport const RouterContextProvider = ({\n children,\n Link = LinkDefault,\n NavLink = NavLinkDefault,\n Outlet,\n Switch = SwitchDefault,\n Route = RouteDefault,\n location = defaultLocation,\n navigate = navigateFnDefault,\n useSearchParams = useSearchParamsDefault,\n useMatches = useMatchesDefault,\n useParams = useParamsDefault\n}: {\n children: ReactNode\n} & Partial<RouterContextType>) => {\n return (\n <RouterContext.Provider\n value={{\n Link,\n NavLink,\n Outlet,\n Switch,\n Route,\n location,\n navigate,\n useSearchParams,\n useMatches,\n useParams\n }}\n >\n {children}\n </RouterContext.Provider>\n )\n}\n\nexport { NavLinkProps, LinkProps }\n","export enum ModeType {\n Dark = 'dark',\n Light = 'light',\n System = 'system'\n}\n\nexport enum ColorType {\n Standard = 'std',\n Tritanopia = 'tri',\n Protanopia = 'pro',\n Deuteranopia = 'deu'\n}\n\nexport enum ContrastType {\n Standard = 'std',\n Low = 'low',\n High = 'high'\n}\n\nexport type FullTheme = `${ModeType}-${ColorType}-${ContrastType}`\n\nexport interface IThemeStore {\n theme?: FullTheme\n setTheme: (theme: FullTheme) => void\n isLightTheme: boolean\n}\n\nexport const defaultTheme = `${ModeType.Dark}-${ColorType.Standard}-${ContrastType.Standard}` as FullTheme\n\nconst COLOR_TO_SUFFIX: Record<ColorType, string | null> = {\n [ColorType.Standard]: null,\n [ColorType.Protanopia]: 'protanopia',\n [ColorType.Deuteranopia]: 'deuteranopia',\n [ColorType.Tritanopia]: 'tritanopia'\n}\n\nconst CONTRAST_TO_SEGMENT: Record<ContrastType, string | null> = {\n [ContrastType.Standard]: null,\n [ContrastType.Low]: 'dimmer',\n [ContrastType.High]: 'high-contrast'\n}\n\n/**\n * Maps a FullTheme (e.g. \"dark-pro-high\") to the corresponding CSS theme\n * filename key (e.g. \"dark-high-contrast-protanopia\"). Returns null for\n * base themes (dark-std-std, light-std-std) that are already bundled.\n */\nexport function getThemeCSSName(theme: FullTheme): string | null {\n const [mode, color, contrast] = theme.split('-') as [ModeType, ColorType, ContrastType]\n\n /**\n * dark-std-std, light-std-std themes are already bundled\n */\n if (color === ColorType.Standard && contrast === ContrastType.Standard) return null\n\n const parts: string[] = [mode]\n const contrastSegment = CONTRAST_TO_SEGMENT[contrast]\n if (contrastSegment) parts.push(contrastSegment)\n const colorSuffix = COLOR_TO_SUFFIX[color]\n if (colorSuffix) parts.push(colorSuffix)\n\n return parts.join('-')\n}\n"],"names":["noop","resolveTo","to","LinkDefault","forwardRef","children","props","ref","href","_reloadDocument","_replace","_state","_preventScrollReset","_relative","_viewTransition","domSafeProps","NavLinkDefault","className","style","isActive","finalClassName","finalStyle","_activeClassName","_activeStyle","_exact","_strict","_isActive","jsx","OutletDefault","SwitchDefault","currentPath","childrenArray","Children","child","isValidElement","pathProp","RouteDefault","render","Fragment","navigateFnDefault","useSearchParamsDefault","setSearchParams","useMatchesDefault","useParamsDefault","defaultLocation","RouterContext","createContext","useRouterContext","Outlet","ctx","useContext","RouterContextProvider","Link","NavLink","Switch","Route","location","navigate","useSearchParams","useMatches","useParams","ModeType","ColorType","ContrastType","defaultTheme","COLOR_TO_SUFFIX","CONTRAST_TO_SEGMENT","getThemeCSSName","theme","mode","color","contrast","parts","contrastSegment","colorSuffix"],"mappings":";;AAYA,SAASA,IAAO;AAEhB;AC8BA,MAAMC,IAAY,CAACC,MAAyB,OAAOA,KAAO,WAAWA,IAAKA,EAAG,YAAY,KAEnFC,IAAcC,EAA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wB;AAAA,EACxB,KAAmB;AAAA,EACnB,MAAoB;AACvB;AAOO,SAASC,EAAgBC,GAAiC;AAC/D,QAAM,CAACC,GAAMC,GAAOC,CAAQ,IAAIH,EAAM,MAAM,GAAG;AAK/C,MAAIE,MAAU,SAAsBC,MAAa,MAA8B,QAAA;AAEzE,QAAAC,IAAkB,CAACH,CAAI,GACvBI,IAAkBP,EAAoBK,CAAQ;AAChD,EAAAE,KAAuBD,EAAA,KAAKC,CAAe;AACzC,QAAAC,IAAcT,EAAgBK,CAAK;AACrC,SAAAI,KAAmBF,EAAA,KAAKE,CAAW,GAEhCF,EAAM,KAAK,GAAG;AACvB;","x_google_ignoreList":[0]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@harnessio/ui",
3
3
  "description": "Harness Canary UI component library",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -119,8 +119,8 @@
119
119
  "vaul": "^1.1.2",
120
120
  "yaml": "^2.7.0",
121
121
  "zod": "^3.23.8",
122
- "@harnessio/core-design-system": "0.0.1",
123
122
  "@harnessio/yaml-editor": "0.25.0",
123
+ "@harnessio/core-design-system": "0.0.1",
124
124
  "@harnessio/pipeline-graph": "1.9.6"
125
125
  },
126
126
  "peerDependencies": {
@@ -1,109 +0,0 @@
1
- import { jsx as i, Fragment as f } from "react/jsx-runtime";
2
- import { useContext as k, createContext as N, forwardRef as p, Children as O, isValidElement as C } from "react";
3
- function y() {
4
- }
5
- const m = (t) => typeof t == "string" ? t : t.pathname || "/", h = p(({ to: t, children: e, ...a }, n) => {
6
- const o = m(t);
7
- return /* @__PURE__ */ i("a", { href: o, ...a, ref: n, children: e });
8
- });
9
- h.displayName = "LinkDefault";
10
- const d = p(
11
- ({ to: t, children: e, className: a, style: n, ...o }, s) => {
12
- const r = m(t), c = new URL(r, window.location.origin).pathname === window.location.pathname, u = typeof a == "function" ? a({ isActive: c, isPending: !1, isTransitioning: !1 }) : a, l = typeof n == "function" ? n({ isActive: c, isPending: !1, isTransitioning: !1 }) : n;
13
- return /* @__PURE__ */ i("a", { ref: s, href: r, className: u, style: l, ...o, children: e });
14
- }
15
- );
16
- d.displayName = "NavLinkDefault";
17
- const A = ({ children: t }) => /* @__PURE__ */ i(f, { children: t }), g = ({ children: t }) => {
18
- const e = window.location.pathname, a = O.toArray(t);
19
- for (const n of a)
20
- if (C(n))
21
- if ("path" in n.props) {
22
- const o = n.props.path;
23
- if (!o) continue;
24
- if (!!n.props.exact ? e === o : e.includes(o)) return n;
25
- } else
26
- return n;
27
- return null;
28
- }, w = ({ render: t, children: e, ...a }) => e ? /* @__PURE__ */ i(f, { children: e }) : t ? /* @__PURE__ */ i(f, { children: t(a) }) : null, S = (t) => {
29
- typeof t == "number" ? window.history.go(t) : window.location.href = t.toString();
30
- }, P = () => {
31
- const t = y;
32
- return [new URLSearchParams(), t];
33
- }, v = () => [], D = () => ({}), x = { ...window.location, state: {}, key: "" }, L = N({
34
- Link: h,
35
- NavLink: d,
36
- Switch: g,
37
- Route: w,
38
- location: x,
39
- navigate: S,
40
- useSearchParams: P,
41
- useMatches: v,
42
- useParams: D
43
- }), j = () => {
44
- const { Outlet: t, ...e } = k(L);
45
- return {
46
- ...e,
47
- isRouterVersion5: !t,
48
- Outlet: t ?? A
49
- };
50
- }, V = ({
51
- children: t,
52
- Link: e = h,
53
- NavLink: a = d,
54
- Outlet: n,
55
- Switch: o = g,
56
- Route: s = w,
57
- location: r = x,
58
- navigate: c = S,
59
- useSearchParams: u = P,
60
- useMatches: l = v,
61
- useParams: R = D
62
- }) => /* @__PURE__ */ i(
63
- L.Provider,
64
- {
65
- value: {
66
- Link: e,
67
- NavLink: a,
68
- Outlet: n,
69
- Switch: o,
70
- Route: s,
71
- location: r,
72
- navigate: c,
73
- useSearchParams: u,
74
- useMatches: l,
75
- useParams: R
76
- },
77
- children: t
78
- }
79
- );
80
- var F = /* @__PURE__ */ ((t) => (t.Dark = "dark", t.Light = "light", t.System = "system", t))(F || {}), M = /* @__PURE__ */ ((t) => (t.Standard = "std", t.Tritanopia = "tri", t.Protanopia = "pro", t.Deuteranopia = "deu", t))(M || {}), T = /* @__PURE__ */ ((t) => (t.Standard = "std", t.Low = "low", t.High = "high", t))(T || {});
81
- const b = "dark-std-std", _ = {
82
- std: null,
83
- pro: "protanopia",
84
- deu: "deuteranopia",
85
- tri: "tritanopia"
86
- }, E = {
87
- std: null,
88
- low: "dimmer",
89
- high: "high-contrast"
90
- };
91
- function G(t) {
92
- const [e, a, n] = t.split("-");
93
- if (a === "std" && n === "std") return null;
94
- const o = [e], s = E[n];
95
- s && o.push(s);
96
- const r = _[a];
97
- return r && o.push(r), o.join("-");
98
- }
99
- export {
100
- T as C,
101
- F as M,
102
- V as R,
103
- M as a,
104
- b as d,
105
- G as g,
106
- y as n,
107
- j as u
108
- };
109
- //# sourceMappingURL=types-BbYIXHHK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-BbYIXHHK.js","sources":["../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.js","../src/context/router-context.tsx","../src/context/theme/types.ts"],"sourcesContent":["/**\n * This method returns `undefined`.\n *\n * @static\n * @memberOf _\n * @since 2.3.0\n * @category Util\n * @example\n *\n * _.times(2, _.noop);\n * // => [undefined, undefined]\n */\nfunction noop() {\n // No operation performed.\n}\n\nexport default noop;\n","import {\n Children,\n ComponentPropsWithRef,\n ComponentType,\n createContext,\n forwardRef,\n isValidElement,\n ReactNode,\n useContext\n} from 'react'\nimport type {\n LinkProps,\n Location,\n NavigateFunction,\n NavLinkProps,\n OutletProps,\n Params,\n SetURLSearchParams,\n UIMatch\n} from 'react-router-dom'\n\nimport { noop } from 'lodash-es'\n\ninterface SwitchProps {\n children?: React.ReactNode\n location?: Location\n}\n\nconst resolveTo = (to: LinkProps['to']) => (typeof to === 'string' ? to : to.pathname || '/')\n\nconst LinkDefault = forwardRef<HTMLAnchorElement, LinkProps>(({ to, children, ...props }, ref) => {\n const href = resolveTo(to)\n return (\n <a href={href} {...props} ref={ref}>\n {children}\n </a>\n )\n})\nLinkDefault.displayName = 'LinkDefault'\n\nconst NavLinkDefault = forwardRef<HTMLAnchorElement, NavLinkProps>(\n ({ to, children, className, style, ...props }, ref) => {\n const href = resolveTo(to)\n const isActive = new URL(href, window.location.origin).pathname === window.location.pathname\n\n const finalClassName =\n typeof className === 'function' ? className({ isActive, isPending: false, isTransitioning: false }) : className\n\n const finalStyle =\n typeof style === 'function' ? style({ isActive, isPending: false, isTransitioning: false }) : style\n\n return (\n <a ref={ref} href={href} className={finalClassName} style={finalStyle} {...props}>\n {children}\n </a>\n )\n }\n)\nNavLinkDefault.displayName = 'NavLinkDefault'\n\nconst OutletDefault: ComponentType<OutletProps> = ({ children }) => <>{children}</>\n\nconst SwitchDefault: ComponentType<SwitchProps> = ({ children }) => {\n const currentPath = window.location.pathname\n const childrenArray = Children.toArray(children)\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue\n\n if ('path' in child.props) {\n const pathProp = child.props.path\n if (!pathProp) continue\n\n const exactProp = !!child.props.exact\n const isMatch = exactProp ? currentPath === pathProp : currentPath.includes(pathProp)\n\n if (isMatch) return child\n } else {\n return child\n }\n }\n\n return null\n}\n\ninterface ExtendedRouteProps {\n path?: string\n exact?: boolean\n render?: (props: object) => ReactNode\n children?: ReactNode\n}\n\nconst RouteDefault: ComponentType<ExtendedRouteProps> = ({ render, children, ...props }) => {\n if (children) {\n return <>{children}</>\n }\n\n if (render) {\n return <>{render(props)}</>\n }\n\n return null\n}\n\nconst navigateFnDefault: NavigateFunction = to => {\n if (typeof to === 'number') {\n window.history.go(to) // Supports navigate(-1), navigate(1), etc.\n } else {\n window.location.href = to.toString()\n }\n}\n\nconst useSearchParamsDefault = () => {\n const setSearchParams: SetURLSearchParams = noop\n return [new URLSearchParams(), setSearchParams] as const\n}\n\nconst useMatchesDefault = (): UIMatch[] => {\n return []\n}\n\nconst useParamsDefault = (): Params => {\n return {}\n}\n\nconst defaultLocation: Location = { ...window.location, state: {}, key: '' }\n\ninterface RouterContextType {\n Link: ComponentType<ComponentPropsWithRef<typeof LinkDefault>>\n NavLink: ComponentType<ComponentPropsWithRef<typeof NavLinkDefault>>\n Outlet?: ComponentType<OutletProps>\n Switch: ComponentType<SwitchProps>\n Route: ComponentType<ExtendedRouteProps>\n location: Location\n navigate: NavigateFunction\n useSearchParams: typeof useSearchParamsDefault\n useMatches: typeof useMatchesDefault\n useParams: typeof useParamsDefault\n}\n\ntype UseRouterContextType = Required<RouterContextType> & { isRouterVersion5: boolean }\n\nconst RouterContext = createContext<RouterContextType>({\n Link: LinkDefault,\n NavLink: NavLinkDefault,\n Switch: SwitchDefault,\n Route: RouteDefault,\n location: defaultLocation,\n navigate: navigateFnDefault,\n useSearchParams: useSearchParamsDefault,\n useMatches: useMatchesDefault,\n useParams: useParamsDefault\n})\n\nexport const useRouterContext = (): UseRouterContextType => {\n const { Outlet, ...ctx } = useContext(RouterContext)\n\n return {\n ...ctx,\n isRouterVersion5: !Outlet,\n Outlet: Outlet ?? OutletDefault\n }\n}\n\nexport const RouterContextProvider = ({\n children,\n Link = LinkDefault,\n NavLink = NavLinkDefault,\n Outlet,\n Switch = SwitchDefault,\n Route = RouteDefault,\n location = defaultLocation,\n navigate = navigateFnDefault,\n useSearchParams = useSearchParamsDefault,\n useMatches = useMatchesDefault,\n useParams = useParamsDefault\n}: {\n children: ReactNode\n} & Partial<RouterContextType>) => {\n return (\n <RouterContext.Provider\n value={{\n Link,\n NavLink,\n Outlet,\n Switch,\n Route,\n location,\n navigate,\n useSearchParams,\n useMatches,\n useParams\n }}\n >\n {children}\n </RouterContext.Provider>\n )\n}\n\nexport { NavLinkProps, LinkProps }\n","export enum ModeType {\n Dark = 'dark',\n Light = 'light',\n System = 'system'\n}\n\nexport enum ColorType {\n Standard = 'std',\n Tritanopia = 'tri',\n Protanopia = 'pro',\n Deuteranopia = 'deu'\n}\n\nexport enum ContrastType {\n Standard = 'std',\n Low = 'low',\n High = 'high'\n}\n\nexport type FullTheme = `${ModeType}-${ColorType}-${ContrastType}`\n\nexport interface IThemeStore {\n theme?: FullTheme\n setTheme: (theme: FullTheme) => void\n isLightTheme: boolean\n}\n\nexport const defaultTheme = `${ModeType.Dark}-${ColorType.Standard}-${ContrastType.Standard}` as FullTheme\n\nconst COLOR_TO_SUFFIX: Record<ColorType, string | null> = {\n [ColorType.Standard]: null,\n [ColorType.Protanopia]: 'protanopia',\n [ColorType.Deuteranopia]: 'deuteranopia',\n [ColorType.Tritanopia]: 'tritanopia'\n}\n\nconst CONTRAST_TO_SEGMENT: Record<ContrastType, string | null> = {\n [ContrastType.Standard]: null,\n [ContrastType.Low]: 'dimmer',\n [ContrastType.High]: 'high-contrast'\n}\n\n/**\n * Maps a FullTheme (e.g. \"dark-pro-high\") to the corresponding CSS theme\n * filename key (e.g. \"dark-high-contrast-protanopia\"). Returns null for\n * base themes (dark-std-std, light-std-std) that are already bundled.\n */\nexport function getThemeCSSName(theme: FullTheme): string | null {\n const [mode, color, contrast] = theme.split('-') as [ModeType, ColorType, ContrastType]\n\n /**\n * dark-std-std, light-std-std themes are already bundled\n */\n if (color === ColorType.Standard && contrast === ContrastType.Standard) return null\n\n const parts: string[] = [mode]\n const contrastSegment = CONTRAST_TO_SEGMENT[contrast]\n if (contrastSegment) parts.push(contrastSegment)\n const colorSuffix = COLOR_TO_SUFFIX[color]\n if (colorSuffix) parts.push(colorSuffix)\n\n return parts.join('-')\n}\n"],"names":["noop","resolveTo","to","LinkDefault","forwardRef","children","props","ref","href","NavLinkDefault","className","style","isActive","finalClassName","finalStyle","jsx","OutletDefault","SwitchDefault","currentPath","childrenArray","Children","child","isValidElement","pathProp","RouteDefault","render","Fragment","navigateFnDefault","useSearchParamsDefault","setSearchParams","useMatchesDefault","useParamsDefault","defaultLocation","RouterContext","createContext","useRouterContext","Outlet","ctx","useContext","RouterContextProvider","Link","NavLink","Switch","Route","location","navigate","useSearchParams","useMatches","useParams","ModeType","ColorType","ContrastType","defaultTheme","COLOR_TO_SUFFIX","CONTRAST_TO_SEGMENT","getThemeCSSName","theme","mode","color","contrast","parts","contrastSegment","colorSuffix"],"mappings":";;AAYA,SAASA,IAAO;AAEhB;ACcA,MAAMC,IAAY,CAACC,MAAyB,OAAOA,KAAO,WAAWA,IAAKA,EAAG,YAAY,KAEnFC,IAAcC,EAAyC,CAAC,EAAE,IAAAF,GAAI,UAAAG,GAAU,GAAGC,EAAM,GAAGC,MAAQ;AAC1F,QAAAC,IAAOP,EAAUC,CAAE;AACzB,2BACG,KAAE,EAAA,MAAAM,GAAa,GAAGF,GAAO,KAAAC,GACvB,UAAAF,GACH;AAEJ,CAAC;AACDF,EAAY,cAAc;AAE1B,MAAMM,IAAiBL;AAAA,EACrB,CAAC,EAAE,IAAAF,GAAI,UAAAG,GAAU,WAAAK,GAAW,OAAAC,GAAO,GAAGL,EAAM,GAAGC,MAAQ;AAC/C,UAAAC,IAAOP,EAAUC,CAAE,GACnBU,IAAW,IAAI,IAAIJ,GAAM,OAAO,SAAS,MAAM,EAAE,aAAa,OAAO,SAAS,UAE9EK,IACJ,OAAOH,KAAc,aAAaA,EAAU,EAAE,UAAAE,GAAU,WAAW,IAAO,iBAAiB,GAAM,CAAC,IAAIF,GAElGI,IACJ,OAAOH,KAAU,aAAaA,EAAM,EAAE,UAAAC,GAAU,WAAW,IAAO,iBAAiB,GAAM,CAAC,IAAID;AAG9F,WAAA,gBAAAI,EAAC,KAAE,EAAA,KAAAR,GAAU,MAAAC,GAAY,WAAWK,GAAgB,OAAOC,GAAa,GAAGR,GACxE,UAAAD,EACH,CAAA;AAAA,EAAA;AAGN;AACAI,EAAe,cAAc;AAE7B,MAAMO,IAA4C,CAAC,EAAE,UAAAX,EAAS,6BAAS,UAAAA,GAAS,GAE1EY,IAA4C,CAAC,EAAE,UAAAZ,QAAe;AAC5D,QAAAa,IAAc,OAAO,SAAS,UAC9BC,IAAgBC,EA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