@transferwise/components 46.60.0 → 46.61.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/checkboxButton/CheckboxButton.js +15 -4
- package/build/checkboxButton/CheckboxButton.js.map +1 -1
- package/build/checkboxButton/CheckboxButton.mjs +16 -5
- package/build/checkboxButton/CheckboxButton.mjs.map +1 -1
- package/build/chips/Chips.js +4 -5
- package/build/chips/Chips.js.map +1 -1
- package/build/chips/Chips.mjs +4 -5
- package/build/chips/Chips.mjs.map +1 -1
- package/build/main.css +20 -1
- package/build/styles/checkboxButton/CheckboxButton.css +20 -1
- package/build/styles/main.css +20 -1
- package/build/types/checkboxButton/CheckboxButton.d.ts +6 -2
- package/build/types/checkboxButton/CheckboxButton.d.ts.map +1 -1
- package/build/types/chips/Chips.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/checkbox/__snapshots__/Checkbox.spec.tsx.snap +3 -0
- package/src/checkboxButton/CheckboxButton.css +20 -1
- package/src/checkboxButton/CheckboxButton.less +22 -1
- package/src/checkboxButton/CheckboxButton.story.tsx +24 -1
- package/src/checkboxButton/CheckboxButton.tsx +18 -4
- package/src/chips/Chips.spec.tsx +1 -1
- package/src/chips/Chips.tsx +2 -3
- package/src/chips/__snapshots__/Chips.spec.tsx.snap +5 -4
- package/src/main.css +20 -1
|
@@ -7,27 +7,38 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
|
|
8
8
|
const CheckboxButton = /*#__PURE__*/React.forwardRef(function CheckboxButton({
|
|
9
9
|
checked,
|
|
10
|
+
indeterminate = false,
|
|
10
11
|
className,
|
|
11
12
|
disabled,
|
|
12
13
|
onChange,
|
|
13
14
|
...rest
|
|
14
15
|
}, reference) {
|
|
15
16
|
const inputAttributes = contexts.useInputAttributes();
|
|
17
|
+
const internalRef = React.useRef(null);
|
|
18
|
+
React.useImperativeHandle(reference, () => internalRef.current ?? {});
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (internalRef.current) {
|
|
21
|
+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-assignment
|
|
22
|
+
internalRef.current.indeterminate = indeterminate;
|
|
23
|
+
}
|
|
24
|
+
}, [indeterminate, reference]);
|
|
16
25
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
17
26
|
className: clsx.clsx('np-checkbox-button', className, disabled && 'disabled'),
|
|
18
27
|
children: [/*#__PURE__*/jsxRuntime.jsx("input", {
|
|
19
28
|
...inputAttributes,
|
|
20
29
|
...rest,
|
|
21
|
-
ref: reference,
|
|
30
|
+
ref: reference ?? internalRef,
|
|
22
31
|
type: "checkbox",
|
|
23
32
|
disabled: disabled,
|
|
24
33
|
checked: checked,
|
|
25
34
|
onChange: onChange
|
|
26
|
-
}), /*#__PURE__*/jsxRuntime.
|
|
35
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
27
36
|
className: "tw-checkbox-button",
|
|
28
|
-
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
37
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
29
38
|
className: "tw-checkbox-check"
|
|
30
|
-
})
|
|
39
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
40
|
+
className: "np-tw-checkbox-indeterminate"
|
|
41
|
+
})]
|
|
31
42
|
})]
|
|
32
43
|
});
|
|
33
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxButton.js","sources":["../../src/checkboxButton/CheckboxButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { InputHTMLAttributes, forwardRef } from 'react';\n\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement
|
|
1
|
+
{"version":3,"file":"CheckboxButton.js","sources":["../../src/checkboxButton/CheckboxButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { InputHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {\n indeterminate?: boolean;\n};\n\nconst CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(function CheckboxButton(\n { checked, indeterminate = false, className, disabled, onChange, ...rest },\n reference,\n) {\n const inputAttributes = useInputAttributes();\n\n const internalRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(reference, () => internalRef.current ?? ({} as HTMLInputElement));\n\n useEffect(() => {\n if (internalRef.current) {\n // eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-assignment\n internalRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate, reference]);\n\n return (\n <span className={clsx('np-checkbox-button', className, disabled && 'disabled')}>\n <input\n {...inputAttributes}\n {...rest}\n ref={reference ?? internalRef}\n type=\"checkbox\"\n disabled={disabled}\n checked={checked}\n onChange={onChange}\n />\n <span className=\"tw-checkbox-button\">\n <span className=\"tw-checkbox-check\" />\n <span className=\"np-tw-checkbox-indeterminate\" />\n </span>\n </span>\n );\n});\n\nexport default CheckboxButton;\n"],"names":["CheckboxButton","forwardRef","checked","indeterminate","className","disabled","onChange","rest","reference","inputAttributes","useInputAttributes","internalRef","useRef","useImperativeHandle","current","useEffect","_jsxs","clsx","children","_jsx","ref","type"],"mappings":";;;;;;;AASA,MAAMA,cAAc,gBAAGC,gBAAU,CAAwC,SAASD,cAAcA,CAC9F;EAAEE,OAAO;AAAEC,EAAAA,aAAa,GAAG,KAAK;EAAEC,SAAS;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC,IAAAA;AAAM,CAAA,EAC1EC,SAAS,EAAA;AAET,EAAA,MAAMC,eAAe,GAAGC,2BAAkB,EAAE,CAAA;AAE5C,EAAA,MAAMC,WAAW,GAAGC,YAAM,CAAmB,IAAI,CAAC,CAAA;EAElDC,yBAAmB,CAACL,SAAS,EAAE,MAAMG,WAAW,CAACG,OAAO,IAAK,EAAuB,CAAC,CAAA;AAErFC,EAAAA,eAAS,CAAC,MAAK;IACb,IAAIJ,WAAW,CAACG,OAAO,EAAE;AACvB;AACAH,MAAAA,WAAW,CAACG,OAAO,CAACX,aAAa,GAAGA,aAAa,CAAA;AACnD,KAAA;AACF,GAAC,EAAE,CAACA,aAAa,EAAEK,SAAS,CAAC,CAAC,CAAA;AAE9B,EAAA,oBACEQ,eAAA,CAAA,MAAA,EAAA;IAAMZ,SAAS,EAAEa,SAAI,CAAC,oBAAoB,EAAEb,SAAS,EAAEC,QAAQ,IAAI,UAAU,CAAE;AAAAa,IAAAA,QAAA,gBAC7EC,cAAA,CAAA,OAAA,EAAA;AAAA,MAAA,GACMV,eAAe;AAAA,MAAA,GACfF,IAAI;MACRa,GAAG,EAAEZ,SAAS,IAAIG,WAAY;AAC9BU,MAAAA,IAAI,EAAC,UAAU;AACfhB,MAAAA,QAAQ,EAAEA,QAAS;AACnBH,MAAAA,OAAO,EAAEA,OAAQ;AACjBI,MAAAA,QAAQ,EAAEA,QAAAA;KAEZ,CAAA,eAAAU,eAAA,CAAA,MAAA,EAAA;AAAMZ,MAAAA,SAAS,EAAC,oBAAoB;AAAAc,MAAAA,QAAA,gBAClCC,cAAA,CAAA,MAAA,EAAA;AAAMf,QAAAA,SAAS,EAAC,mBAAA;OAChB,CAAA,eAAAe,cAAA,CAAA,MAAA,EAAA;AAAMf,QAAAA,SAAS,EAAC,8BAAA;AAA8B,OAChD,CAAA,CAAA;AAAA,KAAM,CACR,CAAA;AAAA,GAAM,CAAC,CAAA;AAEX,CAAC;;;;"}
|
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
2
|
+
import { forwardRef, useRef, useImperativeHandle, useEffect } from 'react';
|
|
3
3
|
import { useInputAttributes } from '../inputs/contexts.mjs';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
const CheckboxButton = /*#__PURE__*/forwardRef(function CheckboxButton({
|
|
7
7
|
checked,
|
|
8
|
+
indeterminate = false,
|
|
8
9
|
className,
|
|
9
10
|
disabled,
|
|
10
11
|
onChange,
|
|
11
12
|
...rest
|
|
12
13
|
}, reference) {
|
|
13
14
|
const inputAttributes = useInputAttributes();
|
|
15
|
+
const internalRef = useRef(null);
|
|
16
|
+
useImperativeHandle(reference, () => internalRef.current ?? {});
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (internalRef.current) {
|
|
19
|
+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-assignment
|
|
20
|
+
internalRef.current.indeterminate = indeterminate;
|
|
21
|
+
}
|
|
22
|
+
}, [indeterminate, reference]);
|
|
14
23
|
return /*#__PURE__*/jsxs("span", {
|
|
15
24
|
className: clsx('np-checkbox-button', className, disabled && 'disabled'),
|
|
16
25
|
children: [/*#__PURE__*/jsx("input", {
|
|
17
26
|
...inputAttributes,
|
|
18
27
|
...rest,
|
|
19
|
-
ref: reference,
|
|
28
|
+
ref: reference ?? internalRef,
|
|
20
29
|
type: "checkbox",
|
|
21
30
|
disabled: disabled,
|
|
22
31
|
checked: checked,
|
|
23
32
|
onChange: onChange
|
|
24
|
-
}), /*#__PURE__*/
|
|
33
|
+
}), /*#__PURE__*/jsxs("span", {
|
|
25
34
|
className: "tw-checkbox-button",
|
|
26
|
-
children: /*#__PURE__*/jsx("span", {
|
|
35
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
27
36
|
className: "tw-checkbox-check"
|
|
28
|
-
})
|
|
37
|
+
}), /*#__PURE__*/jsx("span", {
|
|
38
|
+
className: "np-tw-checkbox-indeterminate"
|
|
39
|
+
})]
|
|
29
40
|
})]
|
|
30
41
|
});
|
|
31
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxButton.mjs","sources":["../../src/checkboxButton/CheckboxButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { InputHTMLAttributes, forwardRef } from 'react';\n\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement
|
|
1
|
+
{"version":3,"file":"CheckboxButton.mjs","sources":["../../src/checkboxButton/CheckboxButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { InputHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\n\nimport { useInputAttributes } from '../inputs/contexts';\n\nexport type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {\n indeterminate?: boolean;\n};\n\nconst CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(function CheckboxButton(\n { checked, indeterminate = false, className, disabled, onChange, ...rest },\n reference,\n) {\n const inputAttributes = useInputAttributes();\n\n const internalRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(reference, () => internalRef.current ?? ({} as HTMLInputElement));\n\n useEffect(() => {\n if (internalRef.current) {\n // eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-assignment\n internalRef.current.indeterminate = indeterminate;\n }\n }, [indeterminate, reference]);\n\n return (\n <span className={clsx('np-checkbox-button', className, disabled && 'disabled')}>\n <input\n {...inputAttributes}\n {...rest}\n ref={reference ?? internalRef}\n type=\"checkbox\"\n disabled={disabled}\n checked={checked}\n onChange={onChange}\n />\n <span className=\"tw-checkbox-button\">\n <span className=\"tw-checkbox-check\" />\n <span className=\"np-tw-checkbox-indeterminate\" />\n </span>\n </span>\n );\n});\n\nexport default CheckboxButton;\n"],"names":["CheckboxButton","forwardRef","checked","indeterminate","className","disabled","onChange","rest","reference","inputAttributes","useInputAttributes","internalRef","useRef","useImperativeHandle","current","useEffect","_jsxs","clsx","children","_jsx","ref","type"],"mappings":";;;;;AASA,MAAMA,cAAc,gBAAGC,UAAU,CAAwC,SAASD,cAAcA,CAC9F;EAAEE,OAAO;AAAEC,EAAAA,aAAa,GAAG,KAAK;EAAEC,SAAS;EAAEC,QAAQ;EAAEC,Q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Chips.js
CHANGED
|
@@ -29,6 +29,8 @@ const Chips = ({
|
|
|
29
29
|
children: chips.map(chip => {
|
|
30
30
|
const chipSelected = isSelected(chip.value);
|
|
31
31
|
return /*#__PURE__*/jsxRuntime.jsx(Chip, {
|
|
32
|
+
role: !multiple ? 'radio' : 'checkbox',
|
|
33
|
+
"aria-checked": chipSelected,
|
|
32
34
|
value: chip.value,
|
|
33
35
|
label: chip.label,
|
|
34
36
|
closeButton: {
|
|
@@ -41,13 +43,10 @@ const Chips = ({
|
|
|
41
43
|
'p-r-1': multiple && chipSelected
|
|
42
44
|
}),
|
|
43
45
|
...(multiple && chipSelected ? {
|
|
44
|
-
onRemove: () => handleOnChange(chip.value, chipSelected)
|
|
45
|
-
'aria-label': chip.label
|
|
46
|
+
onRemove: () => handleOnChange(chip.value, chipSelected)
|
|
46
47
|
} : {
|
|
47
48
|
onClick: () => handleOnChange(chip.value, chipSelected),
|
|
48
|
-
onKeyPress: () => handleOnChange(chip.value, chipSelected)
|
|
49
|
-
role: !multiple ? 'radio' : undefined,
|
|
50
|
-
'aria-checked': chipSelected
|
|
49
|
+
onKeyPress: () => handleOnChange(chip.value, chipSelected)
|
|
51
50
|
})
|
|
52
51
|
}, chip.value);
|
|
53
52
|
})
|
package/build/chips/Chips.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chips.js","sources":["../../src/chips/Chips.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { CommonProps, AriaLabelProperty } from '../common';\n\nimport Chip from './Chip';\nimport messages from './Chips.messages';\n\nexport type ChipValue = string | number;\n\nexport type Chip = {\n value: ChipValue;\n label: string;\n};\n\nexport type ChipsProps = CommonProps &\n AriaLabelProperty & {\n /** List of chips with string labels and string/number values */\n chips: readonly Chip[];\n /** Callback which is invoked when a chip is selected or deselected */\n onChange: ({\n isEnabled,\n selectedValue,\n }: {\n isEnabled: boolean;\n selectedValue: ChipValue;\n }) => void;\n /** Used to manage which chips are selected */\n selected: ChipValue | readonly ChipValue[];\n /** Used to activate multi-selection */\n multiple?: boolean;\n };\n\nconst Chips = ({\n chips,\n onChange,\n selected,\n 'aria-label': ariaLabel,\n className,\n multiple,\n}: ChipsProps) => {\n const intl = useIntl();\n\n const isSelected = (value: ChipValue) =>\n Array.isArray(selected) ? selected.includes(value) : selected === value;\n\n const handleOnChange = (selectedValue: ChipValue, isCurrentlyEnabled: boolean) => {\n onChange({ isEnabled: !isCurrentlyEnabled, selectedValue });\n };\n\n return (\n <div\n className={clsx('np-chips d-flex', className)}\n aria-label={ariaLabel}\n role={!multiple ? 'radiogroup' : undefined}\n >\n {chips.map((chip) => {\n const chipSelected = isSelected(chip.value);\n return (\n <Chip\n key={chip.value}\n value={chip.value}\n label={chip.label}\n closeButton={{\n 'aria-label': intl.formatMessage(messages.ariaLabel, { choice: chip.label }),\n }}\n className={clsx('text-xs-nowrap', {\n 'np-chip--selected': chipSelected,\n 'p-r-1': multiple && chipSelected,\n })}\n {...(multiple && chipSelected\n ? {\n onRemove: () => handleOnChange(chip.value, chipSelected),\n
|
|
1
|
+
{"version":3,"file":"Chips.js","sources":["../../src/chips/Chips.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { CommonProps, AriaLabelProperty } from '../common';\n\nimport Chip from './Chip';\nimport messages from './Chips.messages';\n\nexport type ChipValue = string | number;\n\nexport type Chip = {\n value: ChipValue;\n label: string;\n};\n\nexport type ChipsProps = CommonProps &\n AriaLabelProperty & {\n /** List of chips with string labels and string/number values */\n chips: readonly Chip[];\n /** Callback which is invoked when a chip is selected or deselected */\n onChange: ({\n isEnabled,\n selectedValue,\n }: {\n isEnabled: boolean;\n selectedValue: ChipValue;\n }) => void;\n /** Used to manage which chips are selected */\n selected: ChipValue | readonly ChipValue[];\n /** Used to activate multi-selection */\n multiple?: boolean;\n };\n\nconst Chips = ({\n chips,\n onChange,\n selected,\n 'aria-label': ariaLabel,\n className,\n multiple,\n}: ChipsProps) => {\n const intl = useIntl();\n\n const isSelected = (value: ChipValue) =>\n Array.isArray(selected) ? selected.includes(value) : selected === value;\n\n const handleOnChange = (selectedValue: ChipValue, isCurrentlyEnabled: boolean) => {\n onChange({ isEnabled: !isCurrentlyEnabled, selectedValue });\n };\n\n return (\n <div\n className={clsx('np-chips d-flex', className)}\n aria-label={ariaLabel}\n role={!multiple ? 'radiogroup' : undefined}\n >\n {chips.map((chip) => {\n const chipSelected = isSelected(chip.value);\n return (\n <Chip\n key={chip.value}\n role={!multiple ? 'radio' : 'checkbox'}\n aria-checked={chipSelected}\n value={chip.value}\n label={chip.label}\n closeButton={{\n 'aria-label': intl.formatMessage(messages.ariaLabel, { choice: chip.label }),\n }}\n className={clsx('text-xs-nowrap', {\n 'np-chip--selected': chipSelected,\n 'p-r-1': multiple && chipSelected,\n })}\n {...(multiple && chipSelected\n ? {\n onRemove: () => handleOnChange(chip.value, chipSelected),\n }\n : {\n onClick: () => handleOnChange(chip.value, chipSelected),\n onKeyPress: () => handleOnChange(chip.value, chipSelected),\n })}\n />\n );\n })}\n </div>\n );\n};\n\nexport default Chips;\n"],"names":["Chips","chips","onChange","selected","ariaLabel","className","multiple","intl","useIntl","isSelected","value","Array","isArray","includes","handleOnChange","selectedValue","isCurrentlyEnabled","isEnabled","_jsx","clsx","role","undefined","children","map","chip","chipSelected","Chip","label","closeButton","formatMessage","messages","choice","onRemove","onClick","onKeyPress"],"mappings":";;;;;;;;AAiCMA,MAAAA,KAAK,GAAGA,CAAC;EACbC,KAAK;EACLC,QAAQ;EACRC,QAAQ;AACR,EAAA,YAAY,EAAEC,SAAS;EACvBC,SAAS;AACTC,EAAAA,QAAAA;AAAQ,CACG,KAAI;AACf,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;EAEtB,MAAMC,UAAU,GAAIC,KAAgB,IAClCC,KAAK,CAACC,OAAO,CAACT,QAAQ,CAAC,GAAGA,QAAQ,CAACU,QAAQ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AA;AACxD,SAAA,GACD;UACEQ,OAAO,EAAEA,MAAMnB,cAAc,CAACU,IAAI,CAACd,KAAK,EAAEe,YAAY,CAAC;UACvDS,UAAU,EAAEA,MAAMpB,cAAc,CAACU,IAAI,CAACd,KAAK,EAAEe,YAAY,CAAA;SAC1D,CAAA;OAnBAD,EAAAA,IAAI,CAACd,KAoBV,CAAA,CAAA;KAEL,CAAA;AAAC,GACC,CAAC,CAAA;AAEV;;;;"}
|
package/build/chips/Chips.mjs
CHANGED
|
@@ -27,6 +27,8 @@ const Chips = ({
|
|
|
27
27
|
children: chips.map(chip => {
|
|
28
28
|
const chipSelected = isSelected(chip.value);
|
|
29
29
|
return /*#__PURE__*/jsx(Chip, {
|
|
30
|
+
role: !multiple ? 'radio' : 'checkbox',
|
|
31
|
+
"aria-checked": chipSelected,
|
|
30
32
|
value: chip.value,
|
|
31
33
|
label: chip.label,
|
|
32
34
|
closeButton: {
|
|
@@ -39,13 +41,10 @@ const Chips = ({
|
|
|
39
41
|
'p-r-1': multiple && chipSelected
|
|
40
42
|
}),
|
|
41
43
|
...(multiple && chipSelected ? {
|
|
42
|
-
onRemove: () => handleOnChange(chip.value, chipSelected)
|
|
43
|
-
'aria-label': chip.label
|
|
44
|
+
onRemove: () => handleOnChange(chip.value, chipSelected)
|
|
44
45
|
} : {
|
|
45
46
|
onClick: () => handleOnChange(chip.value, chipSelected),
|
|
46
|
-
onKeyPress: () => handleOnChange(chip.value, chipSelected)
|
|
47
|
-
role: !multiple ? 'radio' : undefined,
|
|
48
|
-
'aria-checked': chipSelected
|
|
47
|
+
onKeyPress: () => handleOnChange(chip.value, chipSelected)
|
|
49
48
|
})
|
|
50
49
|
}, chip.value);
|
|
51
50
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chips.mjs","sources":["../../src/chips/Chips.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { CommonProps, AriaLabelProperty } from '../common';\n\nimport Chip from './Chip';\nimport messages from './Chips.messages';\n\nexport type ChipValue = string | number;\n\nexport type Chip = {\n value: ChipValue;\n label: string;\n};\n\nexport type ChipsProps = CommonProps &\n AriaLabelProperty & {\n /** List of chips with string labels and string/number values */\n chips: readonly Chip[];\n /** Callback which is invoked when a chip is selected or deselected */\n onChange: ({\n isEnabled,\n selectedValue,\n }: {\n isEnabled: boolean;\n selectedValue: ChipValue;\n }) => void;\n /** Used to manage which chips are selected */\n selected: ChipValue | readonly ChipValue[];\n /** Used to activate multi-selection */\n multiple?: boolean;\n };\n\nconst Chips = ({\n chips,\n onChange,\n selected,\n 'aria-label': ariaLabel,\n className,\n multiple,\n}: ChipsProps) => {\n const intl = useIntl();\n\n const isSelected = (value: ChipValue) =>\n Array.isArray(selected) ? selected.includes(value) : selected === value;\n\n const handleOnChange = (selectedValue: ChipValue, isCurrentlyEnabled: boolean) => {\n onChange({ isEnabled: !isCurrentlyEnabled, selectedValue });\n };\n\n return (\n <div\n className={clsx('np-chips d-flex', className)}\n aria-label={ariaLabel}\n role={!multiple ? 'radiogroup' : undefined}\n >\n {chips.map((chip) => {\n const chipSelected = isSelected(chip.value);\n return (\n <Chip\n key={chip.value}\n value={chip.value}\n label={chip.label}\n closeButton={{\n 'aria-label': intl.formatMessage(messages.ariaLabel, { choice: chip.label }),\n }}\n className={clsx('text-xs-nowrap', {\n 'np-chip--selected': chipSelected,\n 'p-r-1': multiple && chipSelected,\n })}\n {...(multiple && chipSelected\n ? {\n onRemove: () => handleOnChange(chip.value, chipSelected),\n
|
|
1
|
+
{"version":3,"file":"Chips.mjs","sources":["../../src/chips/Chips.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport { CommonProps, AriaLabelProperty } from '../common';\n\nimport Chip from './Chip';\nimport messages from './Chips.messages';\n\nexport type ChipValue = string | number;\n\nexport type Chip = {\n value: ChipValue;\n label: string;\n};\n\nexport type ChipsProps = CommonProps &\n AriaLabelProperty & {\n /** List of chips with string labels and string/number values */\n chips: readonly Chip[];\n /** Callback which is invoked when a chip is selected or deselected */\n onChange: ({\n isEnabled,\n selectedValue,\n }: {\n isEnabled: boolean;\n selectedValue: ChipValue;\n }) => void;\n /** Used to manage which chips are selected */\n selected: ChipValue | readonly ChipValue[];\n /** Used to activate multi-selection */\n multiple?: boolean;\n };\n\nconst Chips = ({\n chips,\n onChange,\n selected,\n 'aria-label': ariaLabel,\n className,\n multiple,\n}: ChipsProps) => {\n const intl = useIntl();\n\n const isSelected = (value: ChipValue) =>\n Array.isArray(selected) ? selected.includes(value) : selected === value;\n\n const handleOnChange = (selectedValue: ChipValue, isCurrentlyEnabled: boolean) => {\n onChange({ isEnabled: !isCurrentlyEnabled, selectedValue });\n };\n\n return (\n <div\n className={clsx('np-chips d-flex', className)}\n aria-label={ariaLabel}\n role={!multiple ? 'radiogroup' : undefined}\n >\n {chips.map((chip) => {\n const chipSelected = isSelected(chip.value);\n return (\n <Chip\n key={chip.value}\n role={!multiple ? 'radio' : 'checkbox'}\n aria-checked={chipSelected}\n value={chip.value}\n label={chip.label}\n closeButton={{\n 'aria-label': intl.formatMessage(messages.ariaLabel, { choice: chip.label }),\n }}\n className={clsx('text-xs-nowrap', {\n 'np-chip--selected': chipSelected,\n 'p-r-1': multiple && chipSelected,\n })}\n {...(multiple && chipSelected\n ? {\n onRemove: () => handleOnChange(chip.value, chipSelected),\n }\n : {\n onClick: () => handleOnChange(chip.value, chipSelected),\n onKeyPress: () => handleOnChange(chip.value, chipSelected),\n })}\n />\n );\n })}\n </div>\n );\n};\n\nexport default Chips;\n"],"names":["Chips","chips","onChange","selected","ariaLabel","className","multiple","intl","useIntl","isSelected","value","Array","isArray","includes","handleOnChange","selectedValue","isCurrentlyEnabled","isEnabled","_jsx","clsx","role","undefined","children","map","chip","chipSelected","Chip","label","closeButton","formatMessage","messages","choice","onRemove","onClick","onKeyPress"],"mappings":";;;;;;AAiCMA,MAAAA,KAAK,GAAGA,CAAC;EACbC,KAAK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E;AACFtB,QAAAA,SAAS,EAAEc,IAAI,CAAC,gBAAgB,EAAE;AAChC,UAAA,mBAAmB,EAAEM,YAAY;UACjC,OAAO,EAAEnB,QAAQ,IAAImB,YAAAA;AACtB,SAAA,CAAE;QAAA,IACEnB,QAAQ,IAAImB,YAAY,GACzB;UACEO,QAAQ,EAAEA,MAAMlB,cAAc,CAACU,IAAI,CAACd,KAAK,EAAEe,YAAY,CAAA;AACxD,SAAA,GACD;UACEQ,OAAO,EAAEA,MAAMnB,cAAc,CAACU,IAAI,CAACd,KAAK,EAAEe,YAAY,CAAC;UACvDS,UAAU,EAAEA,MAAMpB,cAAc,CAACU,IAAI,CAACd,KAAK,EAAEe,YAAY,CAAA;SAC1D,CAAA;OAnBAD,EAAAA,IAAI,CAACd,KAoBV,CAAA,CAAA;KAEL,CAAA;AAAC,GACC,CAAC,CAAA;AAEV;;;;"}
|
package/build/main.css
CHANGED
|
@@ -796,7 +796,8 @@ div.critical-comms .critical-comms-body {
|
|
|
796
796
|
.np-checkbox-button input[type="checkbox"]:not(:disabled) {
|
|
797
797
|
cursor: pointer;
|
|
798
798
|
}
|
|
799
|
-
.np-checkbox-button .tw-checkbox-check
|
|
799
|
+
.np-checkbox-button .tw-checkbox-check,
|
|
800
|
+
.np-checkbox-button .np-tw-checkbox-indeterminate {
|
|
800
801
|
pointer-events: none;
|
|
801
802
|
}
|
|
802
803
|
.checkbox .np-checkbox-button input[type="checkbox"] {
|
|
@@ -809,6 +810,24 @@ div.critical-comms .critical-comms-body {
|
|
|
809
810
|
left: auto;
|
|
810
811
|
left: initial;
|
|
811
812
|
}
|
|
813
|
+
.np-tw-checkbox-indeterminate {
|
|
814
|
+
position: relative;
|
|
815
|
+
}
|
|
816
|
+
.np-tw-checkbox-indeterminate::after {
|
|
817
|
+
content: "";
|
|
818
|
+
position: absolute;
|
|
819
|
+
width: 12px;
|
|
820
|
+
height: 2px;
|
|
821
|
+
top: 55%;
|
|
822
|
+
left: 50%;
|
|
823
|
+
background: #ffffff;
|
|
824
|
+
background: var(--color-background-screen);
|
|
825
|
+
transform: translate(-50%, -50%);
|
|
826
|
+
}
|
|
827
|
+
.np-tw-checkbox-indeterminate .has-error::after {
|
|
828
|
+
background-color: #e74848;
|
|
829
|
+
background-color: var(--color-interactive-negative);
|
|
830
|
+
}
|
|
812
831
|
.np-chip {
|
|
813
832
|
background-color: transparent;
|
|
814
833
|
border: 1px solid rgba(0,0,0,0.10196);
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
.np-checkbox-button input[type="checkbox"]:not(:disabled) {
|
|
10
10
|
cursor: pointer;
|
|
11
11
|
}
|
|
12
|
-
.np-checkbox-button .tw-checkbox-check
|
|
12
|
+
.np-checkbox-button .tw-checkbox-check,
|
|
13
|
+
.np-checkbox-button .np-tw-checkbox-indeterminate {
|
|
13
14
|
pointer-events: none;
|
|
14
15
|
}
|
|
15
16
|
.checkbox .np-checkbox-button input[type="checkbox"] {
|
|
@@ -22,3 +23,21 @@
|
|
|
22
23
|
left: auto;
|
|
23
24
|
left: initial;
|
|
24
25
|
}
|
|
26
|
+
.np-tw-checkbox-indeterminate {
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
.np-tw-checkbox-indeterminate::after {
|
|
30
|
+
content: "";
|
|
31
|
+
position: absolute;
|
|
32
|
+
width: 12px;
|
|
33
|
+
height: 2px;
|
|
34
|
+
top: 55%;
|
|
35
|
+
left: 50%;
|
|
36
|
+
background: #ffffff;
|
|
37
|
+
background: var(--color-background-screen);
|
|
38
|
+
transform: translate(-50%, -50%);
|
|
39
|
+
}
|
|
40
|
+
.np-tw-checkbox-indeterminate .has-error::after {
|
|
41
|
+
background-color: #e74848;
|
|
42
|
+
background-color: var(--color-interactive-negative);
|
|
43
|
+
}
|
package/build/styles/main.css
CHANGED
|
@@ -796,7 +796,8 @@ div.critical-comms .critical-comms-body {
|
|
|
796
796
|
.np-checkbox-button input[type="checkbox"]:not(:disabled) {
|
|
797
797
|
cursor: pointer;
|
|
798
798
|
}
|
|
799
|
-
.np-checkbox-button .tw-checkbox-check
|
|
799
|
+
.np-checkbox-button .tw-checkbox-check,
|
|
800
|
+
.np-checkbox-button .np-tw-checkbox-indeterminate {
|
|
800
801
|
pointer-events: none;
|
|
801
802
|
}
|
|
802
803
|
.checkbox .np-checkbox-button input[type="checkbox"] {
|
|
@@ -809,6 +810,24 @@ div.critical-comms .critical-comms-body {
|
|
|
809
810
|
left: auto;
|
|
810
811
|
left: initial;
|
|
811
812
|
}
|
|
813
|
+
.np-tw-checkbox-indeterminate {
|
|
814
|
+
position: relative;
|
|
815
|
+
}
|
|
816
|
+
.np-tw-checkbox-indeterminate::after {
|
|
817
|
+
content: "";
|
|
818
|
+
position: absolute;
|
|
819
|
+
width: 12px;
|
|
820
|
+
height: 2px;
|
|
821
|
+
top: 55%;
|
|
822
|
+
left: 50%;
|
|
823
|
+
background: #ffffff;
|
|
824
|
+
background: var(--color-background-screen);
|
|
825
|
+
transform: translate(-50%, -50%);
|
|
826
|
+
}
|
|
827
|
+
.np-tw-checkbox-indeterminate .has-error::after {
|
|
828
|
+
background-color: #e74848;
|
|
829
|
+
background-color: var(--color-interactive-negative);
|
|
830
|
+
}
|
|
812
831
|
.np-chip {
|
|
813
832
|
background-color: transparent;
|
|
814
833
|
border: 1px solid rgba(0,0,0,0.10196);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { InputHTMLAttributes } from 'react';
|
|
2
|
-
export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement
|
|
3
|
-
|
|
2
|
+
export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
3
|
+
indeterminate?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const CheckboxButton: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
|
|
6
|
+
indeterminate?: boolean;
|
|
7
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
8
|
export default CheckboxButton;
|
|
5
9
|
//# sourceMappingURL=CheckboxButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxButton.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/CheckboxButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"CheckboxButton.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/CheckboxButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAsD,MAAM,OAAO,CAAC;AAIhG,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,QAAA,MAAM,cAAc;oBAHF,OAAO;oDAqCvB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chips.d.ts","sourceRoot":"","sources":["../../../src/chips/Chips.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK3D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAClC,iBAAiB,GAAG;IAClB,gEAAgE;IAChE,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,sEAAsE;IACtE,QAAQ,EAAE,CAAC,EACT,SAAS,EACT,aAAa,GACd,EAAE;QACD,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,SAAS,CAAC;KAC1B,KAAK,IAAI,CAAC;IACX,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE,CAAC;IAC3C,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEJ,QAAA,MAAM,KAAK,iFAOR,UAAU,
|
|
1
|
+
{"version":3,"file":"Chips.d.ts","sourceRoot":"","sources":["../../../src/chips/Chips.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK3D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,WAAW,GAClC,iBAAiB,GAAG;IAClB,gEAAgE;IAChE,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,sEAAsE;IACtE,QAAQ,EAAE,CAAC,EACT,SAAS,EACT,aAAa,GACd,EAAE;QACD,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,SAAS,CAAC;KAC1B,KAAK,IAAI,CAAC;IACX,8CAA8C;IAC9C,QAAQ,EAAE,SAAS,GAAG,SAAS,SAAS,EAAE,CAAC;IAC3C,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEJ,QAAA,MAAM,KAAK,iFAOR,UAAU,gCA6CZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.61.1",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"rollup": "^4.18.1",
|
|
93
93
|
"rollup-preserve-directives": "^1.1.1",
|
|
94
94
|
"storybook": "^8.2.2",
|
|
95
|
-
"@transferwise/
|
|
96
|
-
"@
|
|
97
|
-
"@
|
|
95
|
+
"@transferwise/neptune-css": "14.14.0",
|
|
96
|
+
"@wise/components-theming": "1.6.0",
|
|
97
|
+
"@transferwise/less-config": "3.1.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"@transferwise/icons": "^3.7.0",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
.np-checkbox-button input[type="checkbox"]:not(:disabled) {
|
|
10
10
|
cursor: pointer;
|
|
11
11
|
}
|
|
12
|
-
.np-checkbox-button .tw-checkbox-check
|
|
12
|
+
.np-checkbox-button .tw-checkbox-check,
|
|
13
|
+
.np-checkbox-button .np-tw-checkbox-indeterminate {
|
|
13
14
|
pointer-events: none;
|
|
14
15
|
}
|
|
15
16
|
.checkbox .np-checkbox-button input[type="checkbox"] {
|
|
@@ -22,3 +23,21 @@
|
|
|
22
23
|
left: auto;
|
|
23
24
|
left: initial;
|
|
24
25
|
}
|
|
26
|
+
.np-tw-checkbox-indeterminate {
|
|
27
|
+
position: relative;
|
|
28
|
+
}
|
|
29
|
+
.np-tw-checkbox-indeterminate::after {
|
|
30
|
+
content: "";
|
|
31
|
+
position: absolute;
|
|
32
|
+
width: 12px;
|
|
33
|
+
height: 2px;
|
|
34
|
+
top: 55%;
|
|
35
|
+
left: 50%;
|
|
36
|
+
background: #ffffff;
|
|
37
|
+
background: var(--color-background-screen);
|
|
38
|
+
transform: translate(-50%, -50%);
|
|
39
|
+
}
|
|
40
|
+
.np-tw-checkbox-indeterminate .has-error::after {
|
|
41
|
+
background-color: #e74848;
|
|
42
|
+
background-color: var(--color-interactive-negative);
|
|
43
|
+
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.tw-checkbox-check {
|
|
17
|
+
.tw-checkbox-check, .np-tw-checkbox-indeterminate {
|
|
18
18
|
pointer-events: none;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -27,3 +27,24 @@
|
|
|
27
27
|
margin: 0;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
.np-tw-checkbox-indeterminate {
|
|
32
|
+
position: relative;
|
|
33
|
+
|
|
34
|
+
&::after {
|
|
35
|
+
content: "";
|
|
36
|
+
position: absolute;
|
|
37
|
+
width: 12px;
|
|
38
|
+
height: 2px;
|
|
39
|
+
top: 55%;
|
|
40
|
+
left: 50%;
|
|
41
|
+
background: var(--color-background-screen);
|
|
42
|
+
transform: translate(-50%, -50%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.has-error {
|
|
46
|
+
&::after {
|
|
47
|
+
background-color: var(--color-interactive-negative);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -2,7 +2,7 @@ import { action } from '@storybook/addon-actions';
|
|
|
2
2
|
import { Meta, StoryObj } from '@storybook/react';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
|
|
5
|
-
import CheckboxButton from './CheckboxButton';
|
|
5
|
+
import CheckboxButton, { CheckboxButtonProps } from './CheckboxButton';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
8
8
|
component: CheckboxButton,
|
|
@@ -29,3 +29,26 @@ export const Basic: Story = {
|
|
|
29
29
|
return <CheckboxButton {...args} checked={checked} onChange={() => setChecked(!checked)} />;
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
+
|
|
33
|
+
const Template = (props: CheckboxButtonProps) => {
|
|
34
|
+
const checked = true;
|
|
35
|
+
const [indeterminate, setIndeterminate] = useState(true);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<CheckboxButton
|
|
39
|
+
{...props}
|
|
40
|
+
checked={checked}
|
|
41
|
+
indeterminate={indeterminate}
|
|
42
|
+
onChange={() => setIndeterminate(!indeterminate)}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Indeterminate = () => {
|
|
48
|
+
const args = {
|
|
49
|
+
'aria-label': 'Group checkbox with indeterminate state',
|
|
50
|
+
disabled: false,
|
|
51
|
+
indeterminate: true,
|
|
52
|
+
};
|
|
53
|
+
return <Template {...args} />;
|
|
54
|
+
};
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import { InputHTMLAttributes, forwardRef } from 'react';
|
|
2
|
+
import { InputHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
3
|
|
|
4
4
|
import { useInputAttributes } from '../inputs/contexts';
|
|
5
5
|
|
|
6
|
-
export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement
|
|
6
|
+
export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
7
|
+
indeterminate?: boolean;
|
|
8
|
+
};
|
|
7
9
|
|
|
8
10
|
const CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(function CheckboxButton(
|
|
9
|
-
{ checked, className, disabled, onChange, ...rest },
|
|
11
|
+
{ checked, indeterminate = false, className, disabled, onChange, ...rest },
|
|
10
12
|
reference,
|
|
11
13
|
) {
|
|
12
14
|
const inputAttributes = useInputAttributes();
|
|
13
15
|
|
|
16
|
+
const internalRef = useRef<HTMLInputElement>(null);
|
|
17
|
+
|
|
18
|
+
useImperativeHandle(reference, () => internalRef.current ?? ({} as HTMLInputElement));
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (internalRef.current) {
|
|
22
|
+
// eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-assignment
|
|
23
|
+
internalRef.current.indeterminate = indeterminate;
|
|
24
|
+
}
|
|
25
|
+
}, [indeterminate, reference]);
|
|
26
|
+
|
|
14
27
|
return (
|
|
15
28
|
<span className={clsx('np-checkbox-button', className, disabled && 'disabled')}>
|
|
16
29
|
<input
|
|
17
30
|
{...inputAttributes}
|
|
18
31
|
{...rest}
|
|
19
|
-
ref={reference}
|
|
32
|
+
ref={reference ?? internalRef}
|
|
20
33
|
type="checkbox"
|
|
21
34
|
disabled={disabled}
|
|
22
35
|
checked={checked}
|
|
@@ -24,6 +37,7 @@ const CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(functio
|
|
|
24
37
|
/>
|
|
25
38
|
<span className="tw-checkbox-button">
|
|
26
39
|
<span className="tw-checkbox-check" />
|
|
40
|
+
<span className="np-tw-checkbox-indeterminate" />
|
|
27
41
|
</span>
|
|
28
42
|
</span>
|
|
29
43
|
);
|
package/src/chips/Chips.spec.tsx
CHANGED
|
@@ -85,7 +85,7 @@ describe('Chips', () => {
|
|
|
85
85
|
|
|
86
86
|
it(`will pass previous state, updated state, and cleared value on clear`, () => {
|
|
87
87
|
render(<Chips {...filterProps} />);
|
|
88
|
-
fireEvent.click(screen.
|
|
88
|
+
fireEvent.click(screen.getByRole('button', { name: 'Clear Payments' }));
|
|
89
89
|
expect(filterProps.onChange).toHaveBeenCalledWith({
|
|
90
90
|
selectedValue: 'payments',
|
|
91
91
|
isEnabled: false,
|
package/src/chips/Chips.tsx
CHANGED
|
@@ -59,6 +59,8 @@ const Chips = ({
|
|
|
59
59
|
return (
|
|
60
60
|
<Chip
|
|
61
61
|
key={chip.value}
|
|
62
|
+
role={!multiple ? 'radio' : 'checkbox'}
|
|
63
|
+
aria-checked={chipSelected}
|
|
62
64
|
value={chip.value}
|
|
63
65
|
label={chip.label}
|
|
64
66
|
closeButton={{
|
|
@@ -71,13 +73,10 @@ const Chips = ({
|
|
|
71
73
|
{...(multiple && chipSelected
|
|
72
74
|
? {
|
|
73
75
|
onRemove: () => handleOnChange(chip.value, chipSelected),
|
|
74
|
-
'aria-label': chip.label,
|
|
75
76
|
}
|
|
76
77
|
: {
|
|
77
78
|
onClick: () => handleOnChange(chip.value, chipSelected),
|
|
78
79
|
onKeyPress: () => handleOnChange(chip.value, chipSelected),
|
|
79
|
-
role: !multiple ? 'radio' : undefined,
|
|
80
|
-
'aria-checked': chipSelected,
|
|
81
80
|
})}
|
|
82
81
|
/>
|
|
83
82
|
);
|
|
@@ -72,7 +72,7 @@ exports[`Chips Filter Chips renders as expected 1`] = `
|
|
|
72
72
|
<div
|
|
73
73
|
aria-checked="false"
|
|
74
74
|
class="np-chip d-flex align-items-center justify-content-between text-xs-nowrap"
|
|
75
|
-
role="
|
|
75
|
+
role="checkbox"
|
|
76
76
|
tabindex="0"
|
|
77
77
|
>
|
|
78
78
|
<span
|
|
@@ -85,7 +85,7 @@ exports[`Chips Filter Chips renders as expected 1`] = `
|
|
|
85
85
|
<div
|
|
86
86
|
aria-checked="false"
|
|
87
87
|
class="np-chip d-flex align-items-center justify-content-between text-xs-nowrap"
|
|
88
|
-
role="
|
|
88
|
+
role="checkbox"
|
|
89
89
|
tabindex="0"
|
|
90
90
|
>
|
|
91
91
|
<span
|
|
@@ -98,7 +98,7 @@ exports[`Chips Filter Chips renders as expected 1`] = `
|
|
|
98
98
|
<div
|
|
99
99
|
aria-checked="false"
|
|
100
100
|
class="np-chip d-flex align-items-center justify-content-between text-xs-nowrap"
|
|
101
|
-
role="
|
|
101
|
+
role="checkbox"
|
|
102
102
|
tabindex="0"
|
|
103
103
|
>
|
|
104
104
|
<span
|
|
@@ -109,8 +109,9 @@ exports[`Chips Filter Chips renders as expected 1`] = `
|
|
|
109
109
|
</span>
|
|
110
110
|
</div>
|
|
111
111
|
<div
|
|
112
|
-
aria-
|
|
112
|
+
aria-checked="true"
|
|
113
113
|
class="np-chip d-flex align-items-center justify-content-between np-chip--removable text-xs-nowrap np-chip--selected p-r-1"
|
|
114
|
+
role="checkbox"
|
|
114
115
|
tabindex="-1"
|
|
115
116
|
>
|
|
116
117
|
<span
|
package/src/main.css
CHANGED
|
@@ -796,7 +796,8 @@ div.critical-comms .critical-comms-body {
|
|
|
796
796
|
.np-checkbox-button input[type="checkbox"]:not(:disabled) {
|
|
797
797
|
cursor: pointer;
|
|
798
798
|
}
|
|
799
|
-
.np-checkbox-button .tw-checkbox-check
|
|
799
|
+
.np-checkbox-button .tw-checkbox-check,
|
|
800
|
+
.np-checkbox-button .np-tw-checkbox-indeterminate {
|
|
800
801
|
pointer-events: none;
|
|
801
802
|
}
|
|
802
803
|
.checkbox .np-checkbox-button input[type="checkbox"] {
|
|
@@ -809,6 +810,24 @@ div.critical-comms .critical-comms-body {
|
|
|
809
810
|
left: auto;
|
|
810
811
|
left: initial;
|
|
811
812
|
}
|
|
813
|
+
.np-tw-checkbox-indeterminate {
|
|
814
|
+
position: relative;
|
|
815
|
+
}
|
|
816
|
+
.np-tw-checkbox-indeterminate::after {
|
|
817
|
+
content: "";
|
|
818
|
+
position: absolute;
|
|
819
|
+
width: 12px;
|
|
820
|
+
height: 2px;
|
|
821
|
+
top: 55%;
|
|
822
|
+
left: 50%;
|
|
823
|
+
background: #ffffff;
|
|
824
|
+
background: var(--color-background-screen);
|
|
825
|
+
transform: translate(-50%, -50%);
|
|
826
|
+
}
|
|
827
|
+
.np-tw-checkbox-indeterminate .has-error::after {
|
|
828
|
+
background-color: #e74848;
|
|
829
|
+
background-color: var(--color-interactive-negative);
|
|
830
|
+
}
|
|
812
831
|
.np-chip {
|
|
813
832
|
background-color: transparent;
|
|
814
833
|
border: 1px solid rgba(0,0,0,0.10196);
|