@elliemae/ds-form-toggle 3.70.0-next.6 → 3.70.0-next.60
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/cjs/DSControlledToggle.js +50 -0
- package/dist/cjs/DSControlledToggle.js.map +7 -0
- package/dist/cjs/DSControlledToggleCTX.js +40 -0
- package/dist/cjs/DSControlledToggleCTX.js.map +7 -0
- package/dist/cjs/config/useDSControlledToggle.js +2 -17
- package/dist/cjs/config/useDSControlledToggle.js.map +2 -2
- package/dist/cjs/constants/index.js +0 -1
- package/dist/cjs/constants/index.js.map +2 -2
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/package.json +1 -4
- package/dist/cjs/parts/Button.js +103 -0
- package/dist/cjs/parts/Button.js.map +7 -0
- package/dist/cjs/parts/Container.js +61 -0
- package/dist/cjs/parts/Container.js.map +7 -0
- package/dist/cjs/parts/styles/styles.js +246 -0
- package/dist/cjs/parts/styles/styles.js.map +7 -0
- package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js +110 -0
- package/dist/cjs/parts/wcagViolation/Button.wcagViolationLabels.js.map +7 -0
- package/dist/cjs/{config → parts/wcagViolation}/useGetWidestLabelWidth.js.map +1 -1
- package/dist/cjs/react-desc-prop-types.js +2 -0
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/form-toggle-typescript-valid.js +2 -1
- package/dist/cjs/typescript-testing/form-toggle-typescript-valid.js.map +2 -2
- package/dist/cjs/typescript-testing/slot-props.js +40 -0
- package/dist/cjs/typescript-testing/slot-props.js.map +7 -0
- package/dist/esm/DSControlledToggle.js +20 -0
- package/dist/esm/DSControlledToggle.js.map +7 -0
- package/dist/esm/DSControlledToggleCTX.js +10 -0
- package/dist/esm/DSControlledToggleCTX.js.map +7 -0
- package/dist/esm/config/useDSControlledToggle.js +2 -17
- package/dist/esm/config/useDSControlledToggle.js.map +2 -2
- package/dist/esm/constants/index.js +0 -1
- package/dist/esm/constants/index.js.map +2 -2
- package/dist/esm/index.js +10 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/package.json +1 -4
- package/dist/esm/parts/Button.js +73 -0
- package/dist/esm/parts/Button.js.map +7 -0
- package/dist/esm/parts/Container.js +31 -0
- package/dist/esm/parts/Container.js.map +7 -0
- package/dist/esm/parts/styles/styles.js +216 -0
- package/dist/esm/parts/styles/styles.js.map +7 -0
- package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js +86 -0
- package/dist/esm/parts/wcagViolation/Button.wcagViolationLabels.js.map +7 -0
- package/dist/esm/{config → parts/wcagViolation}/useGetWidestLabelWidth.js.map +1 -1
- package/dist/esm/react-desc-prop-types.js +9 -2
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/form-toggle-typescript-valid.js +2 -1
- package/dist/esm/typescript-testing/form-toggle-typescript-valid.js.map +2 -2
- package/dist/esm/typescript-testing/slot-props.js +17 -0
- package/dist/esm/typescript-testing/slot-props.js.map +7 -0
- package/dist/types/DSControlledToggleCTX.d.ts +4 -0
- package/dist/types/config/useDSControlledToggle.d.ts +8 -373
- package/dist/types/constants/index.d.ts +0 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/parts/Button.d.ts +3 -0
- package/dist/types/parts/Container.d.ts +2 -0
- package/dist/types/parts/styles/styles.d.ts +37 -0
- package/dist/types/parts/wcagViolation/Button.wcagViolationLabels.d.ts +3 -0
- package/dist/types/react-desc-prop-types.d.ts +17 -2
- package/package.json +11 -9
- package/dist/cjs/ControlledToggle.js +0 -127
- package/dist/cjs/ControlledToggle.js.map +0 -7
- package/dist/cjs/styles.js +0 -154
- package/dist/cjs/styles.js.map +0 -7
- package/dist/cjs/utils/styleHelpers.js +0 -116
- package/dist/cjs/utils/styleHelpers.js.map +0 -7
- package/dist/esm/ControlledToggle.js +0 -105
- package/dist/esm/ControlledToggle.js.map +0 -7
- package/dist/esm/styles.js +0 -134
- package/dist/esm/styles.js.map +0 -7
- package/dist/esm/utils/styleHelpers.js +0 -86
- package/dist/esm/utils/styleHelpers.js.map +0 -7
- package/dist/types/styles.d.ts +0 -44
- package/dist/types/tests/DSControlledToggle.a11y-specific-scenarios.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.api.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.app-sdk-compatibility.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.axe.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.data-testId.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.events.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.exports.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.get-owner-props-arguments.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.keyboard.test.d.ts +0 -1
- package/dist/types/tests/DSControlledToggle.pitfall.test.d.ts +0 -1
- package/dist/types/typescript-testing/form-toggle-typescript-valid.d.ts +0 -1
- package/dist/types/utils/styleHelpers.d.ts +0 -41
- /package/dist/cjs/{config → parts/wcagViolation}/useGetWidestLabelWidth.js +0 -0
- /package/dist/esm/{config → parts/wcagViolation}/useGetWidestLabelWidth.js +0 -0
- /package/dist/types/{ControlledToggle.d.ts → DSControlledToggle.d.ts} +0 -0
- /package/dist/types/{config → parts/wcagViolation}/useGetWidestLabelWidth.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSControlledToggleCTX.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext } from 'react';\nimport type { ControlledToggleCTX } from './config/useDSControlledToggle.js';\n\nconst defaultContext = {} as ControlledToggleCTX;\n\n/** Context for cross component communication */\nexport const ControlledToggleContext = createContext<ControlledToggleCTX>(defaultContext);\n\nexport default ControlledToggleContext;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAG9B,MAAM,iBAAiB,CAAC;AAGjB,MAAM,0BAA0B,cAAmC,cAAc;AAExF,IAAO,gCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -4,7 +4,6 @@ import React2, { useCallback } from "react";
|
|
|
4
4
|
import { uid } from "uid";
|
|
5
5
|
import { DSControlledTogglePropTypes, defaultProps } from "../react-desc-prop-types.js";
|
|
6
6
|
import { useGetButtonProps } from "./useGetButtonProps.js";
|
|
7
|
-
import { useGetWidestLabelWidth } from "./useGetWidestLabelWidth.js";
|
|
8
7
|
import { useValidateProps } from "./useValidateProps.js";
|
|
9
8
|
const useDSControlledToggle = (propsFromUser) => {
|
|
10
9
|
const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
|
|
@@ -25,7 +24,6 @@ const useDSControlledToggle = (propsFromUser) => {
|
|
|
25
24
|
const xstyledProps = useGetXstyledProps(propsWithDefault);
|
|
26
25
|
const { id } = propsWithDefault;
|
|
27
26
|
const instanceUid = React2.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);
|
|
28
|
-
const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = useGetWidestLabelWidth();
|
|
29
27
|
const buttonProps = useGetButtonProps({
|
|
30
28
|
handleOnClick,
|
|
31
29
|
globalProps,
|
|
@@ -35,26 +33,13 @@ const useDSControlledToggle = (propsFromUser) => {
|
|
|
35
33
|
return React2.useMemo(
|
|
36
34
|
() => ({
|
|
37
35
|
propsWithDefault,
|
|
38
|
-
width,
|
|
39
|
-
handleRefOnLabelWidth,
|
|
40
|
-
handleRefOffLabelWidth,
|
|
41
36
|
globalProps,
|
|
42
|
-
buttonProps,
|
|
43
37
|
xstyledProps,
|
|
44
38
|
instanceUid,
|
|
45
|
-
handleOnClick
|
|
46
|
-
}),
|
|
47
|
-
[
|
|
48
|
-
propsWithDefault,
|
|
49
|
-
width,
|
|
50
|
-
handleRefOnLabelWidth,
|
|
51
|
-
handleRefOffLabelWidth,
|
|
52
|
-
globalProps,
|
|
53
39
|
buttonProps,
|
|
54
|
-
xstyledProps,
|
|
55
|
-
instanceUid,
|
|
56
40
|
handleOnClick
|
|
57
|
-
|
|
41
|
+
}),
|
|
42
|
+
[propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick]
|
|
58
43
|
);
|
|
59
44
|
};
|
|
60
45
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useDSControlledToggle.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useGetGlobalAttributes, useGetXstyledProps, useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';\nimport React, { useCallback } from 'react';\nimport { uid } from 'uid';\nimport { type DSControlledToggleT, DSControlledTogglePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { useGetButtonProps } from './useGetButtonProps.js';\nimport { useValidateProps } from './useValidateProps.js';\n\nexport interface ControlledToggleCTX {\n propsWithDefault: DSControlledToggleT.InternalProps;\n globalProps: ReturnType<typeof useGetGlobalAttributes>;\n xstyledProps: ReturnType<typeof useGetXstyledProps>;\n instanceUid: string;\n buttonProps: ReturnType<typeof useGetButtonProps>;\n handleOnClick: (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n}\n\nexport const useDSControlledToggle = (propsFromUser: DSControlledToggleT.Props): ControlledToggleCTX => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSControlledToggleT.InternalProps>(propsFromUser, defaultProps);\n useValidateProps(propsWithDefault, DSControlledTogglePropTypes);\n // =============================================================================\n // AD HOC PER COMPONENT LOGIC\n // =============================================================================\n const { disabled, applyAriaDisabled, readOnly, onChange } = propsWithDefault;\n const handleOnClick = useCallback(\n (e: React.KeyboardEvent<HTMLButtonElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n if (disabled || applyAriaDisabled || readOnly) return;\n if (onChange) {\n onChange(e);\n }\n },\n [disabled, applyAriaDisabled, readOnly, onChange],\n );\n // =============================================================================\n // GLOBAL ATTRIBUTES & XSTYLED PROPS\n // =============================================================================\n const globalProps = useGetGlobalAttributes<DSControlledToggleT.InternalProps>(propsWithDefault, {\n onClick: handleOnClick,\n });\n const xstyledProps = useGetXstyledProps(propsWithDefault);\n const { id } = propsWithDefault;\n const instanceUid = React.useMemo(() => id || `ds-form-toggle-${uid(5)}`, [id]);\n // =============================================================================\n // HELPERS HOOKS CONFIGS\n // =============================================================================\n const buttonProps = useGetButtonProps({\n handleOnClick,\n globalProps,\n instanceUid,\n propsWithDefault,\n });\n\n return React.useMemo(\n () => ({\n propsWithDefault,\n globalProps,\n xstyledProps,\n instanceUid,\n buttonProps,\n handleOnClick,\n }),\n [propsWithDefault, globalProps, buttonProps, xstyledProps, instanceUid, handleOnClick],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,wBAAwB,oBAAoB,oCAAoC;AACzF,OAAOA,UAAS,mBAAmB;AACnC,SAAS,WAAW;AACpB,SAAmC,6BAA6B,oBAAoB;AACpF,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAW1B,MAAM,wBAAwB,CAAC,kBAAkE;AAItG,QAAM,mBAAmB,6BAAgE,eAAe,YAAY;AACpH,mBAAiB,kBAAkB,2BAA2B;AAI9D,QAAM,EAAE,UAAU,mBAAmB,UAAU,SAAS,IAAI;AAC5D,QAAM,gBAAgB;AAAA,IACpB,CAAC,MAAgG;AAC/F,UAAI,YAAY,qBAAqB,SAAU;AAC/C,UAAI,UAAU;AACZ,iBAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAAA,IACA,CAAC,UAAU,mBAAmB,UAAU,QAAQ;AAAA,EAClD;AAIA,QAAM,cAAc,uBAA0D,kBAAkB;AAAA,IAC9F,SAAS;AAAA,EACX,CAAC;AACD,QAAM,eAAe,mBAAmB,gBAAgB;AACxD,QAAM,EAAE,GAAG,IAAI;AACf,QAAM,cAAcA,OAAM,QAAQ,MAAM,MAAM,kBAAkB,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAI9E,QAAM,cAAc,kBAAkB;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,aAAa,aAAa,cAAc,aAAa,aAAa;AAAA,EACvF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -2,7 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import { slotObjectToDataTestIds } from "@elliemae/ds-system";
|
|
3
3
|
const DSControlledToggleName = "DSFormtoggle";
|
|
4
4
|
const CONTROLLED_TOGGLE_SLOTS = {
|
|
5
|
-
CONTAINER_WITH_RADIUS_SHAPE: "container-with-radius-shape",
|
|
6
5
|
BUTTON_CONTENT_WRAPPER: "button-content-wrapper",
|
|
7
6
|
CIRCLE: "circle",
|
|
8
7
|
TEXT_WRAPPER: "text-wrapper",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/constants/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSControlledToggleName = 'DSFormtoggle';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_SLOTS = {\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,yBAAyB;AAG/B,MAAM,0BAA0B;AAAA,EACrC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { slotObjectToDataTestIds } from '@elliemae/ds-system';\n\nexport const DSControlledToggleName = 'DSFormtoggle';\n\n// we are giving \"component_name_slots\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_SLOTS = {\n BUTTON_CONTENT_WRAPPER: 'button-content-wrapper',\n CIRCLE: 'circle',\n TEXT_WRAPPER: 'text-wrapper',\n // legacy ones...\n CONTROLLED_CONTAINER: 'controlled-container', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'toggle-checkbox',\n} as const;\n\n// we are giving \"component_name_data_testid\" to avoid errors on duplicate exports variables in aggregators\nexport const CONTROLLED_TOGGLE_DATA_TESTID = {\n ...slotObjectToDataTestIds(DSControlledToggleName, CONTROLLED_TOGGLE_SLOTS),\n CONTROLLED_CONTAINER: 'ds-controlled-toggle', // in other components this is the ROOT\n TOGGLE_CHECKBOX: 'ds-controlled-toggle-checkbox',\n};\n\n// Specific of the toggle component\n\nexport const TOGGLE_SIZES = {\n SMALL: 's',\n MEDIUM: 'm',\n LARGE: 'l',\n} as const;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,+BAA+B;AAEjC,MAAM,yBAAyB;AAG/B,MAAM,0BAA0B;AAAA,EACrC,wBAAwB;AAAA,EACxB,QAAQ;AAAA,EACR,cAAc;AAAA;AAAA,EAEd,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAGO,MAAM,gCAAgC;AAAA,EAC3C,GAAG,wBAAwB,wBAAwB,uBAAuB;AAAA,EAC1E,sBAAsB;AAAA;AAAA,EACtB,iBAAiB;AACnB;AAIO,MAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
CONTROLLED_TOGGLE_DATA_TESTID,
|
|
4
|
+
CONTROLLED_TOGGLE_SLOTS,
|
|
5
|
+
DSControlledToggleName,
|
|
6
|
+
TOGGLE_SIZES
|
|
7
|
+
} from "./constants/index.js";
|
|
8
|
+
import { DSControlledToggle, DSControlledToggleWithSchema } from "./DSControlledToggle.js";
|
|
4
9
|
export {
|
|
10
|
+
CONTROLLED_TOGGLE_DATA_TESTID,
|
|
11
|
+
CONTROLLED_TOGGLE_SLOTS,
|
|
5
12
|
DSControlledToggle,
|
|
13
|
+
DSControlledToggleName,
|
|
6
14
|
DSControlledToggleWithSchema,
|
|
7
15
|
TOGGLE_SIZES
|
|
8
16
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export {\n CONTROLLED_TOGGLE_DATA_TESTID,\n CONTROLLED_TOGGLE_SLOTS,\n DSControlledToggleName,\n TOGGLE_SIZES,\n} from './constants/index.js';\nexport { DSControlledToggle, DSControlledToggleWithSchema } from './DSControlledToggle.js';\nexport type { DSControlledToggleT } from './react-desc-prop-types.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB,oCAAoC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/package.json
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import { TYPOGRAPHY_VARIANTS } from "@elliemae/ds-typography";
|
|
5
|
+
import React2 from "react";
|
|
6
|
+
import { ControlledToggleContext } from "../DSControlledToggleCTX.js";
|
|
7
|
+
import { StyledButton, StyledButtonContentWrapper, StyledCircle, StyledTextWrapper } from "./styles/styles.js";
|
|
8
|
+
const widthSizeMap = {
|
|
9
|
+
s: 18,
|
|
10
|
+
m: 26,
|
|
11
|
+
l: 36
|
|
12
|
+
};
|
|
13
|
+
const Button = () => {
|
|
14
|
+
const { propsWithDefault, buttonProps } = React2.useContext(ControlledToggleContext);
|
|
15
|
+
const { checked, size, disabled, applyAriaDisabled, readOnly, innerRef } = propsWithDefault;
|
|
16
|
+
const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
StyledButton,
|
|
19
|
+
{
|
|
20
|
+
...readOnly ? { "aria-readonly": "true" } : {},
|
|
21
|
+
...buttonProps,
|
|
22
|
+
innerRef,
|
|
23
|
+
$checked: checked,
|
|
24
|
+
$readOnly: readOnly,
|
|
25
|
+
$disabled: disabled,
|
|
26
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
27
|
+
getOwnerProps,
|
|
28
|
+
getOwnerPropsArguments,
|
|
29
|
+
children: /* @__PURE__ */ jsxs(
|
|
30
|
+
StyledButtonContentWrapper,
|
|
31
|
+
{
|
|
32
|
+
$width: widthSizeMap[size],
|
|
33
|
+
$checked: checked,
|
|
34
|
+
$size: size,
|
|
35
|
+
getOwnerProps,
|
|
36
|
+
getOwnerPropsArguments,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
StyledCircle,
|
|
40
|
+
{
|
|
41
|
+
$size: size,
|
|
42
|
+
$disabled: disabled,
|
|
43
|
+
$readOnly: readOnly,
|
|
44
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
45
|
+
getOwnerProps,
|
|
46
|
+
getOwnerPropsArguments
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
StyledTextWrapper,
|
|
51
|
+
{
|
|
52
|
+
$size: size,
|
|
53
|
+
$disabled: disabled,
|
|
54
|
+
$readOnly: readOnly,
|
|
55
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
56
|
+
getOwnerProps,
|
|
57
|
+
getOwnerPropsArguments,
|
|
58
|
+
variant: TYPOGRAPHY_VARIANTS.B2,
|
|
59
|
+
role: "presentation",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
children: checked ? "ON" : "OFF"
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
Button
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Button.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport React from 'react';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { type DSControlledToggleT } from '../react-desc-prop-types.js';\nimport { StyledButton, StyledButtonContentWrapper, StyledCircle, StyledTextWrapper } from './styles/styles.js';\n\n// What is this about?\n// Currently the way the code is written for this component and the way this component UI/UX specs are handled\n// there is no defiend \"dynamic\" and \"responsive\" sizes also, the font-size are hardcoded and not aligned with typography in the different \"size\" variants.\n// In the past we accepted \"whatever\" labels for the toggle,\n// it was discarded as non compliant for the semantic of the component that only announces and accepts the \"on\" and \"off\" meaning,\n// as of today, wcag compliant way has an hardcoded \"ON\" and \"OFF\"/\n// The previous implementation was relying on a dynamic calculation of the width to keep the size of the toggle button,\n// it had it's own set of issues and was creating extra renders (see PUI-18655).\n\n// This constant is just the pre-calculated values to avoid extra javascript logic and extra renderes.\n\n// What does this means long term?\n// - When the font-size is aligned, the component specs are made responsive and the component will support \"text resize/reflow\",\n// - When the px will change to rem\n// - When the component will be updated to support \"tokens\"\n// - When/if the component will be i18n compliant and support different languages labels that are the other language version of \"on\" and \"off\" (like \"activ\u00E9\" and \"d\u00E9sactiv\u00E9\" in french)\n\n// The whole size calcualtion logic of the component needs to be reviewed and updated to not need a constant \"width\" to guarante the width to be \"the biggest of the two labels\".\n\n// The most reasonable implementation would be to:\n// - simply render both \"on\" and \"off\" in the DOM at the same time\n// - make the not active version influence the size but not visible (e.g. height:0, overflow:hidden)\n// - have the width be automatically calculated by the browser to fit the longest.\n\n// I can't implement this as part of the current ticket(PUI-16323) as that would be a visual breaking change and need coordination with QA and UX.\n\n// So, short term solution:\n// - Not responsive (in the rem, text resize WCAG sense, still is in the \"zoom\" sense as before)\n// - Not i18n compliant\n// - Not theming ready\n// Exactly as we never wrote the component to be, but at least it won't:\n// - flicker\n// - pay the cost of the WCAG non-compliant labels\n// - hide the pending issues with aproximation that \"happens to kinda fix it\"\n// Important note -> I changed the \"width\" to \"min-width\" to keep some amount of resize/reflow WCAG compliant (zoom will keep working, font size changes won't like before),\n// but true wcag compliance requires the component to use typography, be designed accordingly, written accordingly and rely on rem.\nconst widthSizeMap = {\n s: 18,\n m: 26,\n l: 36,\n} as const;\n\nexport const Button: React.ComponentType<DSControlledToggleT.Props> = () => {\n const { propsWithDefault, buttonProps } = React.useContext(ControlledToggleContext);\n const { checked, size, disabled, applyAriaDisabled, readOnly, innerRef } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n return (\n <StyledButton\n // as per morning meeting, juan said \"readOnly\" in toggle should receive aria-readonly, aria-readonly is valid for switch role, the html readonly attribute is not\n {...(readOnly ? { 'aria-readonly': 'true' } : {})}\n {...buttonProps}\n /**\n * PUI-14730\n * innerRef is not a global attribute, so it is not carried by buttonProps; forward it\n * explicitly to reach the underlying <button> DOM node (parity with radio/checkbox)\n */\n innerRef={innerRef}\n $checked={checked}\n $readOnly={readOnly}\n $disabled={disabled}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledButtonContentWrapper\n $width={widthSizeMap[size]}\n $checked={checked}\n $size={size}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledCircle\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n <StyledTextWrapper\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n variant={TYPOGRAPHY_VARIANTS.B2}\n // this is \"okay\" in this version but not in the WCAGViolation code\n // the reason being that a role switch with proper \"aria-checked\" already announces \"on\" and \"off\" to screen readers\n // so this is just a visual representation of the state, not a semantic one\n // the WCAGViolation code is violating this contract with custom labels and they need to be announced, so they can't be hidden from screen readers\n // and they can't be considered \"presentational\" as they are meaning bearing for scenario with custom texts (which is exactly WHY role switch is wrong in that case)\n // confirmed with Juan, this avoids the \"double announcement\" issue that was happening with the previous implementation of the component\n role=\"presentation\"\n aria-hidden=\"true\"\n >\n {checked ? 'ON' : 'OFF'}\n </StyledTextWrapper>\n </StyledButtonContentWrapper>\n </StyledButton>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwEjB,SAOE,KAPF;AAxEN,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,OAAOA,YAAW;AAClB,SAAS,+BAA+B;AAExC,SAAS,cAAc,4BAA4B,cAAc,yBAAyB;AAsC1F,MAAM,eAAe;AAAA,EACnB,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AACL;AAEO,MAAM,SAAyD,MAAM;AAC1E,QAAM,EAAE,kBAAkB,YAAY,IAAIA,OAAM,WAAW,uBAAuB;AAClF,QAAM,EAAE,SAAS,MAAM,UAAU,mBAAmB,UAAU,SAAS,IAAI;AAC3E,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,SACE;AAAA,IAAC;AAAA;AAAA,MAEE,GAAI,WAAW,EAAE,iBAAiB,OAAO,IAAI,CAAC;AAAA,MAC9C,GAAG;AAAA,MAMJ;AAAA,MACA,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,QAAQ,aAAa,IAAI;AAAA,UACzB,UAAU;AAAA,UACV,OAAO;AAAA,UACP;AAAA,UACA;AAAA,UAEA;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB;AAAA,gBACA;AAAA;AAAA,YACF;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,oBAAoB;AAAA,gBACpB;AAAA,gBACA;AAAA,gBACA,SAAS,oBAAoB;AAAA,gBAO7B,MAAK;AAAA,gBACL,eAAY;AAAA,gBAEX,oBAAU,OAAO;AAAA;AAAA,YACpB;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import React2 from "react";
|
|
5
|
+
import { CONTROLLED_TOGGLE_DATA_TESTID } from "../constants/index.js";
|
|
6
|
+
import { ControlledToggleContext } from "../DSControlledToggleCTX.js";
|
|
7
|
+
import { Button } from "./Button.js";
|
|
8
|
+
import { ButtonWCAGViolation } from "./wcagViolation/Button.wcagViolationLabels.js";
|
|
9
|
+
import { StyledContainer } from "./styles/styles.js";
|
|
10
|
+
const Container = () => {
|
|
11
|
+
const { propsWithDefault, xstyledProps } = React2.useContext(ControlledToggleContext);
|
|
12
|
+
const { wcagViolationLabelOn, wcagViolationLabelOff, size, containerProps } = propsWithDefault;
|
|
13
|
+
const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);
|
|
14
|
+
const isViolationVersion = wcagViolationLabelOn || wcagViolationLabelOff;
|
|
15
|
+
return /* @__PURE__ */ jsx(
|
|
16
|
+
StyledContainer,
|
|
17
|
+
{
|
|
18
|
+
$size: size,
|
|
19
|
+
"data-testid": CONTROLLED_TOGGLE_DATA_TESTID.CONTROLLED_CONTAINER,
|
|
20
|
+
...containerProps,
|
|
21
|
+
...xstyledProps,
|
|
22
|
+
getOwnerProps,
|
|
23
|
+
getOwnerPropsArguments,
|
|
24
|
+
children: isViolationVersion ? /* @__PURE__ */ jsx(ButtonWCAGViolation, { ...propsWithDefault }) : /* @__PURE__ */ jsx(Button, { ...propsWithDefault })
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
Container
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=Container.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Container.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport React from 'react';\nimport { CONTROLLED_TOGGLE_DATA_TESTID } from '../constants/index.js';\nimport { ControlledToggleContext } from '../DSControlledToggleCTX.js';\nimport { Button } from './Button.js';\nimport { ButtonWCAGViolation } from './wcagViolation/Button.wcagViolationLabels.js';\nimport { StyledContainer } from './styles/styles.js';\n\nexport const Container = () => {\n const { propsWithDefault, xstyledProps } = React.useContext(ControlledToggleContext);\n const { wcagViolationLabelOn, wcagViolationLabelOff, size, containerProps } = propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n\n const isViolationVersion = wcagViolationLabelOn || wcagViolationLabelOff;\n\n return (\n <StyledContainer\n $size={size}\n data-testid={CONTROLLED_TOGGLE_DATA_TESTID.CONTROLLED_CONTAINER}\n {...containerProps}\n {...xstyledProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n {isViolationVersion ? <ButtonWCAGViolation {...propsWithDefault} /> : <Button {...propsWithDefault} />}\n </StyledContainer>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACwBK;AAxB5B,SAAS,qBAAqB;AAC9B,OAAOA,YAAW;AAClB,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAEzB,MAAM,YAAY,MAAM;AAC7B,QAAM,EAAE,kBAAkB,aAAa,IAAIA,OAAM,WAAW,uBAAuB;AACnF,QAAM,EAAE,sBAAsB,uBAAuB,MAAM,eAAe,IAAI;AAC9E,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAEhF,QAAM,qBAAqB,wBAAwB;AAEnD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,eAAa,8BAA8B;AAAA,MAC1C,GAAG;AAAA,MACH,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MAEC,+BAAqB,oBAAC,uBAAqB,GAAG,kBAAkB,IAAK,oBAAC,UAAQ,GAAG,kBAAkB;AAAA;AAAA,EACtG;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DSButtonV3 } from "@elliemae/ds-button-v2";
|
|
3
|
+
import { css, styled, xStyledCommonProps } from "@elliemae/ds-system";
|
|
4
|
+
import { DSTypography } from "@elliemae/ds-typography";
|
|
5
|
+
import { CONTROLLED_TOGGLE_SLOTS, DSControlledToggleName } from "../../constants/index.js";
|
|
6
|
+
const containerHeight = {
|
|
7
|
+
s: "20px",
|
|
8
|
+
m: "28px",
|
|
9
|
+
l: "36px"
|
|
10
|
+
};
|
|
11
|
+
const StyledContainer = styled("div", {
|
|
12
|
+
name: DSControlledToggleName,
|
|
13
|
+
slot: CONTROLLED_TOGGLE_SLOTS.CONTROLLED_CONTAINER
|
|
14
|
+
})`
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
width: fit-content;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
height: ${({ $size }) => containerHeight[$size]};
|
|
20
|
+
padding: 2px;
|
|
21
|
+
border-radius: 20px;
|
|
22
|
+
:focus-within {
|
|
23
|
+
background-color: ${({ theme }) => theme.colors.neutral["000"]};
|
|
24
|
+
}
|
|
25
|
+
${xStyledCommonProps}
|
|
26
|
+
`;
|
|
27
|
+
const SwitchButtonStateColors = css`
|
|
28
|
+
${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {
|
|
29
|
+
if ($disabled)
|
|
30
|
+
return `
|
|
31
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
32
|
+
border: 2px solid ${theme.colors.neutral["400"]};
|
|
33
|
+
`;
|
|
34
|
+
if ($readOnly || $applyAriaDisabled)
|
|
35
|
+
return `
|
|
36
|
+
background-color: ${theme.colors.neutral["050"]};
|
|
37
|
+
border: 2px solid ${theme.colors.neutral["400"]};
|
|
38
|
+
`;
|
|
39
|
+
if ($checked)
|
|
40
|
+
return `
|
|
41
|
+
background-color: ${theme.colors.brand["600"]};
|
|
42
|
+
border: 2px solid ${theme.colors.brand["700"]};
|
|
43
|
+
`;
|
|
44
|
+
return `
|
|
45
|
+
background-color: ${theme.colors.neutral["500"]};
|
|
46
|
+
border: 2px solid ${theme.colors.neutral["600"]};
|
|
47
|
+
`;
|
|
48
|
+
}}
|
|
49
|
+
`;
|
|
50
|
+
const SwitchCursors = css`
|
|
51
|
+
${({ $disabled, $readOnly, $applyAriaDisabled }) => {
|
|
52
|
+
if ($disabled || $readOnly || $applyAriaDisabled)
|
|
53
|
+
return `
|
|
54
|
+
cursor: not-allowed;
|
|
55
|
+
`;
|
|
56
|
+
return `
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
`;
|
|
59
|
+
}}
|
|
60
|
+
`;
|
|
61
|
+
const SwitchHoverColors = css`
|
|
62
|
+
${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {
|
|
63
|
+
if ($disabled)
|
|
64
|
+
return `
|
|
65
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
66
|
+
`;
|
|
67
|
+
if ($readOnly || $applyAriaDisabled)
|
|
68
|
+
return `
|
|
69
|
+
background-color: ${theme.colors.neutral["050"]};
|
|
70
|
+
`;
|
|
71
|
+
if ($checked)
|
|
72
|
+
return `
|
|
73
|
+
background-color: ${theme.colors.brand["700"]};
|
|
74
|
+
border-color: ${theme.colors.brand["800"]};
|
|
75
|
+
`;
|
|
76
|
+
return `
|
|
77
|
+
background-color: ${theme.colors.neutral["600"]};
|
|
78
|
+
border-color: ${theme.colors.neutral["700"]};
|
|
79
|
+
`;
|
|
80
|
+
}}
|
|
81
|
+
`;
|
|
82
|
+
const StyledButton = styled(DSButtonV3, {
|
|
83
|
+
name: DSControlledToggleName,
|
|
84
|
+
slot: CONTROLLED_TOGGLE_SLOTS.TOGGLE_CHECKBOX
|
|
85
|
+
})`
|
|
86
|
+
margin: 0;
|
|
87
|
+
padding: 0;
|
|
88
|
+
border-radius: 20px;
|
|
89
|
+
${SwitchButtonStateColors}
|
|
90
|
+
transition: background-color 0.2s;
|
|
91
|
+
:focus {
|
|
92
|
+
outline: 2px solid ${({ theme }) => theme.colors.brand["700"]};
|
|
93
|
+
outline-offset: 1px;
|
|
94
|
+
}
|
|
95
|
+
&:hover {
|
|
96
|
+
${SwitchCursors}
|
|
97
|
+
${SwitchHoverColors}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
const labelHeight = {
|
|
101
|
+
s: "16px",
|
|
102
|
+
m: "24px",
|
|
103
|
+
l: "32px"
|
|
104
|
+
};
|
|
105
|
+
const margin = {
|
|
106
|
+
s: "26px",
|
|
107
|
+
m: "34px",
|
|
108
|
+
l: "42px"
|
|
109
|
+
};
|
|
110
|
+
const StyledButtonContentWrapper = styled("div", {
|
|
111
|
+
name: DSControlledToggleName,
|
|
112
|
+
slot: CONTROLLED_TOGGLE_SLOTS.BUTTON_CONTENT_WRAPPER
|
|
113
|
+
})`
|
|
114
|
+
min-width: ${({ $width, $size }) => `calc(${$width}px + ${margin[$size]})`};
|
|
115
|
+
height: ${({ $size }) => labelHeight[$size]};
|
|
116
|
+
display: flex;
|
|
117
|
+
margin: 0;
|
|
118
|
+
padding: 0;
|
|
119
|
+
align-items: center;
|
|
120
|
+
height: 100%;
|
|
121
|
+
flex-direction: ${({ $checked }) => $checked ? "row-reverse" : "row"};
|
|
122
|
+
border-radius: 20px;
|
|
123
|
+
`;
|
|
124
|
+
const CircleColors = css`
|
|
125
|
+
${({ theme, $disabled, $readOnly, $applyAriaDisabled }) => {
|
|
126
|
+
if ($disabled) {
|
|
127
|
+
return `
|
|
128
|
+
background-color: ${theme.colors.neutral["080"]};
|
|
129
|
+
outline: 2px solid ${theme.colors.neutral["400"]};
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
if ($readOnly || $applyAriaDisabled) {
|
|
133
|
+
return `
|
|
134
|
+
background-color: ${theme.colors.neutral["000"]};
|
|
135
|
+
outline: 2px solid ${theme.colors.neutral["400"]};
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
return `
|
|
139
|
+
background-color: ${theme.colors.neutral["000"]};
|
|
140
|
+
`;
|
|
141
|
+
}}
|
|
142
|
+
`;
|
|
143
|
+
const circleValues = {
|
|
144
|
+
s: "14px",
|
|
145
|
+
m: "20px",
|
|
146
|
+
l: "28px"
|
|
147
|
+
};
|
|
148
|
+
const StyledCircle = styled("div", {
|
|
149
|
+
name: DSControlledToggleName,
|
|
150
|
+
slot: CONTROLLED_TOGGLE_SLOTS.CIRCLE
|
|
151
|
+
})`
|
|
152
|
+
height: ${({ $size }) => circleValues[$size]};
|
|
153
|
+
width: ${({ $size }) => circleValues[$size]};
|
|
154
|
+
border-radius: 50%;
|
|
155
|
+
${CircleColors}
|
|
156
|
+
`;
|
|
157
|
+
const TextWrapperColors = css`
|
|
158
|
+
${({ theme, $disabled, $applyAriaDisabled, $readOnly }) => {
|
|
159
|
+
if ($disabled || $applyAriaDisabled || $readOnly) {
|
|
160
|
+
return `
|
|
161
|
+
color: ${theme.colors.neutral["600"]};
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
return `
|
|
165
|
+
color: ${theme.colors.neutral["000"]};
|
|
166
|
+
`;
|
|
167
|
+
}}
|
|
168
|
+
`;
|
|
169
|
+
const RemBasedFontProperties = css`
|
|
170
|
+
${({ theme, $size }) => {
|
|
171
|
+
if ($size === "s")
|
|
172
|
+
return `
|
|
173
|
+
font-size: 0.6875rem; // 11px -> 11/16 = 0.6875rem
|
|
174
|
+
line-height: 0.6875rem; // 11px -> 11/16 = 0.6875rem
|
|
175
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
176
|
+
font-size: 0.84615rem; // 11px -> 11/13 = 0.84615rem
|
|
177
|
+
line-height: 0.84615rem; // 11px -> 11/13 = 0.84615rem
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
if ($size === "l")
|
|
181
|
+
return `
|
|
182
|
+
font-size: 1.25rem; // 20px -> 20/16 = 1.25rem
|
|
183
|
+
line-height: 1.25rem; // 20px -> 20/16 = 1.25rem
|
|
184
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
185
|
+
font-size: 1.53846rem; // 20px -> 20/13 = 1.53846rem
|
|
186
|
+
line-height: 1.53846rem; // 20px -> 20/13 = 1.53846rem
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
return `
|
|
190
|
+
font-size: 0.9375rem; // 15px -> 15/16 = 0.9375rem
|
|
191
|
+
line-height: 0.9375rem; // 15px -> 15/16 = 0.9375rem
|
|
192
|
+
@media (min-width: ${theme.breakpoints.small}) {
|
|
193
|
+
font-size: 1.15385rem; // 15px -> 15/13 = 1.15385rem
|
|
194
|
+
line-height: 1.15385rem; // 15px -> 15/13 = 1.15385rem
|
|
195
|
+
}
|
|
196
|
+
`;
|
|
197
|
+
}}
|
|
198
|
+
`;
|
|
199
|
+
const StyledTextWrapper = styled(DSTypography, {
|
|
200
|
+
name: DSControlledToggleName,
|
|
201
|
+
slot: CONTROLLED_TOGGLE_SLOTS.TEXT_WRAPPER
|
|
202
|
+
})`
|
|
203
|
+
flex-grow: 1;
|
|
204
|
+
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
205
|
+
${RemBasedFontProperties}
|
|
206
|
+
${TextWrapperColors}
|
|
207
|
+
`;
|
|
208
|
+
export {
|
|
209
|
+
RemBasedFontProperties,
|
|
210
|
+
StyledButton,
|
|
211
|
+
StyledButtonContentWrapper,
|
|
212
|
+
StyledCircle,
|
|
213
|
+
StyledContainer,
|
|
214
|
+
StyledTextWrapper
|
|
215
|
+
};
|
|
216
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/styles/styles.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport { DSButtonV3 } from '@elliemae/ds-button-v2';\nimport { css, styled, xStyledCommonProps } from '@elliemae/ds-system';\nimport { DSTypography, type DSTypographyT } from '@elliemae/ds-typography';\nimport { CONTROLLED_TOGGLE_SLOTS, DSControlledToggleName } from '../../constants/index.js';\nimport type { DSControlledToggleT } from '../../react-desc-prop-types.js';\n\ninterface StyledContainerT {\n $size: DSControlledToggleT.ToggleSize;\n}\nconst containerHeight = {\n s: '20px',\n m: '28px',\n l: '36px',\n};\nexport const StyledContainer = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.CONTROLLED_CONTAINER,\n})<StyledContainerT>`\n display: inline-flex;\n width: fit-content;\n justify-content: center;\n align-items: center;\n height: ${({ $size }) => containerHeight[$size]};\n padding: 2px;\n border-radius: 20px;\n :focus-within {\n background-color: ${({ theme }) => theme.colors.neutral['000']};\n }\n ${xStyledCommonProps}\n`;\ninterface StyledButtonT {\n $checked: boolean;\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}\nconst SwitchButtonStateColors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {\n // 1. disabled (standard HTML attribute)\n if ($disabled)\n return `\n background-color: ${theme.colors.neutral['080']};\n border: 2px solid ${theme.colors.neutral['400']};\n `;\n // 2. Aria-Read-Only / Aria-Disabled\n if ($readOnly || $applyAriaDisabled)\n return `\n background-color: ${theme.colors.neutral['050']};\n border: 2px solid ${theme.colors.neutral['400']};\n `;\n // 3. Enabled\n // a. Checked\n if ($checked)\n return `\n background-color: ${theme.colors.brand['600']};\n border: 2px solid ${theme.colors.brand['700']};\n `;\n // b. Not checked\n return `\n background-color: ${theme.colors.neutral['500']};\n border: 2px solid ${theme.colors.neutral['600']};\n `;\n }}\n`;\nconst SwitchCursors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled }) => {\n // 1. truly disabled (standard HTML attribute)\n if ($disabled || $readOnly || $applyAriaDisabled)\n // /\\ this \"cursor: not-allowed\" for the aria-disabled/aria-readonly is not consistent what the spec says\n // as of today readonly/aria-disabled say \"arrow\" (default) but that is not consistent with other dimsum components\n // coordinated with QA, we ship this consistent with other dimsum components and if UX confirms the intention we change it later\n return `\n cursor: not-allowed;\n `;\n // 2. Enabled\n return `\n cursor: pointer;\n `;\n }}\n`;\nconst SwitchHoverColors = css<StyledButtonT>`\n ${({ $disabled, $readOnly, $applyAriaDisabled, $checked, theme }) => {\n // the button \"on hover\" overrides with background: transparent\n // disabled keeps the same color as before, no hover effect, but we compensate the transparent effect inherithed from the button hover.\n // 1. disabled (standard HTML attribute)\n if ($disabled)\n return `\n background-color: ${theme.colors.neutral['080']};\n `;\n // 2. Aria-Read-Only / Aria-Disabled\n // the button \"on hover\" overrides with background: transparent\n // disabled keeps the same color as before, no hover effect, but we compensate the transparent effect inherithed from the button hover.\n if ($readOnly || $applyAriaDisabled)\n return `\n background-color: ${theme.colors.neutral['050']};\n `;\n // 2. Enabled\n // a. Checked\n if ($checked)\n return `\n background-color: ${theme.colors.brand['700']};\n border-color: ${theme.colors.brand['800']};\n `;\n // b. Not checked\n return `\n background-color: ${theme.colors.neutral['600']};\n border-color: ${theme.colors.neutral['700']};\n `;\n }}\n`;\nexport const StyledButton = styled(DSButtonV3, {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.TOGGLE_CHECKBOX,\n})<StyledButtonT>`\n margin: 0;\n padding: 0;\n border-radius: 20px;\n ${SwitchButtonStateColors}\n transition: background-color 0.2s;\n :focus {\n outline: 2px solid ${({ theme }) => theme.colors.brand['700']};\n outline-offset: 1px;\n }\n &:hover {\n ${SwitchCursors}\n ${SwitchHoverColors}\n }\n`;\ninterface StyledButtonContentWrapperT {\n $size: DSControlledToggleT.ToggleSize;\n $width: number;\n $checked: boolean;\n}\nconst labelHeight = {\n s: '16px',\n m: '24px',\n l: '32px',\n};\nconst margin = {\n s: '26px',\n m: '34px',\n l: '42px',\n};\nexport const StyledButtonContentWrapper = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.BUTTON_CONTENT_WRAPPER,\n})<StyledButtonContentWrapperT>`\n min-width: ${({ $width, $size }) => `calc(${$width}px + ${margin[$size]})`};\n height: ${({ $size }) => labelHeight[$size]};\n display: flex;\n margin: 0;\n padding: 0;\n align-items: center;\n height: 100%;\n flex-direction: ${({ $checked }) => ($checked ? 'row-reverse' : 'row')};\n border-radius: 20px;\n`;\ninterface StyledCircleT {\n $size: DSControlledToggleT.ToggleSize;\n $disabled: boolean;\n $readOnly: boolean;\n $applyAriaDisabled: boolean;\n}\nconst CircleColors = css<StyledCircleT>`\n ${({ theme, $disabled, $readOnly, $applyAriaDisabled }) => {\n // 1. Truly disabled (standard HTML attribute)\n if ($disabled) {\n return `\n background-color: ${theme.colors.neutral['080']};\n outline: 2px solid ${theme.colors.neutral['400']};\n `;\n }\n\n // 2. Aria-disabled / aria-readonly\n if ($readOnly || $applyAriaDisabled) {\n return `\n background-color: ${theme.colors.neutral['000']};\n outline: 2px solid ${theme.colors.neutral['400']};\n `;\n }\n\n // 3. Enabled\n return `\n background-color: ${theme.colors.neutral['000']};\n `;\n }}\n`;\nconst circleValues = {\n s: '14px',\n m: '20px',\n l: '28px',\n};\nexport const StyledCircle = styled('div', {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.CIRCLE,\n})<StyledCircleT>`\n height: ${({ $size }) => circleValues[$size]};\n width: ${({ $size }) => circleValues[$size]};\n border-radius: 50%;\n ${CircleColors}\n`;\ninterface StyledTextWrapperT extends DSTypographyT.Props {\n $size: DSControlledToggleT.ToggleSize;\n $disabled: boolean;\n $applyAriaDisabled: boolean;\n $readOnly: boolean;\n}\nconst TextWrapperColors = css<StyledTextWrapperT>`\n ${({ theme, $disabled, $applyAriaDisabled, $readOnly }) => {\n // 1. Truly disabled, applyAriaDisabled, readOnly\n if ($disabled || $applyAriaDisabled || $readOnly) {\n return `\n color: ${theme.colors.neutral['600']};\n `;\n }\n // 2. Enabled\n return `\n color: ${theme.colors.neutral['000']};\n `;\n }}\n`;\nexport const RemBasedFontProperties = css<{ $size: DSControlledToggleT.ToggleSize }>`\n ${({ theme, $size }) => {\n if ($size === 's')\n return `\n font-size: 0.6875rem; // 11px -> 11/16 = 0.6875rem\n line-height: 0.6875rem; // 11px -> 11/16 = 0.6875rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 0.84615rem; // 11px -> 11/13 = 0.84615rem\n line-height: 0.84615rem; // 11px -> 11/13 = 0.84615rem\n }\n `;\n if ($size === 'l')\n return `\n font-size: 1.25rem; // 20px -> 20/16 = 1.25rem\n line-height: 1.25rem; // 20px -> 20/16 = 1.25rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 1.53846rem; // 20px -> 20/13 = 1.53846rem\n line-height: 1.53846rem; // 20px -> 20/13 = 1.53846rem\n }\n `;\n return `\n font-size: 0.9375rem; // 15px -> 15/16 = 0.9375rem\n line-height: 0.9375rem; // 15px -> 15/16 = 0.9375rem\n @media (min-width: ${theme.breakpoints.small}) {\n font-size: 1.15385rem; // 15px -> 15/13 = 1.15385rem\n line-height: 1.15385rem; // 15px -> 15/13 = 1.15385rem\n }\n `;\n }}\n`;\nexport const StyledTextWrapper = styled(DSTypography, {\n name: DSControlledToggleName,\n slot: CONTROLLED_TOGGLE_SLOTS.TEXT_WRAPPER,\n})<StyledTextWrapperT>`\n flex-grow: 1;\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n ${RemBasedFontProperties}\n ${TextWrapperColors}\n`;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import { TYPOGRAPHY_VARIANTS } from "@elliemae/ds-typography";
|
|
5
|
+
import { styled } from "@elliemae/ds-system";
|
|
6
|
+
import React2 from "react";
|
|
7
|
+
import { ControlledToggleContext } from "../../DSControlledToggleCTX.js";
|
|
8
|
+
import {
|
|
9
|
+
RemBasedFontProperties,
|
|
10
|
+
StyledButton,
|
|
11
|
+
StyledButtonContentWrapper,
|
|
12
|
+
StyledCircle,
|
|
13
|
+
StyledTextWrapper
|
|
14
|
+
} from "../styles/styles.js";
|
|
15
|
+
import { useGetWidestLabelWidth } from "./useGetWidestLabelWidth.js";
|
|
16
|
+
const SetLabelWidth = styled.div`
|
|
17
|
+
${RemBasedFontProperties}
|
|
18
|
+
font-weight: ${({ theme }) => theme.fontWeights.semibold};
|
|
19
|
+
width: auto;
|
|
20
|
+
position: absolute;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
visibility: hidden;
|
|
23
|
+
`;
|
|
24
|
+
const ButtonWCAGViolation = () => {
|
|
25
|
+
const { propsWithDefault, buttonProps } = React2.useContext(ControlledToggleContext);
|
|
26
|
+
const { wcagViolationLabelOn, wcagViolationLabelOff, checked, size, disabled, applyAriaDisabled, readOnly } = propsWithDefault;
|
|
27
|
+
const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);
|
|
28
|
+
const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = useGetWidestLabelWidth();
|
|
29
|
+
return /* @__PURE__ */ jsxs(
|
|
30
|
+
StyledButton,
|
|
31
|
+
{
|
|
32
|
+
...readOnly ? { "aria-readonly": "true" } : {},
|
|
33
|
+
...buttonProps,
|
|
34
|
+
$checked: checked,
|
|
35
|
+
$readOnly: readOnly,
|
|
36
|
+
$disabled: disabled,
|
|
37
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
38
|
+
getOwnerProps,
|
|
39
|
+
getOwnerPropsArguments,
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsxs(
|
|
42
|
+
StyledButtonContentWrapper,
|
|
43
|
+
{
|
|
44
|
+
$width: width,
|
|
45
|
+
$checked: checked,
|
|
46
|
+
$size: size,
|
|
47
|
+
getOwnerProps,
|
|
48
|
+
getOwnerPropsArguments,
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
StyledCircle,
|
|
52
|
+
{
|
|
53
|
+
$size: size,
|
|
54
|
+
$disabled: disabled,
|
|
55
|
+
$readOnly: readOnly,
|
|
56
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
57
|
+
getOwnerProps,
|
|
58
|
+
getOwnerPropsArguments
|
|
59
|
+
}
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
StyledTextWrapper,
|
|
63
|
+
{
|
|
64
|
+
$size: size,
|
|
65
|
+
$disabled: disabled,
|
|
66
|
+
$readOnly: readOnly,
|
|
67
|
+
$applyAriaDisabled: applyAriaDisabled,
|
|
68
|
+
getOwnerProps,
|
|
69
|
+
getOwnerPropsArguments,
|
|
70
|
+
variant: TYPOGRAPHY_VARIANTS.B2,
|
|
71
|
+
children: checked ? wcagViolationLabelOn ?? "ON" : wcagViolationLabelOff ?? "OFF"
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ jsx(SetLabelWidth, { $size: size, innerRef: handleRefOnLabelWidth, "aria-hidden": "true", children: wcagViolationLabelOn ?? "ON" }),
|
|
78
|
+
/* @__PURE__ */ jsx(SetLabelWidth, { $size: size, innerRef: handleRefOffLabelWidth, "aria-hidden": "true", children: wcagViolationLabelOff ?? "OFF" })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
ButtonWCAGViolation
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=Button.wcagViolationLabels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/wcagViolation/Button.wcagViolationLabels.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { TYPOGRAPHY_VARIANTS } from '@elliemae/ds-typography';\nimport { styled } from '@elliemae/ds-system';\nimport React from 'react';\nimport { ControlledToggleContext } from '../../DSControlledToggleCTX.js';\nimport type { DSControlledToggleT } from '../../react-desc-prop-types.js';\nimport {\n RemBasedFontProperties,\n StyledButton,\n StyledButtonContentWrapper,\n StyledCircle,\n StyledTextWrapper,\n} from '../styles/styles.js';\nimport { useGetWidestLabelWidth } from './useGetWidestLabelWidth.js';\n\n/**\n * we are doing this to keep the wcagViolationLabelOn/wcagViolationLabelOff working\n * this calculates the width of the widest custom label and sets the width of both labels to that width to avoid layout shift on toggle\n *\n * ---\n *\n * this can be safely removed in favor of a sensible default min-width for the accessible ON/OFF labels when we can actually kill the wcagViolationLabelOn/wcagViolationLabelOff props\n */\nconst SetLabelWidth = styled.div<{ $size: DSControlledToggleT.ToggleSize }>`\n ${RemBasedFontProperties}\n font-weight: ${({ theme }) => theme.fontWeights.semibold};\n width: auto;\n position: absolute;\n white-space: nowrap;\n visibility: hidden;\n`;\n\nexport const ButtonWCAGViolation: React.ComponentType<DSControlledToggleT.Props> = () => {\n const { propsWithDefault, buttonProps } = React.useContext(ControlledToggleContext);\n const { wcagViolationLabelOn, wcagViolationLabelOff, checked, size, disabled, applyAriaDisabled, readOnly } =\n propsWithDefault;\n const { getOwnerProps, getOwnerPropsArguments } = useOwnerProps(propsWithDefault);\n const { width, handleRefOnLabelWidth, handleRefOffLabelWidth } = useGetWidestLabelWidth();\n\n return (\n <StyledButton\n // as per morning meeting, juan said \"readOnly\" in toggle should receive aria-readonly, aria-readonly is valid for switch role, the html readonly attribute is not\n {...(readOnly ? { 'aria-readonly': 'true' } : {})}\n {...buttonProps}\n $checked={checked}\n $readOnly={readOnly}\n $disabled={disabled}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledButtonContentWrapper\n $width={width}\n $checked={checked}\n $size={size}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n >\n <StyledCircle\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n <StyledTextWrapper\n $size={size}\n $disabled={disabled}\n $readOnly={readOnly}\n $applyAriaDisabled={applyAriaDisabled}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n variant={TYPOGRAPHY_VARIANTS.B2}\n >\n {checked ? (wcagViolationLabelOn ?? 'ON') : (wcagViolationLabelOff ?? 'OFF')}\n </StyledTextWrapper>\n </StyledButtonContentWrapper>\n <SetLabelWidth $size={size} innerRef={handleRefOnLabelWidth} aria-hidden=\"true\">\n {wcagViolationLabelOn ?? 'ON'}\n </SetLabelWidth>\n <SetLabelWidth $size={size} innerRef={handleRefOffLabelWidth} aria-hidden=\"true\">\n {wcagViolationLabelOff ?? 'OFF'}\n </SetLabelWidth>\n </StyledButton>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACmDjB,SAOE,KAPF;AAnDN,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,cAAc;AACvB,OAAOA,YAAW;AAClB,SAAS,+BAA+B;AAExC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAUvC,MAAM,gBAAgB,OAAO;AAAA,IACzB,sBAAsB;AAAA,iBACT,CAAC,EAAE,MAAM,MAAM,MAAM,YAAY,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAOnD,MAAM,sBAAsE,MAAM;AACvF,QAAM,EAAE,kBAAkB,YAAY,IAAIA,OAAM,WAAW,uBAAuB;AAClF,QAAM,EAAE,sBAAsB,uBAAuB,SAAS,MAAM,UAAU,mBAAmB,SAAS,IACxG;AACF,QAAM,EAAE,eAAe,uBAAuB,IAAI,cAAc,gBAAgB;AAChF,QAAM,EAAE,OAAO,uBAAuB,uBAAuB,IAAI,uBAAuB;AAExF,SACE;AAAA,IAAC;AAAA;AAAA,MAEE,GAAI,WAAW,EAAE,iBAAiB,OAAO,IAAI,CAAC;AAAA,MAC9C,GAAG;AAAA,MACJ,UAAU;AAAA,MACV,WAAW;AAAA,MACX,WAAW;AAAA,MACX,oBAAoB;AAAA,MACpB;AAAA,MACA;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,QAAQ;AAAA,YACR,UAAU;AAAA,YACV,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YAEA;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP,WAAW;AAAA,kBACX,WAAW;AAAA,kBACX,oBAAoB;AAAA,kBACpB;AAAA,kBACA;AAAA;AAAA,cACF;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,OAAO;AAAA,kBACP,WAAW;AAAA,kBACX,WAAW;AAAA,kBACX,oBAAoB;AAAA,kBACpB;AAAA,kBACA;AAAA,kBACA,SAAS,oBAAoB;AAAA,kBAE5B,oBAAW,wBAAwB,OAAS,yBAAyB;AAAA;AAAA,cACxE;AAAA;AAAA;AAAA,QACF;AAAA,QACA,oBAAC,iBAAc,OAAO,MAAM,UAAU,uBAAuB,eAAY,QACtE,kCAAwB,MAC3B;AAAA,QACA,oBAAC,iBAAc,OAAO,MAAM,UAAU,wBAAwB,eAAY,QACvE,mCAAyB,OAC5B;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|