@uva-glass/component-library 2.1.0 → 2.2.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/dist/SelectListbox.module-BWavTmq8.js +25 -0
- package/dist/SelectListbox.module-BWavTmq8.js.map +1 -0
- package/dist/assets/SelectListbox.css +1 -1
- package/dist/assets/ToggleSwitch.css +1 -0
- package/dist/components/SelectListbox/SelectListBox.stories.js +2 -2
- package/dist/components/SelectListbox/SelectListBox.stories.js.map +1 -1
- package/dist/components/SelectListbox/SelectListbox.d.ts +4 -2
- package/dist/components/SelectListbox/SelectListbox.js +31 -29
- package/dist/components/SelectListbox/SelectListbox.js.map +1 -1
- package/dist/components/SelectListbox/components/SelectButton.d.ts +1 -1
- package/dist/components/SelectListbox/components/SelectButton.js +1 -1
- package/dist/components/SelectListbox/components/SelectButton.js.map +1 -1
- package/dist/components/SelectListbox/components/SelectContainer.js +1 -1
- package/dist/components/SelectListbox/components/SelectOption.js +1 -1
- package/dist/components/SelectListbox/components/SelectOptionBox.js +1 -1
- package/dist/components/ToggleSwitch/ToggleSwitch.d.ts +15 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.js +66 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.js.map +1 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.stories.d.ts +5 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.stories.js +26 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.stories.js.map +1 -0
- package/dist/components/ToggleSwitch/index.d.ts +1 -0
- package/dist/components/ToggleSwitch/index.js +5 -0
- package/dist/components/ToggleSwitch/index.js.map +1 -0
- package/dist/components/hooks/usePositionedFloaters.d.ts +1 -0
- package/dist/components/hooks/usePositionedFloaters.js +22 -20
- package/dist/components/hooks/usePositionedFloaters.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +30 -28
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +30 -28
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/dist/SelectListbox.module-ByNtXEyE.js +0 -24
- package/dist/SelectListbox.module-ByNtXEyE.js.map +0 -1
|
@@ -14,7 +14,9 @@ export interface SelectListboxProps {
|
|
|
14
14
|
/** `true` to render the labels in bold; otherwise, `false`. The default is `false`. */
|
|
15
15
|
buttonLabelBold?: boolean;
|
|
16
16
|
/** The variant of the select box. */
|
|
17
|
-
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';
|
|
17
|
+
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight' | 'darkBorder';
|
|
18
|
+
/** If true sets the option dropdown min-width to the width of the select button. */
|
|
19
|
+
fullWidth?: boolean;
|
|
18
20
|
/** The size of the select box. */
|
|
19
21
|
size?: 'small' | 'medium' | 'default';
|
|
20
22
|
/** `true` to align the right side of the options with the select box; otherwise, `false` to align on the left side. */
|
|
@@ -26,6 +28,6 @@ export interface SelectListboxProps {
|
|
|
26
28
|
}
|
|
27
29
|
/** Represents a component to render a select list box. */
|
|
28
30
|
export declare const SelectListbox: {
|
|
29
|
-
({ options, variant, size, optionPositionRight, defaultValue, maxOptionHeight, disabled, buttonLabelProp, buttonLabelBold, onChange, children, }: PropsWithChildren<SelectListboxProps>): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
({ options, variant, fullWidth, size, optionPositionRight, defaultValue, maxOptionHeight, disabled, buttonLabelProp, buttonLabelBold, onChange, children, }: PropsWithChildren<SelectListboxProps>): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
SelectOption: ({ option, index, children }: import('./components/SelectOption').SelectOptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
33
|
};
|
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as b } from "react/jsx-runtime";
|
|
2
2
|
import { useState as t } from "react";
|
|
3
|
-
import { SelectProvider as
|
|
4
|
-
import { SelectButton as
|
|
5
|
-
import { SelectContainer as
|
|
6
|
-
import { SelectOptionBox as
|
|
7
|
-
import { SelectOption as
|
|
8
|
-
import { usePositionedFloaters as
|
|
9
|
-
const
|
|
3
|
+
import { SelectProvider as P } from "./SelectProvider.js";
|
|
4
|
+
import { SelectButton as B } from "./components/SelectButton.js";
|
|
5
|
+
import { SelectContainer as O } from "./components/SelectContainer.js";
|
|
6
|
+
import { SelectOptionBox as g } from "./components/SelectOptionBox.js";
|
|
7
|
+
import { SelectOption as j } from "./components/SelectOption.js";
|
|
8
|
+
import { usePositionedFloaters as k } from "../hooks/usePositionedFloaters.js";
|
|
9
|
+
const v = ({
|
|
10
10
|
options: o,
|
|
11
11
|
variant: i,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
fullWidth: r = !1,
|
|
13
|
+
size: n = "default",
|
|
14
|
+
optionPositionRight: l,
|
|
15
|
+
defaultValue: m = -1,
|
|
16
|
+
maxOptionHeight: s,
|
|
17
|
+
disabled: f,
|
|
17
18
|
buttonLabelProp: c = "label",
|
|
18
|
-
buttonLabelBold:
|
|
19
|
-
onChange:
|
|
19
|
+
buttonLabelBold: p,
|
|
20
|
+
onChange: a,
|
|
20
21
|
children: S
|
|
21
22
|
}) => {
|
|
22
|
-
const [
|
|
23
|
+
const [u, x] = t(null), [d, h] = t(null), { style: E } = k(u, d, {
|
|
23
24
|
mouseEvent: "click",
|
|
24
25
|
position: "bottomLeft",
|
|
25
26
|
offset: 4,
|
|
26
|
-
maxFixedHeight:
|
|
27
|
-
horizontalPosition:
|
|
28
|
-
mobileBreakpoint: "28rem"
|
|
27
|
+
maxFixedHeight: s,
|
|
28
|
+
horizontalPosition: l ? "right" : "left",
|
|
29
|
+
mobileBreakpoint: "28rem",
|
|
30
|
+
fullWidth: r
|
|
29
31
|
});
|
|
30
|
-
return /* @__PURE__ */ e(
|
|
32
|
+
return /* @__PURE__ */ e(P, { options: o, defaultValue: m, children: /* @__PURE__ */ b(O, { children: [
|
|
31
33
|
/* @__PURE__ */ e(
|
|
32
|
-
|
|
34
|
+
B,
|
|
33
35
|
{
|
|
34
|
-
disabled:
|
|
36
|
+
disabled: f,
|
|
35
37
|
buttonLabelProp: c,
|
|
36
|
-
buttonLabelBold:
|
|
38
|
+
buttonLabelBold: p,
|
|
37
39
|
variant: i,
|
|
38
|
-
size:
|
|
39
|
-
onChange:
|
|
40
|
-
ref:
|
|
40
|
+
size: n,
|
|
41
|
+
onChange: a,
|
|
42
|
+
ref: h
|
|
41
43
|
}
|
|
42
44
|
),
|
|
43
|
-
/* @__PURE__ */ e(
|
|
45
|
+
/* @__PURE__ */ e(g, { ref: x, ...E, children: S })
|
|
44
46
|
] }) });
|
|
45
47
|
};
|
|
46
|
-
|
|
48
|
+
v.SelectOption = j;
|
|
47
49
|
export {
|
|
48
|
-
|
|
50
|
+
v as SelectListbox
|
|
49
51
|
};
|
|
50
52
|
//# sourceMappingURL=SelectListbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectListbox.js","sources":["../../../src/components/SelectListbox/SelectListbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport type { PropsWithChildren } from 'react';\nimport type { OptionValue, SelectValue } from './SelectProvider';\n\nimport { SelectProvider } from './SelectProvider';\nimport { SelectButton } from './components/SelectButton';\nimport { SelectContainer } from './components/SelectContainer';\nimport { SelectOptionBox } from './components/SelectOptionBox';\nimport { SelectOption } from './components/SelectOption';\n\nimport { usePositionedFloaters } from 'components/hooks/usePositionedFloaters';\n\nexport interface SelectListboxProps {\n /** The possible options to select. */\n options: OptionValue[];\n /** The selected value by default. */\n defaultValue?: SelectValue;\n /** The max height of the options. */\n maxOptionHeight?: `${number}${'px' | 'rem'}`;\n /** `true` to disable the select box; otherwise, `false`. The default is `false`. */\n disabled?: boolean;\n /** The name of the property in the options structure that contains the label of the options. */\n buttonLabelProp?: string;\n /** `true` to render the labels in bold; otherwise, `false`. The default is `false`. */\n buttonLabelBold?: boolean;\n /** The variant of the select box. */\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';\n /** The size of the select box. */\n size?: 'small' | 'medium' | 'default';\n /** `true` to align the right side of the options with the select box; otherwise, `false` to align on the left side. */\n optionPositionRight?: boolean;\n /** The breakpoint at which to switch to the mobile view. */\n mobileBreakpoint?: `${number}${'px' | 'rem'}`;\n /** The callback function that is invoked when an option is selected. */\n onChange?: (option: OptionValue) => void;\n}\n\n/** Represents a component to render a select list box. */\nexport const SelectListbox = ({\n options,\n variant,\n size = 'default',\n optionPositionRight,\n defaultValue = -1,\n maxOptionHeight,\n disabled,\n buttonLabelProp = 'label',\n buttonLabelBold,\n onChange,\n children,\n}: PropsWithChildren<SelectListboxProps>) => {\n const [positionElement, setPositionElement] = useState<HTMLElement | null>(null);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const { style: positionStyle } = usePositionedFloaters(positionElement, referenceElement, {\n mouseEvent: 'click',\n position: 'bottomLeft',\n offset: 4,\n maxFixedHeight: maxOptionHeight,\n horizontalPosition: optionPositionRight ? 'right' : 'left',\n mobileBreakpoint: '28rem',\n });\n\n return (\n <SelectProvider options={options} defaultValue={defaultValue}>\n <SelectContainer>\n <SelectButton\n disabled={disabled}\n buttonLabelProp={buttonLabelProp}\n buttonLabelBold={buttonLabelBold}\n variant={variant}\n size={size}\n onChange={onChange}\n ref={setReferenceElement}\n />\n\n <SelectOptionBox ref={setPositionElement} {...positionStyle}>\n {children}\n </SelectOptionBox>\n </SelectContainer>\n </SelectProvider>\n );\n};\n\nSelectListbox.SelectOption = SelectOption;\n"],"names":["SelectListbox","options","variant","size","optionPositionRight","defaultValue","maxOptionHeight","disabled","buttonLabelProp","buttonLabelBold","onChange","children","positionElement","setPositionElement","useState","referenceElement","setReferenceElement","positionStyle","usePositionedFloaters","jsx","SelectProvider","SelectContainer","SelectButton","SelectOptionBox","SelectOption"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"SelectListbox.js","sources":["../../../src/components/SelectListbox/SelectListbox.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport type { PropsWithChildren } from 'react';\nimport type { OptionValue, SelectValue } from './SelectProvider';\n\nimport { SelectProvider } from './SelectProvider';\nimport { SelectButton } from './components/SelectButton';\nimport { SelectContainer } from './components/SelectContainer';\nimport { SelectOptionBox } from './components/SelectOptionBox';\nimport { SelectOption } from './components/SelectOption';\n\nimport { usePositionedFloaters } from 'components/hooks/usePositionedFloaters';\n\nexport interface SelectListboxProps {\n /** The possible options to select. */\n options: OptionValue[];\n /** The selected value by default. */\n defaultValue?: SelectValue;\n /** The max height of the options. */\n maxOptionHeight?: `${number}${'px' | 'rem'}`;\n /** `true` to disable the select box; otherwise, `false`. The default is `false`. */\n disabled?: boolean;\n /** The name of the property in the options structure that contains the label of the options. */\n buttonLabelProp?: string;\n /** `true` to render the labels in bold; otherwise, `false`. The default is `false`. */\n buttonLabelBold?: boolean;\n /** The variant of the select box. */\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight' | 'darkBorder';\n /** If true sets the option dropdown min-width to the width of the select button. */\n fullWidth?: boolean;\n /** The size of the select box. */\n size?: 'small' | 'medium' | 'default';\n /** `true` to align the right side of the options with the select box; otherwise, `false` to align on the left side. */\n optionPositionRight?: boolean;\n /** The breakpoint at which to switch to the mobile view. */\n mobileBreakpoint?: `${number}${'px' | 'rem'}`;\n /** The callback function that is invoked when an option is selected. */\n onChange?: (option: OptionValue) => void;\n}\n\n/** Represents a component to render a select list box. */\nexport const SelectListbox = ({\n options,\n variant,\n fullWidth = false,\n size = 'default',\n optionPositionRight,\n defaultValue = -1,\n maxOptionHeight,\n disabled,\n buttonLabelProp = 'label',\n buttonLabelBold,\n onChange,\n children,\n}: PropsWithChildren<SelectListboxProps>) => {\n const [positionElement, setPositionElement] = useState<HTMLElement | null>(null);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const { style: positionStyle } = usePositionedFloaters(positionElement, referenceElement, {\n mouseEvent: 'click',\n position: 'bottomLeft',\n offset: 4,\n maxFixedHeight: maxOptionHeight,\n horizontalPosition: optionPositionRight ? 'right' : 'left',\n mobileBreakpoint: '28rem',\n fullWidth,\n });\n\n return (\n <SelectProvider options={options} defaultValue={defaultValue}>\n <SelectContainer>\n <SelectButton\n disabled={disabled}\n buttonLabelProp={buttonLabelProp}\n buttonLabelBold={buttonLabelBold}\n variant={variant}\n size={size}\n onChange={onChange}\n ref={setReferenceElement}\n />\n\n <SelectOptionBox ref={setPositionElement} {...positionStyle}>\n {children}\n </SelectOptionBox>\n </SelectContainer>\n </SelectProvider>\n );\n};\n\nSelectListbox.SelectOption = SelectOption;\n"],"names":["SelectListbox","options","variant","fullWidth","size","optionPositionRight","defaultValue","maxOptionHeight","disabled","buttonLabelProp","buttonLabelBold","onChange","children","positionElement","setPositionElement","useState","referenceElement","setReferenceElement","positionStyle","usePositionedFloaters","jsx","SelectProvider","SelectContainer","SelectButton","SelectOptionBox","SelectOption"],"mappings":";;;;;;;;AAyCO,MAAMA,IAAgB,CAAC;AAAA,EAC5B,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,qBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,MAA6C;AAC3C,QAAM,CAACC,GAAiBC,CAAkB,IAAIC,EAA6B,IAAI,GACzE,CAACC,GAAkBC,CAAmB,IAAIF,EAA6B,IAAI,GAC3E,EAAE,OAAOG,EAAA,IAAkBC,EAAsBN,GAAiBG,GAAkB;AAAA,IACxF,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgBT;AAAA,IAChB,oBAAoBF,IAAsB,UAAU;AAAA,IACpD,kBAAkB;AAAA,IAClB,WAAAF;AAAA,EAAA,CACD;AAED,SACG,gBAAAiB,EAAAC,GAAA,EAAe,SAAApB,GAAkB,cAAAK,GAChC,4BAACgB,GACC,EAAA,UAAA;AAAA,IAAA,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QACC,UAAAf;AAAA,QACA,iBAAAC;AAAA,QACA,iBAAAC;AAAA,QACA,SAAAR;AAAA,QACA,MAAAE;AAAA,QACA,UAAAO;AAAA,QACA,KAAKM;AAAA,MAAA;AAAA,IACP;AAAA,sBAECO,GAAgB,EAAA,KAAKV,GAAqB,GAAGI,GAC3C,UAAAN,EACH,CAAA;AAAA,EAAA,EAAA,CACF,EACF,CAAA;AAEJ;AAEAZ,EAAc,eAAeyB;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OptionValue } from 'components/SelectListbox/SelectProvider';
|
|
2
2
|
export interface SelectButtonProps {
|
|
3
|
-
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';
|
|
3
|
+
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight' | 'darkBorder';
|
|
4
4
|
size?: 'small' | 'medium' | 'default';
|
|
5
5
|
onChange?: (option: OptionValue) => void;
|
|
6
6
|
buttonLabelProp?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as a, jsxs as C } from "react/jsx-runtime";
|
|
2
2
|
import { c as f } from "../../../clsx-OuTLNxxd.js";
|
|
3
3
|
import { forwardRef as E, useRef as g, useEffect as c } from "react";
|
|
4
|
-
import { s as t } from "../../../SelectListbox.module-
|
|
4
|
+
import { s as t } from "../../../SelectListbox.module-BWavTmq8.js";
|
|
5
5
|
import { Icon as L } from "../../Icon/Icon.js";
|
|
6
6
|
import { useSelect as N } from "../SelectProvider.js";
|
|
7
7
|
const O = E((d, u) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectButton.js","sources":["../../../../src/components/SelectListbox/components/SelectButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, forwardRef } from 'react';\n\nimport type { KeyboardEvent } from 'react';\nimport type { OptionValue, SelectValue } from 'components/SelectListbox/SelectProvider';\n\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\nimport { Icon } from 'components/Icon';\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\n\nexport interface SelectButtonProps {\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';\n size?: 'small' | 'medium' | 'default';\n onChange?: (option: OptionValue) => void;\n buttonLabelProp?: string;\n buttonLabelBold?: boolean;\n disabled?: boolean;\n}\n\nexport const SelectButton = forwardRef<HTMLButtonElement, SelectButtonProps>((props, ref) => {\n const { variant, size = 'default', onChange, buttonLabelProp = 'label', buttonLabelBold, disabled = false } = props;\n const buttonWrapper = useRef<HTMLSpanElement>(null);\n const isFirstRender = useRef(true);\n const { listboxId, isOpen, selectedValue, toggleListbox, setIsOpen, setActiveIndex, options } = useSelect() || {};\n\n const onTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n if (!isOpen) {\n setIsOpen(true);\n return;\n }\n break;\n case 'Escape':\n if (isOpen) {\n event.stopPropagation();\n setActiveIndex(options.findIndex((option) => option.value === selectedValue?.value));\n setIsOpen(false);\n }\n break;\n }\n };\n\n useEffect(() => {\n isOpen\n ? (buttonWrapper.current?.children[0] as HTMLButtonElement).blur()\n : !isFirstRender.current && (buttonWrapper.current?.children[0] as HTMLButtonElement).focus();\n }, [isOpen]);\n\n useEffect(() => {\n isFirstRender.current = false;\n\n return () => {\n isFirstRender.current = true;\n };\n }, []);\n\n useEffect(() => {\n if (onChange) onChange(selectedValue);\n }, [onChange, selectedValue]);\n\n return (\n <span ref={buttonWrapper}>\n <button\n className={clsx(styles['select-listbox-trigger'], styles[`select-listbox-trigger--${size}`], {\n [styles[`select-listbox-trigger--${variant}`]]: variant,\n [styles['select-listbox-trigger--bold']]: buttonLabelBold,\n })}\n type=\"button\"\n onClick={toggleListbox}\n onKeyDown={onTriggerKeyDown}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n aria-label={`${selectedValue.label}`}\n disabled={disabled}\n aria-controls={listboxId}\n {...(ref && { ref: ref })}\n >\n <span className={styles['select-listbox-trigger-label']}>\n {selectedValue[buttonLabelProp as keyof SelectValue]}\n </span>\n\n <Icon\n className={clsx(styles['select-listbox-trigger-icon'], {\n [styles['select-listbox-trigger-icon--open']]: isOpen,\n })}\n name=\"CheveronDown\"\n size={16}\n />\n </button>\n </span>\n );\n});\n"],"names":["SelectButton","forwardRef","props","ref","variant","size","onChange","buttonLabelProp","buttonLabelBold","disabled","buttonWrapper","useRef","isFirstRender","listboxId","isOpen","selectedValue","toggleListbox","setIsOpen","setActiveIndex","options","useSelect","onTriggerKeyDown","event","option","useEffect","_a","_b","jsx","jsxs","clsx","styles","Icon"],"mappings":";;;;;;AAmBO,MAAMA,IAAeC,EAAiD,CAACC,GAAOC,MAAQ;AACrF,QAAA,EAAE,SAAAC,GAAS,MAAAC,IAAO,WAAW,UAAAC,GAAU,iBAAAC,IAAkB,SAAS,iBAAAC,GAAiB,UAAAC,IAAW,GAAU,IAAAP,GACxGQ,IAAgBC,EAAwB,IAAI,GAC5CC,IAAgBD,EAAO,EAAI,GAC3B,EAAE,WAAAE,GAAW,QAAAC,GAAQ,eAAAC,GAAe,eAAAC,GAAe,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,EAAQ,IAAIC,EAAU,KAAK,CAAC,GAE1GC,IAAmB,CAACC,MAA4C;AACpE,YAAQA,EAAM,KAAK;AAAA,MACjB,KAAK;AAEH,YADAA,EAAM,eAAe,GACjB,CAACR,GAAQ;AACX,UAAAG,EAAU,EAAI;AACd;AAAA,QAAA;AAEF;AAAA,MACF,KAAK;AACH,QAAIH,MACFQ,EAAM,gBAAgB,GACPJ,EAAAC,EAAQ,UAAU,CAACI,MAAWA,EAAO,WAAUR,KAAA,gBAAAA,EAAe,MAAK,CAAC,GACnFE,EAAU,EAA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YACL,MAAM;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,CAAC;"}
|
|
1
|
+
{"version":3,"file":"SelectButton.js","sources":["../../../../src/components/SelectListbox/components/SelectButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, forwardRef } from 'react';\n\nimport type { KeyboardEvent } from 'react';\nimport type { OptionValue, SelectValue } from 'components/SelectListbox/SelectProvider';\n\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\nimport { Icon } from 'components/Icon';\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\n\nexport interface SelectButtonProps {\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight' | 'darkBorder';\n size?: 'small' | 'medium' | 'default';\n onChange?: (option: OptionValue) => void;\n buttonLabelProp?: string;\n buttonLabelBold?: boolean;\n disabled?: boolean;\n}\n\nexport const SelectButton = forwardRef<HTMLButtonElement, SelectButtonProps>((props, ref) => {\n const { variant, size = 'default', onChange, buttonLabelProp = 'label', buttonLabelBold, disabled = false } = props;\n const buttonWrapper = useRef<HTMLSpanElement>(null);\n const isFirstRender = useRef(true);\n const { listboxId, isOpen, selectedValue, toggleListbox, setIsOpen, setActiveIndex, options } = useSelect() || {};\n\n const onTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n if (!isOpen) {\n setIsOpen(true);\n return;\n }\n break;\n case 'Escape':\n if (isOpen) {\n event.stopPropagation();\n setActiveIndex(options.findIndex((option) => option.value === selectedValue?.value));\n setIsOpen(false);\n }\n break;\n }\n };\n\n useEffect(() => {\n isOpen\n ? (buttonWrapper.current?.children[0] as HTMLButtonElement).blur()\n : !isFirstRender.current && (buttonWrapper.current?.children[0] as HTMLButtonElement).focus();\n }, [isOpen]);\n\n useEffect(() => {\n isFirstRender.current = false;\n\n return () => {\n isFirstRender.current = true;\n };\n }, []);\n\n useEffect(() => {\n if (onChange) onChange(selectedValue);\n }, [onChange, selectedValue]);\n\n return (\n <span ref={buttonWrapper}>\n <button\n className={clsx(styles['select-listbox-trigger'], styles[`select-listbox-trigger--${size}`], {\n [styles[`select-listbox-trigger--${variant}`]]: variant,\n [styles['select-listbox-trigger--bold']]: buttonLabelBold,\n })}\n type=\"button\"\n onClick={toggleListbox}\n onKeyDown={onTriggerKeyDown}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n aria-label={`${selectedValue.label}`}\n disabled={disabled}\n aria-controls={listboxId}\n {...(ref && { ref: ref })}\n >\n <span className={styles['select-listbox-trigger-label']}>\n {selectedValue[buttonLabelProp as keyof SelectValue]}\n </span>\n\n <Icon\n className={clsx(styles['select-listbox-trigger-icon'], {\n [styles['select-listbox-trigger-icon--open']]: isOpen,\n })}\n name=\"CheveronDown\"\n size={16}\n />\n </button>\n </span>\n );\n});\n"],"names":["SelectButton","forwardRef","props","ref","variant","size","onChange","buttonLabelProp","buttonLabelBold","disabled","buttonWrapper","useRef","isFirstRender","listboxId","isOpen","selectedValue","toggleListbox","setIsOpen","setActiveIndex","options","useSelect","onTriggerKeyDown","event","option","useEffect","_a","_b","jsx","jsxs","clsx","styles","Icon"],"mappings":";;;;;;AAmBO,MAAMA,IAAeC,EAAiD,CAACC,GAAOC,MAAQ;AACrF,QAAA,EAAE,SAAAC,GAAS,MAAAC,IAAO,WAAW,UAAAC,GAAU,iBAAAC,IAAkB,SAAS,iBAAAC,GAAiB,UAAAC,IAAW,GAAU,IAAAP,GACxGQ,IAAgBC,EAAwB,IAAI,GAC5CC,IAAgBD,EAAO,EAAI,GAC3B,EAAE,WAAAE,GAAW,QAAAC,GAAQ,eAAAC,GAAe,eAAAC,GAAe,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,EAAQ,IAAIC,EAAU,KAAK,CAAC,GAE1GC,IAAmB,CAACC,MAA4C;AACpE,YAAQA,EAAM,KAAK;AAAA,MACjB,KAAK;AAEH,YADAA,EAAM,eAAe,GAC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A8B,GACnD,UAAAf,EAAcR,CAAoC,GACrD;AAAA,QAEA,gBAAAoB;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,WAAWF,EAAKC,EAAO,6BAA6B,GAAG;AAAA,cACrD,CAACA,EAAO,mCAAmC,CAAC,GAAGhB;AAAA,YAAA,CAChD;AAAA,YACD,MAAK;AAAA,YACL,MAAM;AAAA,UAAA;AAAA,QAAA;AAAA,MACR;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,CAAC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as i, useCallback as u, useEffect as l } from "react";
|
|
3
3
|
import { useSelect as m } from "../SelectProvider.js";
|
|
4
|
-
import { s as f } from "../../../SelectListbox.module-
|
|
4
|
+
import { s as f } from "../../../SelectListbox.module-BWavTmq8.js";
|
|
5
5
|
const E = ({ children: o }) => {
|
|
6
6
|
const { isOpen: r, setIsOpen: n } = m(), t = i(null), e = u(
|
|
7
7
|
({ target: s }) => {
|
|
@@ -2,7 +2,7 @@ import { jsx as d } from "react/jsx-runtime";
|
|
|
2
2
|
import { c as v } from "../../../clsx-OuTLNxxd.js";
|
|
3
3
|
import { useRef as D, useEffect as p } from "react";
|
|
4
4
|
import { useSelect as y } from "../SelectProvider.js";
|
|
5
|
-
import { s as b } from "../../../SelectListbox.module-
|
|
5
|
+
import { s as b } from "../../../SelectListbox.module-BWavTmq8.js";
|
|
6
6
|
const S = ({ option: t, index: l, children: m }) => {
|
|
7
7
|
const o = D(null), { isOpen: r, activeIndex: s, setActiveIndex: c, selectedValue: f, setSelectedValue: u, setIsOpen: i, options: a } = y(), w = (e) => {
|
|
8
8
|
u(a[e]), i(!1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as m, useRef as x } from "react";
|
|
3
|
-
import { s as i } from "../../../SelectListbox.module-
|
|
3
|
+
import { s as i } from "../../../SelectListbox.module-BWavTmq8.js";
|
|
4
4
|
import { useSelect as a } from "../SelectProvider.js";
|
|
5
5
|
const h = m((l, e) => {
|
|
6
6
|
const { style: t, children: o } = l, { listboxId: r, isOpen: c } = a(), n = x(null);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
export interface ToggleSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'className'> {
|
|
3
|
+
/** The label for the toggle switch. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Boolean value if label should be visible. */
|
|
6
|
+
labelVisible?: boolean;
|
|
7
|
+
/** Selection for label placement compared to toggle switch. */
|
|
8
|
+
labelPosition?: 'before' | 'after';
|
|
9
|
+
/** Boolean value to be used if the toggle mutates. If true the toggle is disabled in a loading state. */
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
/** Boolean value if extra gap is needed on left of component. */
|
|
12
|
+
extraLeftGap?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Represents a component for a toggle switch. */
|
|
15
|
+
export declare function ToggleSwitch({ label, labelPosition, labelVisible, loading, extraLeftGap, ...restProps }: ToggleSwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as l, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
import { c as a } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import '../../assets/ToggleSwitch.css';const t = {
|
|
4
|
+
"toggle-switch": "_toggle-switch_1df21_1",
|
|
5
|
+
"toggle-switch__visible": "_toggle-switch__visible_1df21_9",
|
|
6
|
+
"toggle-switch--disabled": "_toggle-switch--disabled_1df21_54",
|
|
7
|
+
"toggle-switch--loading": "_toggle-switch--loading_1df21_64",
|
|
8
|
+
"toggle-switch--visually-hidden": "_toggle-switch--visually-hidden_1df21_74",
|
|
9
|
+
"toggle-switch--disabled-label": "_toggle-switch--disabled-label_1df21_87",
|
|
10
|
+
"toggle-switch--loading-cursor": "_toggle-switch--loading-cursor_1df21_91",
|
|
11
|
+
"toggle-switch--extra-left-gap": "_toggle-switch--extra-left-gap_1df21_95"
|
|
12
|
+
};
|
|
13
|
+
function n({
|
|
14
|
+
condition: i,
|
|
15
|
+
wrapper: g,
|
|
16
|
+
children: e
|
|
17
|
+
}) {
|
|
18
|
+
return i ? g(e) : e;
|
|
19
|
+
}
|
|
20
|
+
function f({
|
|
21
|
+
label: i,
|
|
22
|
+
labelPosition: g = "after",
|
|
23
|
+
labelVisible: e = !0,
|
|
24
|
+
loading: o = !1,
|
|
25
|
+
extraLeftGap: d,
|
|
26
|
+
...s
|
|
27
|
+
}) {
|
|
28
|
+
const c = /* @__PURE__ */ l(
|
|
29
|
+
"span",
|
|
30
|
+
{
|
|
31
|
+
className: a(
|
|
32
|
+
{ [t["toggle-switch--visually-hidden"]]: !e },
|
|
33
|
+
{ [t["toggle-switch--disabled-label"]]: s.disabled }
|
|
34
|
+
),
|
|
35
|
+
children: i
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return /* @__PURE__ */ l(
|
|
39
|
+
n,
|
|
40
|
+
{
|
|
41
|
+
condition: o,
|
|
42
|
+
wrapper: (h) => /* @__PURE__ */ l("div", { className: t["toggle-switch--loading-cursor"], children: h }),
|
|
43
|
+
children: /* @__PURE__ */ _(
|
|
44
|
+
"label",
|
|
45
|
+
{
|
|
46
|
+
className: a(
|
|
47
|
+
t["toggle-switch"],
|
|
48
|
+
{ [t["toggle-switch--disabled"]]: s.disabled },
|
|
49
|
+
{ [t["toggle-switch--loading"]]: o },
|
|
50
|
+
{ [t["toggle-switch--extra-left-gap"]]: d }
|
|
51
|
+
),
|
|
52
|
+
children: [
|
|
53
|
+
g === "before" && c,
|
|
54
|
+
/* @__PURE__ */ l("input", { className: t["toggle-switch--visually-hidden"], ...s, type: "checkbox" }),
|
|
55
|
+
/* @__PURE__ */ l("span", { className: t["toggle-switch__visible"], title: e ? "" : i }),
|
|
56
|
+
g === "after" && c
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
f as ToggleSwitch
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=ToggleSwitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.js","sources":["../../../src/components/ToggleSwitch/ToggleSwitch.tsx"],"sourcesContent":["import classNames from 'clsx';\n\nimport type { InputHTMLAttributes, ReactNode } from 'react';\n\nimport styles from './ToggleSwitch.module.css';\n\nexport interface ToggleSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'style' | 'className'> {\n /** The label for the toggle switch. */\n label: string;\n /** Boolean value if label should be visible. */\n labelVisible?: boolean;\n /** Selection for label placement compared to toggle switch. */\n labelPosition?: 'before' | 'after';\n /** Boolean value to be used if the toggle mutates. If true the toggle is disabled in a loading state. */\n loading?: boolean;\n /** Boolean value if extra gap is needed on left of component. */\n extraLeftGap?: boolean;\n}\n\nfunction ConditionalWrapper({\n condition,\n wrapper,\n children,\n}: {\n condition: boolean;\n wrapper: (children: ReactNode) => ReactNode;\n children: ReactNode;\n}) {\n return condition ? wrapper(children) : children;\n}\n\n/** Represents a component for a toggle switch. */\nexport function ToggleSwitch({\n label,\n labelPosition = 'after',\n labelVisible = true,\n loading = false,\n extraLeftGap,\n ...restProps\n}: ToggleSwitchProps) {\n const labelComponent = (\n <span\n className={classNames(\n { [styles['toggle-switch--visually-hidden']]: !labelVisible },\n { [styles['toggle-switch--disabled-label']]: restProps.disabled }\n )}\n >\n {label}\n </span>\n );\n\n return (\n <ConditionalWrapper\n condition={loading}\n wrapper={(children) => <div className={styles['toggle-switch--loading-cursor']}>{children}</div>}\n >\n <label\n className={classNames(\n styles['toggle-switch'],\n { [styles['toggle-switch--disabled']]: restProps.disabled },\n { [styles['toggle-switch--loading']]: loading },\n { [styles['toggle-switch--extra-left-gap']]: extraLeftGap }\n )}\n >\n {labelPosition === 'before' && labelComponent}\n <input className={styles['toggle-switch--visually-hidden']} {...restProps} type=\"checkbox\" />\n <span className={styles['toggle-switch__visible']} title={!labelVisible ? label : ''} />\n {labelPosition === 'after' && labelComponent}\n </label>\n </ConditionalWrapper>\n );\n}\n"],"names":["ConditionalWrapper","condition","wrapper","children","ToggleSwitch","label","labelPosition","labelVisible","loading","extraLeftGap","restProps","labelComponent","jsx","classNames","styles","jsxs"],"mappings":";;;;;;;;;;;;AAmBA,SAASA,EAAmB;AAAA,EAC1B,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AACF,GAIG;AACM,SAAAF,IAAYC,EAAQC,CAAQ,IAAIA;AACzC;AAGO,SAASC,EAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,cAAAC,IAAe;AAAA,EACf,SAAAC,IAAU;AAAA,EACV,cAAAC;AAAA,EACA,GAAGC;AACL,GAAsB;AACpB,QAAMC,IACJ,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAAA,QACT,EAAE,CAACC,EAAO,gCAAgC,CAAC,GAAG,CAACP,EAAa;AAAA,QAC5D,EAAE,CAACO,EAAO,+BAA+B,CAAC,GAAGJ,EAAU,SAAS;AAAA,MAClE;AAAA,MAEC,UAAAL;AAAA,IAAA;AAAA,EACH;AAIA,SAAA,gBAAAO;AAAA,IAACZ;AAAA,IAAA;AAAA,MACC,WAAWQ;AAAA,MACX,SAAS,CAACL,MAAa,gBAAAS,EAAC,SAAI,WAAWE,EAAO,+BAA+B,GAAI,UAAAX,GAAS;AAAA,MAE1F,UAAA,gBAAAY;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWF;AAAAA,YACTC,EAAO,eAAe;AAAA,YACtB,EAAE,CAACA,EAAO,yBAAyB,CAAC,GAAGJ,EAAU,SAAS;AAAA,YAC1D,EAAE,CAACI,EAAO,wBAAwB,CAAC,GAAGN,EAAQ;AAAA,YAC9C,EAAE,CAACM,EAAO,+BAA+B,CAAC,GAAGL,EAAa;AAAA,UAC5D;AAAA,UAEC,UAAA;AAAA,YAAAH,MAAkB,YAAYK;AAAA,YAC/B,gBAAAC,EAAC,WAAM,WAAWE,EAAO,gCAAgC,GAAI,GAAGJ,GAAW,MAAK,YAAW;AAAA,YAC3F,gBAAAE,EAAC,QAAK,EAAA,WAAWE,EAAO,wBAAwB,GAAG,OAAQP,IAAuB,KAARF,EAAY,CAAA;AAAA,YACrFC,MAAkB,WAAWK;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAChC;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { ToggleSwitchProps } from './ToggleSwitch';
|
|
3
|
+
declare const _default: Meta<ToggleSwitchProps>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const ToggleSwitchExample: import('@storybook/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, ToggleSwitchProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { fn as l } from "../../index-DWzkl4aY.js";
|
|
3
|
+
import { ToggleSwitch as e } from "./ToggleSwitch.js";
|
|
4
|
+
const n = `
|
|
5
|
+
// Has all InputHTMLAttributes props available except "className" and "style"
|
|
6
|
+
<ToggleSwitch onChange={onChangeFunction} checked={checked} label={label} />
|
|
7
|
+
`, p = {
|
|
8
|
+
title: "Atoms/ToggleSwitch",
|
|
9
|
+
component: e,
|
|
10
|
+
parameters: {
|
|
11
|
+
inspectComponent: e,
|
|
12
|
+
codeString: n
|
|
13
|
+
}
|
|
14
|
+
}, a = (t) => /* @__PURE__ */ o(e, { ...t }), s = {
|
|
15
|
+
label: "Toggle switch example",
|
|
16
|
+
labelPosition: "before",
|
|
17
|
+
onChange: l()
|
|
18
|
+
}, c = a.bind({});
|
|
19
|
+
c.args = {
|
|
20
|
+
...s
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
c as ToggleSwitchExample,
|
|
24
|
+
p as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=ToggleSwitch.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.stories.js","sources":["../../../src/components/ToggleSwitch/ToggleSwitch.stories.tsx"],"sourcesContent":["import { fn } from '@storybook/test';\n\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { ToggleSwitchProps } from './ToggleSwitch';\n\nimport { ToggleSwitch } from './ToggleSwitch';\n\nconst codeString = `\n// Has all InputHTMLAttributes props available except \"className\" and \"style\" \n<ToggleSwitch onChange={onChangeFunction} checked={checked} label={label} />\n`;\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/ToggleSwitch',\n component: ToggleSwitch,\n parameters: {\n inspectComponent: ToggleSwitch,\n codeString: codeString,\n },\n} as Meta<ToggleSwitchProps>;\n\nconst Template: StoryFn<ToggleSwitchProps> = (args) => {\n return <ToggleSwitch {...args} />;\n};\n\nconst defaultArgs: Partial<ToggleSwitchProps> = {\n label: 'Toggle switch example',\n labelPosition: 'before',\n onChange: fn(),\n};\n\nexport const ToggleSwitchExample = Template.bind({});\nToggleSwitchExample.args = {\n ...defaultArgs,\n};\n"],"names":["codeString","ToggleSwitch_stories","ToggleSwitch","Template","args","jsx","defaultArgs","fn","ToggleSwitchExample"],"mappings":";;;AAOA,MAAMA,IAAa;AAAA;AAAA;AAAA,GAMJC,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,YAAY;AAAA,IACV,kBAAkBA;AAAA,IAClB,YAAAF;AAAA,EAAA;AAEJ,GAEMG,IAAuC,CAACC,MACrC,gBAAAC,EAACH,GAAc,EAAA,GAAGE,EAAM,CAAA,GAG3BE,IAA0C;AAAA,EAC9C,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAUC,EAAG;AACf,GAEaC,IAAsBL,EAAS,KAAK,CAAE,CAAA;AACnDK,EAAoB,OAAO;AAAA,EACzB,GAAGF;AACL;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ToggleSwitch';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -13,6 +13,7 @@ interface optionProps {
|
|
|
13
13
|
maxFixedHeight?: `${number}${'px' | 'rem'}`;
|
|
14
14
|
horizontalPosition?: 'left' | 'right';
|
|
15
15
|
mobileBreakpoint?: `${number}${'px' | 'rem'}`;
|
|
16
|
+
fullWidth: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare function usePositionedFloaters<T extends HTMLElement = HTMLElement>(positionedElement: T | null, referenceElement: T | null, options: optionProps): positionProps;
|
|
18
19
|
export {};
|
|
@@ -1,62 +1,64 @@
|
|
|
1
|
-
import { useState as L, useEffect as
|
|
2
|
-
import { useDebounce as
|
|
3
|
-
const a = 10,
|
|
1
|
+
import { useState as L, useEffect as p } from "react";
|
|
2
|
+
import { useDebounce as F } from "./useDebounce.js";
|
|
3
|
+
const a = 10, y = 45, r = 300, B = 0, k = 768, D = 2;
|
|
4
4
|
function S(d, e, n) {
|
|
5
|
-
const [m, H] = L(!1),
|
|
5
|
+
const [m, H] = L(!1), w = {
|
|
6
6
|
inset: "0 auto auto 0",
|
|
7
7
|
opacity: 0,
|
|
8
8
|
maxHeight: "100%",
|
|
9
9
|
maxWidth: "100%",
|
|
10
|
+
minWidth: r,
|
|
10
11
|
overflowX: "hidden",
|
|
11
12
|
overflowY: "auto",
|
|
12
13
|
margin: "0rem"
|
|
13
|
-
}, [
|
|
14
|
+
}, [h, v] = L(w), l = (t) => {
|
|
14
15
|
const o = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
15
16
|
return t.indexOf("rem") !== -1 ? parseFloat(t) * o : parseFloat(t);
|
|
16
17
|
}, b = (t, o) => {
|
|
17
18
|
if (!t) return 0;
|
|
18
19
|
const i = o === "bottom" ? window.innerHeight - t.bottom - n.offset - a : t.top - n.offset - a;
|
|
19
|
-
return !n.maxFixedHeight ||
|
|
20
|
-
},
|
|
20
|
+
return !n.maxFixedHeight || l(n.maxFixedHeight) > i ? i : l(n.maxFixedHeight);
|
|
21
|
+
}, W = (t, o) => {
|
|
21
22
|
if (!t) return 0;
|
|
22
23
|
const i = o === "left" ? window.innerWidth - t.left - a : t.right - a;
|
|
23
|
-
return i <=
|
|
24
|
+
return i <= r ? r : i;
|
|
24
25
|
}, P = (t, o, i) => i ? `${t.left - Math.abs(o.width - t.width) / D}px` : `${t.left}px`, x = () => {
|
|
25
26
|
const t = d == null ? void 0 : d.getBoundingClientRect(), o = e == null ? void 0 : e.getBoundingClientRect();
|
|
26
27
|
let i = "bottom", u = "left";
|
|
27
28
|
const f = window.matchMedia(
|
|
28
|
-
`(max-width: ${n.mobileBreakpoint ?
|
|
29
|
+
`(max-width: ${n.mobileBreakpoint ? l(n.mobileBreakpoint) : k}px)`
|
|
29
30
|
).matches;
|
|
30
|
-
return !o || !t ?
|
|
31
|
+
return !o || !t ? w : (window.innerHeight - o.bottom - a < y && (i = "top"), (window.innerWidth - o.left - a < r || n.horizontalPosition === "right") && !f && (u = "right"), {
|
|
31
32
|
inset: `${i === "bottom" ? o[i] + "px" : "auto"}
|
|
32
33
|
${u === "right" ? window.innerWidth - o[u] + "px" : "auto"}
|
|
33
34
|
${i === "top" ? window.innerHeight - o[i] + "px" : "auto"}
|
|
34
35
|
${u === "left" ? P(o, t, f) : "auto"}`,
|
|
35
36
|
maxHeight: `${b(o, i)}px`,
|
|
36
|
-
maxWidth: `${
|
|
37
|
+
maxWidth: `${W(o, u)}px`,
|
|
38
|
+
minWidth: n.fullWidth ? o.width : r,
|
|
37
39
|
overflowX: "hidden",
|
|
38
40
|
overflowY: "auto",
|
|
39
41
|
opacity: 1,
|
|
40
42
|
margin: `${n.offset}px 0`
|
|
41
43
|
});
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
...
|
|
44
|
+
}, c = () => {
|
|
45
|
+
v({
|
|
46
|
+
...h,
|
|
45
47
|
...x()
|
|
46
48
|
}), H(!0);
|
|
47
49
|
}, $ = () => {
|
|
48
|
-
m &&
|
|
49
|
-
...
|
|
50
|
+
m && v({
|
|
51
|
+
...h,
|
|
50
52
|
...x()
|
|
51
53
|
});
|
|
52
54
|
}, s = (t) => {
|
|
53
55
|
!e || e.contains(t.target) || !d || d.contains(t.target);
|
|
54
|
-
}, g =
|
|
55
|
-
return
|
|
56
|
-
e !== null && (n.mouseEvent === "click" ? e.removeEventListener("click",
|
|
56
|
+
}, g = F($, B);
|
|
57
|
+
return p(() => (e !== null && (n.mouseEvent === "click" ? e.addEventListener("click", c) : (e.addEventListener("mouseenter", c), e.addEventListener("mouseleave", s)), document.addEventListener("mousedown", s), document.addEventListener("touchstart", s), window.addEventListener("resize", g)), () => {
|
|
58
|
+
e !== null && (n.mouseEvent === "click" ? e.removeEventListener("click", c) : (e.removeEventListener("mouseenter", c), e.removeEventListener("mouseleave", s)), document.removeEventListener("mousedown", s), document.removeEventListener("touchstart", s), window.removeEventListener("resize", g));
|
|
57
59
|
})), {
|
|
58
60
|
style: {
|
|
59
|
-
style:
|
|
61
|
+
style: h
|
|
60
62
|
},
|
|
61
63
|
status: m
|
|
62
64
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePositionedFloaters.js","sources":["../../../src/components/hooks/usePositionedFloaters.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { useDebounce } from './useDebounce';\n\ninterface positionProps {\n style: {\n style: {\n inset: string;\n };\n };\n status: boolean;\n}\n\ninterface optionProps {\n mouseEvent: 'click' | 'hover';\n position: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';\n offset: number;\n maxFixedHeight?: `${number}${'px' | 'rem'}`;\n horizontalPosition?: 'left' | 'right';\n mobileBreakpoint?: `${number}${'px' | 'rem'}`;\n}\n\nconst BODY_PADDING = 10;\nconst MIN_HEIGHT = 45;\nconst MIN_WIDTH = 300;\nconst DEBOUNCE_DELAY = 0;\nconst MOBILE_BREAKPOINT = 768;\nconst HALF = 2;\n\nexport function usePositionedFloaters<T extends HTMLElement = HTMLElement>(\n positionedElement: T | null,\n referenceElement: T | null,\n options: optionProps\n): positionProps {\n const [status, setStatus] = useState(false);\n const defaultStyle = {\n inset: '0 auto auto 0',\n opacity: 0,\n maxHeight: '100%',\n maxWidth: '100%',\n overflowX: 'hidden',\n overflowY: 'auto',\n margin: '0rem',\n };\n\n const [style, setStyle] = useState(defaultStyle);\n\n const sizeToPx = (size: `${number}${'px' | 'rem'}`): number => {\n const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);\n return size.indexOf('rem') !== -1 ? parseFloat(size) * rootFontSize : parseFloat(size);\n };\n\n const setHeight = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _maxHeight =\n pos === 'bottom'\n ? window.innerHeight - refRect.bottom - options.offset - BODY_PADDING\n : refRect.top - options.offset - BODY_PADDING;\n\n return !options.maxFixedHeight || sizeToPx(options.maxFixedHeight) > _maxHeight\n ? _maxHeight\n : sizeToPx(options.maxFixedHeight);\n };\n\n const setWidth = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _availableWidth =\n pos === 'left' ? window.innerWidth - refRect.left - BODY_PADDING : refRect.right - BODY_PADDING;\n\n return _availableWidth <= MIN_WIDTH ? MIN_WIDTH : _availableWidth;\n };\n\n const setLeft = (refRect: DOMRect, posRect: DOMRect, isMobile: boolean) => {\n if (isMobile) {\n return `${refRect.left - Math.abs(posRect.width - refRect.width) / HALF}px`;\n } else {\n return `${refRect.left}px`;\n }\n };\n\n const calcPosition = (): typeof defaultStyle => {\n const positionedRect = (positionedElement as HTMLElement | null)?.getBoundingClientRect();\n const referenceRect = (referenceElement as HTMLElement | null)?.getBoundingClientRect();\n let yPos = 'bottom';\n let xPos = 'left';\n\n const isMobile = window.matchMedia(\n `(max-width: ${options.mobileBreakpoint ? sizeToPx(options.mobileBreakpoint) : MOBILE_BREAKPOINT}px)`\n ).matches;\n\n if (!referenceRect || !positionedRect) {\n return defaultStyle;\n }\n\n if (window.innerHeight - referenceRect.bottom - BODY_PADDING < MIN_HEIGHT) {\n yPos = 'top';\n }\n\n if (\n (window.innerWidth - referenceRect.left - BODY_PADDING < MIN_WIDTH || options.horizontalPosition === 'right') &&\n !isMobile\n ) {\n xPos = 'right';\n }\n\n return {\n inset: `${yPos === 'bottom' ? referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'right' ? window.innerWidth - referenceRect[xPos] + 'px' : 'auto'}\n ${yPos === 'top' ? window.innerHeight - referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'left' ? setLeft(referenceRect, positionedRect, isMobile) : 'auto'}`,\n maxHeight: `${setHeight(referenceRect, yPos)}px`,\n maxWidth: `${setWidth(referenceRect, xPos)}px`,\n overflowX: 'hidden',\n overflowY: 'auto',\n opacity: 1,\n margin: `${options.offset}px 0`,\n };\n };\n\n const handleMouseEvent = (): void => {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n setStatus(true);\n };\n\n const updatePosition = (): void => {\n if (status) {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n }\n };\n\n const handleClickOutside = (evt: Event): void => {\n if (\n !referenceElement ||\n (referenceElement as unknown as HTMLElement).contains(evt.target as Node) ||\n !positionedElement ||\n (positionedElement as unknown as HTMLElement).contains(evt.target as Node)\n ) {\n return;\n }\n };\n\n const debouncedUpdatePosition = useDebounce(updatePosition, DEBOUNCE_DELAY);\n\n useEffect(() => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseleave', handleClickOutside);\n }\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('touchstart', handleClickOutside);\n window.addEventListener('resize', debouncedUpdatePosition);\n }\n\n return () => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseleave', handleClickOutside);\n }\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('touchstart', handleClickOutside);\n window.removeEventListener('resize', debouncedUpdatePosition);\n }\n };\n });\n\n return {\n style: {\n style,\n },\n status,\n };\n}\n"],"names":["BODY_PADDING","MIN_HEIGHT","MIN_WIDTH","DEBOUNCE_DELAY","MOBILE_BREAKPOINT","HALF","usePositionedFloaters","positionedElement","referenceElement","options","status","setStatus","useState","defaultStyle","style","setStyle","sizeToPx","size","rootFontSize","setHeight","refRect","pos","_maxHeight","setWidth","_availableWidth","setLeft","posRect","isMobile","calcPosition","positionedRect","referenceRect","yPos","xPos","handleMouseEvent","updatePosition","handleClickOutside","evt","debouncedUpdatePosition","useDebounce","useEffect"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"usePositionedFloaters.js","sources":["../../../src/components/hooks/usePositionedFloaters.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { useDebounce } from './useDebounce';\n\ninterface positionProps {\n style: {\n style: {\n inset: string;\n };\n };\n status: boolean;\n}\n\ninterface optionProps {\n mouseEvent: 'click' | 'hover';\n position: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';\n offset: number;\n maxFixedHeight?: `${number}${'px' | 'rem'}`;\n horizontalPosition?: 'left' | 'right';\n mobileBreakpoint?: `${number}${'px' | 'rem'}`;\n fullWidth: boolean;\n}\n\nconst BODY_PADDING = 10;\nconst MIN_HEIGHT = 45;\nconst MIN_WIDTH = 300;\nconst DEBOUNCE_DELAY = 0;\nconst MOBILE_BREAKPOINT = 768;\nconst HALF = 2;\n\nexport function usePositionedFloaters<T extends HTMLElement = HTMLElement>(\n positionedElement: T | null,\n referenceElement: T | null,\n options: optionProps\n): positionProps {\n const [status, setStatus] = useState(false);\n const defaultStyle = {\n inset: '0 auto auto 0',\n opacity: 0,\n maxHeight: '100%',\n maxWidth: '100%',\n minWidth: MIN_WIDTH,\n overflowX: 'hidden',\n overflowY: 'auto',\n margin: '0rem',\n };\n\n const [style, setStyle] = useState(defaultStyle);\n\n const sizeToPx = (size: `${number}${'px' | 'rem'}`): number => {\n const rootFontSize = parseFloat(getComputedStyle(document.documentElement).fontSize);\n return size.indexOf('rem') !== -1 ? parseFloat(size) * rootFontSize : parseFloat(size);\n };\n\n const setHeight = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _maxHeight =\n pos === 'bottom'\n ? window.innerHeight - refRect.bottom - options.offset - BODY_PADDING\n : refRect.top - options.offset - BODY_PADDING;\n\n return !options.maxFixedHeight || sizeToPx(options.maxFixedHeight) > _maxHeight\n ? _maxHeight\n : sizeToPx(options.maxFixedHeight);\n };\n\n const setWidth = (refRect: DOMRect, pos: string): number => {\n if (!refRect) return 0;\n\n const _availableWidth =\n pos === 'left' ? window.innerWidth - refRect.left - BODY_PADDING : refRect.right - BODY_PADDING;\n\n return _availableWidth <= MIN_WIDTH ? MIN_WIDTH : _availableWidth;\n };\n\n const setLeft = (refRect: DOMRect, posRect: DOMRect, isMobile: boolean) => {\n if (isMobile) {\n return `${refRect.left - Math.abs(posRect.width - refRect.width) / HALF}px`;\n } else {\n return `${refRect.left}px`;\n }\n };\n\n const calcPosition = (): typeof defaultStyle => {\n const positionedRect = (positionedElement as HTMLElement | null)?.getBoundingClientRect();\n const referenceRect = (referenceElement as HTMLElement | null)?.getBoundingClientRect();\n let yPos = 'bottom';\n let xPos = 'left';\n\n const isMobile = window.matchMedia(\n `(max-width: ${options.mobileBreakpoint ? sizeToPx(options.mobileBreakpoint) : MOBILE_BREAKPOINT}px)`\n ).matches;\n\n if (!referenceRect || !positionedRect) {\n return defaultStyle;\n }\n\n if (window.innerHeight - referenceRect.bottom - BODY_PADDING < MIN_HEIGHT) {\n yPos = 'top';\n }\n\n if (\n (window.innerWidth - referenceRect.left - BODY_PADDING < MIN_WIDTH || options.horizontalPosition === 'right') &&\n !isMobile\n ) {\n xPos = 'right';\n }\n\n return {\n inset: `${yPos === 'bottom' ? referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'right' ? window.innerWidth - referenceRect[xPos] + 'px' : 'auto'}\n ${yPos === 'top' ? window.innerHeight - referenceRect[yPos] + 'px' : 'auto'}\n ${xPos === 'left' ? setLeft(referenceRect, positionedRect, isMobile) : 'auto'}`,\n maxHeight: `${setHeight(referenceRect, yPos)}px`,\n maxWidth: `${setWidth(referenceRect, xPos)}px`,\n minWidth: options.fullWidth ? referenceRect.width : MIN_WIDTH,\n overflowX: 'hidden',\n overflowY: 'auto',\n opacity: 1,\n margin: `${options.offset}px 0`,\n };\n };\n\n const handleMouseEvent = (): void => {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n setStatus(true);\n };\n\n const updatePosition = (): void => {\n if (status) {\n setStyle({\n ...style,\n ...calcPosition(),\n });\n }\n };\n\n const handleClickOutside = (evt: Event): void => {\n if (\n !referenceElement ||\n (referenceElement as unknown as HTMLElement).contains(evt.target as Node) ||\n !positionedElement ||\n (positionedElement as unknown as HTMLElement).contains(evt.target as Node)\n ) {\n return;\n }\n };\n\n const debouncedUpdatePosition = useDebounce(updatePosition, DEBOUNCE_DELAY);\n\n useEffect(() => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).addEventListener('mouseleave', handleClickOutside);\n }\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('touchstart', handleClickOutside);\n window.addEventListener('resize', debouncedUpdatePosition);\n }\n\n return () => {\n if (referenceElement !== null) {\n if (options.mouseEvent === 'click') {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('click', handleMouseEvent);\n } else {\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseenter', handleMouseEvent);\n // eslint-disable-next-line no-extra-semi\n (referenceElement as unknown as HTMLElement).removeEventListener('mouseleave', handleClickOutside);\n }\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('touchstart', handleClickOutside);\n window.removeEventListener('resize', debouncedUpdatePosition);\n }\n };\n });\n\n return {\n style: {\n style,\n },\n status,\n };\n}\n"],"names":["BODY_PADDING","MIN_HEIGHT","MIN_WIDTH","DEBOUNCE_DELAY","MOBILE_BREAKPOINT","HALF","usePositionedFloaters","positionedElement","referenceElement","options","status","setStatus","useState","defaultStyle","style","setStyle","sizeToPx","size","rootFontSize","setHeight","refRect","pos","_maxHeight","setWidth","_availableWidth","setLeft","posRect","isMobile","calcPosition","positionedRect","referenceRect","yPos","xPos","handleMouseEvent","updatePosition","handleClickOutside","evt","debouncedUpdatePosition","useDebounce","useEffect"],"mappings":";;AAuBA,MAAMA,IAAe,IACfC,IAAa,IACbC,IAAY,KACZC,IAAiB,GACjBC,IAAoB,KACpBC,IAAO;AAEG,SAAAC,EACdC,GACAC,GACAC,GACe;AACf,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpCC,IAAe;AAAA,IACnB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,WAAW;AAAA,IACX,UAAU;A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,SAASyB,CAAgB,KAGtFzB,EAA4C,iBAAiB,cAAcyB,CAAgB,GAE3FzB,EAA4C,iBAAiB,cAAc2B,CAAkB,IAEvF,SAAA,iBAAiB,aAAaA,CAAkB,GAChD,SAAA,iBAAiB,cAAcA,CAAkB,GACnD,OAAA,iBAAiB,UAAUE,CAAuB,IAGpD,MAAM;AACX,IAAI7B,MAAqB,SACnBC,EAAQ,eAAe,UAExBD,EAA4C,oBAAoB,SAASyB,CAAgB,KAGzFzB,EAA4C,oBAAoB,cAAcyB,CAAgB,GAE9FzB,EAA4C,oBAAoB,cAAc2B,CAAkB,IAE1F,SAAA,oBAAoB,aAAaA,CAAkB,GACnD,SAAA,oBAAoB,cAAcA,CAAkB,GACtD,OAAA,oBAAoB,UAAUE,CAAuB;AAAA,EAEhE,EACD,GAEM;AAAA,IACL,OAAO;AAAA,MACL,OAAAvB;AAAA,IACF;AAAA,IACA,QAAAJ;AAAA,EACF;AACF;"}
|
package/dist/components/index.js
CHANGED
|
@@ -9,14 +9,14 @@ import { Button as B } from "./Buttons/Button.js";
|
|
|
9
9
|
import { LinkButton as b } from "./Buttons/LinkButton.js";
|
|
10
10
|
import { MenuButton as C } from "./Buttons/MenuButton.js";
|
|
11
11
|
import { Card as L } from "./Card/Card.js";
|
|
12
|
-
import { Checkbox as
|
|
13
|
-
import { CheckboxButton as
|
|
14
|
-
import { CheckboxButtonBar as
|
|
15
|
-
import { CheckboxTree as
|
|
12
|
+
import { Checkbox as g } from "./Checkbox/Checkbox.js";
|
|
13
|
+
import { CheckboxButton as P } from "./CheckboxButton/CheckboxButton.js";
|
|
14
|
+
import { CheckboxButtonBar as A } from "./CheckboxButtonBar/CheckboxButtonBar.js";
|
|
15
|
+
import { CheckboxTree as R } from "./CheckboxTree/CheckboxTree.js";
|
|
16
16
|
import { Drawer as v } from "./Drawer/Drawer.js";
|
|
17
|
-
import { EmptyStateDataDisplay as
|
|
18
|
-
import { FeedbackBox as
|
|
19
|
-
import { FieldHint as
|
|
17
|
+
import { EmptyStateDataDisplay as T } from "./EmptyStateDataDisplay/EmptyStateDataDisplay.js";
|
|
18
|
+
import { FeedbackBox as G } from "./FeedbackBox/FeedbackBox.js";
|
|
19
|
+
import { FieldHint as O } from "./FieldHint/FieldHint.js";
|
|
20
20
|
import { Fieldset as N } from "./Fieldset/Fieldset.js";
|
|
21
21
|
import { FormField as q } from "./FormField/FormField.js";
|
|
22
22
|
import { FormInput as K } from "./FormInput/FormInput.js";
|
|
@@ -36,17 +36,18 @@ import { OverlayCloseButton as So } from "./OverlayCloseButton/OverlayCloseButto
|
|
|
36
36
|
import { PageOverlay as ko } from "./PageOverlay/PageOverlay.js";
|
|
37
37
|
import { Periods as Fo } from "./Periods/Periods.js";
|
|
38
38
|
import { PeriodSelector as Mo } from "./PeriodSelector/PeriodSelector.js";
|
|
39
|
-
import { ProgrammeCard as
|
|
40
|
-
import { RadioButton as
|
|
41
|
-
import { Repeater as
|
|
39
|
+
import { ProgrammeCard as Io } from "./ProgrammeCard/ProgrammeCard.js";
|
|
40
|
+
import { RadioButton as ho } from "./RadioButton/RadioButton.js";
|
|
41
|
+
import { Repeater as Do } from "./Repeater/Repeater.js";
|
|
42
42
|
import { Rte as yo, RteEditor as vo } from "./RteEditor/RteEditor.js";
|
|
43
|
-
import { SectionNotification as
|
|
44
|
-
import { SelectListbox as
|
|
45
|
-
import { SelectProvider as
|
|
43
|
+
import { SectionNotification as To } from "./SectionNotification/SectionNotification.js";
|
|
44
|
+
import { SelectListbox as Go } from "./SelectListbox/SelectListbox.js";
|
|
45
|
+
import { SelectProvider as Oo, useSelect as zo } from "./SelectListbox/SelectProvider.js";
|
|
46
46
|
import { Sortable as jo } from "./Sortable/Sortable.js";
|
|
47
47
|
import { Spinner as Jo } from "./Spinner/Spinner.js";
|
|
48
48
|
import { StatusPill as Qo } from "./StatusPill/StatusPill.js";
|
|
49
|
-
import {
|
|
49
|
+
import { ToggleSwitch as Vo } from "./ToggleSwitch/ToggleSwitch.js";
|
|
50
|
+
import { Tooltip as Xo } from "./Tooltip/Tooltip.js";
|
|
50
51
|
export {
|
|
51
52
|
t as Accordion,
|
|
52
53
|
p as AccordionCard,
|
|
@@ -57,14 +58,14 @@ export {
|
|
|
57
58
|
B as Button,
|
|
58
59
|
d as ButtonGroup,
|
|
59
60
|
L as Card,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
g as Checkbox,
|
|
62
|
+
P as CheckboxButton,
|
|
63
|
+
A as CheckboxButtonBar,
|
|
64
|
+
R as CheckboxTree,
|
|
64
65
|
v as Drawer,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
T as EmptyStateDataDisplay,
|
|
67
|
+
G as FeedbackBox,
|
|
68
|
+
O as FieldHint,
|
|
68
69
|
N as Fieldset,
|
|
69
70
|
q as FormField,
|
|
70
71
|
K as FormInput,
|
|
@@ -86,18 +87,19 @@ export {
|
|
|
86
87
|
ko as PageOverlay,
|
|
87
88
|
Mo as PeriodSelector,
|
|
88
89
|
Fo as Periods,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
Io as ProgrammeCard,
|
|
91
|
+
ho as RadioButton,
|
|
92
|
+
Do as Repeater,
|
|
92
93
|
yo as Rte,
|
|
93
94
|
vo as RteEditor,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
To as SectionNotification,
|
|
96
|
+
Go as SelectListbox,
|
|
97
|
+
Oo as SelectProvider,
|
|
97
98
|
jo as Sortable,
|
|
98
99
|
Jo as Spinner,
|
|
99
100
|
Qo as StatusPill,
|
|
100
|
-
Vo as
|
|
101
|
+
Vo as ToggleSwitch,
|
|
102
|
+
Xo as Tooltip,
|
|
101
103
|
zo as useSelect
|
|
102
104
|
};
|
|
103
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|