@transferwise/components 0.0.0-experimental-4f00ba7 → 0.0.0-experimental-cd38ca2
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/field/Field.js +4 -4
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +4 -4
- package/build/field/Field.mjs.map +1 -1
- package/build/inputs/contexts.js +1 -2
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +1 -2
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/main.css +0 -3
- package/build/segmentedControl/SegmentedControl.js +1 -6
- package/build/segmentedControl/SegmentedControl.js.map +1 -1
- package/build/segmentedControl/SegmentedControl.mjs +1 -6
- package/build/segmentedControl/SegmentedControl.mjs.map +1 -1
- package/build/styles/main.css +0 -3
- package/build/styles/segmentedControl/SegmentedControl.css +0 -3
- package/build/tabs/TabList.js +11 -3
- package/build/tabs/TabList.js.map +1 -1
- package/build/tabs/TabList.mjs +7 -3
- package/build/tabs/TabList.mjs.map +1 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/tabs/TabList.d.ts +8 -3
- package/build/types/tabs/TabList.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/uploadInput/UploadInput.js +6 -0
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +6 -0
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/package.json +3 -3
- package/src/field/Field.tsx +7 -5
- package/src/inputs/contexts.tsx +1 -2
- package/src/main.css +0 -3
- package/src/segmentedControl/SegmentedControl.css +0 -3
- package/src/segmentedControl/SegmentedControl.less +0 -4
- package/src/segmentedControl/SegmentedControl.spec.tsx +0 -10
- package/src/segmentedControl/SegmentedControl.story.tsx +4 -42
- package/src/segmentedControl/SegmentedControl.tsx +1 -5
- package/src/tabs/TabList.js +15 -0
- package/src/tabs/Tabs.story.js +135 -0
- package/src/uploadInput/UploadInput.spec.tsx +14 -1
- package/src/uploadInput/UploadInput.story.tsx +11 -0
- package/src/uploadInput/UploadInput.tsx +8 -1
- package/src/tabs/TabList.tsx +0 -11
- package/src/tabs/Tabs.story.tsx +0 -76
package/build/field/Field.js
CHANGED
|
@@ -4,6 +4,7 @@ var classNames = require('classnames');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var InlineAlert = require('../inlineAlert/InlineAlert.js');
|
|
6
6
|
var contexts = require('../inputs/contexts.js');
|
|
7
|
+
var Label = require('../label/Label.js');
|
|
7
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
9
|
var sentiment = require('../common/propsValues/sentiment.js');
|
|
9
10
|
|
|
@@ -42,12 +43,11 @@ const Field = ({
|
|
|
42
43
|
'has-error': hasError,
|
|
43
44
|
'has-info': sentiment$1 === sentiment.Sentiment.NEUTRAL
|
|
44
45
|
}, className),
|
|
45
|
-
children: [label ? /*#__PURE__*/jsxRuntime.
|
|
46
|
+
children: [label != null ? /*#__PURE__*/jsxRuntime.jsxs(Label.Label, {
|
|
46
47
|
id: labelId,
|
|
47
48
|
htmlFor: inputId,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}) : null, children, message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
49
|
+
children: [label, children]
|
|
50
|
+
}) : children, message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
|
|
51
51
|
type: sentiment$1,
|
|
52
52
|
id: descriptionId,
|
|
53
53
|
children: message
|
package/build/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label/Label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? id ?? fallbackInputId : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label ? (\n <
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label/Label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? id ?? fallbackInputId : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <Label id={labelId} htmlFor={inputId}>\n {label}\n {children}\n </Label>\n ) : (\n children\n )}\n\n {message && (\n <InlineAlert type={sentiment} id={descriptionId}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelIdContextProvider>\n );\n};\n"],"names":["Field","id","label","message","propMessage","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","classNames","POSITIVE","WARNING","Label","htmlFor","InlineAlert","type"],"mappings":";;;;;;;;;;;;;;AA4BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,mBAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC,KAAAA;AAAK,CACG,KAAI;EACf,MAAMN,WAAS,GAAGM,KAAK,CAACC,KAAK,GAAGL,mBAAS,CAACM,QAAQ,GAAGP,QAAQ,CAAA;EAC7D,MAAMH,OAAO,GAAGQ,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,IAAI,IAAIV,WAAW,CAAA;AACxD,EAAA,MAAMW,QAAQ,GAAGV,WAAS,KAAKE,mBAAS,CAACM,QAAQ,CAAA;AAEjD,EAAA,MAAMG,OAAO,GAAGC,WAAK,EAAE,CAAA;AAEvB,EAAA,MAAMC,eAAe,GAAGD,WAAK,EAAE,CAAA;EAC/B,MAAME,OAAO,GAAGlB,EAAE,KAAK,IAAI,GAAGA,EAAE,IAAIiB,eAAe,GAAGE,SAAS,CAAA;AAE/D,EAAA,MAAMC,aAAa,GAAGJ,WAAK,EAAE,CAAA;EAE7B,oBACEK,cAAA,CAACC,oCAA2B,EAAA;AAACC,IAAAA,KAAK,EAAER,OAAQ;IAAAN,QAAA,eAC1CY,cAAA,CAACG,+BAAsB,EAAA;AAACD,MAAAA,KAAK,EAAEL,OAAQ;MAAAT,QAAA,eACrCY,cAAA,CAACI,iCAAwB,EAAA;AAACF,QAAAA,KAAK,EAAErB,OAAO,GAAGkB,aAAa,GAAGD,SAAU;QAAAV,QAAA,eACnEY,cAAA,CAACK,6BAAoB,EAAA;AAACH,UAAAA,KAAK,EAAET,QAAS;AAAAL,UAAAA,QAAA,eACpCkB,eAAA,CAAA,KAAA,EAAA;AACEnB,YAAAA,SAAS,EAAEoB,2BAAU,CACnB,oBAAoB,EACpB;AACE,cAAA,aAAa,EAAExB,WAAS,KAAKE,mBAAS,CAACuB,QAAQ;AAC/C,cAAA,aAAa,EAAEzB,WAAS,KAAKE,mBAAS,CAACwB,OAAO;AAC9C,cAAA,WAAW,EAAEhB,QAAQ;AACrB,cAAA,UAAU,EAAEV,WAAS,KAAKE,mBAAS,CAACC,OAAAA;aACrC,EACDC,SAAS,CACT;AAAAC,YAAAA,QAAA,GAEDR,KAAK,IAAI,IAAI,gBACZ0B,eAAA,CAACI,WAAK,EAAA;AAAC/B,cAAAA,EAAE,EAAEe,OAAQ;AAACiB,cAAAA,OAAO,EAAEd,OAAQ;cAAAT,QAAA,EAAA,CAClCR,KAAK,EACLQ,QAAQ,CAAA;aACJ,CAAC,GAERA,QACD,EAEAP,OAAO,iBACNmB,cAAA,CAACY,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAE9B,WAAU;AAACJ,cAAAA,EAAE,EAAEoB,aAAc;AAAAX,cAAAA,QAAA,EAC7CP,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
|
package/build/field/Field.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { useId } from 'react';
|
|
3
3
|
import InlineAlert from '../inlineAlert/InlineAlert.mjs';
|
|
4
4
|
import { FieldLabelIdContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider } from '../inputs/contexts.mjs';
|
|
5
|
+
import { Label } from '../label/Label.mjs';
|
|
5
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
7
|
import { Sentiment } from '../common/propsValues/sentiment.mjs';
|
|
7
8
|
|
|
@@ -36,12 +37,11 @@ const Field = ({
|
|
|
36
37
|
'has-error': hasError,
|
|
37
38
|
'has-info': sentiment === Sentiment.NEUTRAL
|
|
38
39
|
}, className),
|
|
39
|
-
children: [label ? /*#__PURE__*/
|
|
40
|
+
children: [label != null ? /*#__PURE__*/jsxs(Label, {
|
|
40
41
|
id: labelId,
|
|
41
42
|
htmlFor: inputId,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}) : null, children, message && /*#__PURE__*/jsx(InlineAlert, {
|
|
43
|
+
children: [label, children]
|
|
44
|
+
}) : children, message && /*#__PURE__*/jsx(InlineAlert, {
|
|
45
45
|
type: sentiment,
|
|
46
46
|
id: descriptionId,
|
|
47
47
|
children: message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label/Label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? id ?? fallbackInputId : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label ? (\n <
|
|
1
|
+
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useId } from 'react';\n\nimport { Sentiment } from '../common';\nimport InlineAlert from '../inlineAlert/InlineAlert';\nimport {\n FieldLabelIdContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label/Label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /** @deprecated use `message` and `type={Sentiment.NEGATIVE}` prop instead */\n error?: React.ReactNode;\n sentiment?: `${Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.POSITIVE | Sentiment.WARNING}`;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n message: propMessage,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = props.error || props.hint || propMessage;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? id ?? fallbackInputId : undefined;\n\n const descriptionId = useId();\n\n return (\n <FieldLabelIdContextProvider value={labelId}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={message ? descriptionId : undefined}>\n <InputInvalidProvider value={hasError}>\n <div\n className={classNames(\n 'form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <Label id={labelId} htmlFor={inputId}>\n {label}\n {children}\n </Label>\n ) : (\n children\n )}\n\n {message && (\n <InlineAlert type={sentiment} id={descriptionId}>\n {message}\n </InlineAlert>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelIdContextProvider>\n );\n};\n"],"names":["Field","id","label","message","propMessage","sentiment","propType","Sentiment","NEUTRAL","className","children","props","error","NEGATIVE","hint","hasError","labelId","useId","fallbackInputId","inputId","undefined","descriptionId","_jsx","FieldLabelIdContextProvider","value","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","classNames","POSITIVE","WARNING","Label","htmlFor","InlineAlert","type"],"mappings":";;;;;;;;AA4BO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,OAAO,EAAEC,WAAW;AACpBC,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC,KAAAA;AAAK,CACG,KAAI;EACf,MAAMN,SAAS,GAAGM,KAAK,CAACC,KAAK,GAAGL,SAAS,CAACM,QAAQ,GAAGP,QAAQ,CAAA;EAC7D,MAAMH,OAAO,GAAGQ,KAAK,CAACC,KAAK,IAAID,KAAK,CAACG,IAAI,IAAIV,WAAW,CAAA;AAC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P,OAAO,iBACNmB,GAAA,CAACY,WAAW,EAAA;AAACC,cAAAA,IAAI,EAAE9B,SAAU;AAACJ,cAAAA,EAAE,EAAEoB,aAAc;AAAAX,cAAAA,QAAA,EAC7CP,OAAAA;AAAO,aACG,CACd,CAAA;WACE,CAAA;SACe,CAAA;OACE,CAAA;KACJ,CAAA;AAC1B,GAA6B,CAAC,CAAA;AAElC;;;;"}
|
package/build/inputs/contexts.js
CHANGED
|
@@ -14,10 +14,9 @@ const InputInvalidProvider = InputInvalidContext.Provider;
|
|
|
14
14
|
function useInputAttributes({
|
|
15
15
|
nonLabelable
|
|
16
16
|
} = {}) {
|
|
17
|
-
const id = React.useContext(InputIdContext);
|
|
18
17
|
const labelId = React.useContext(FieldLabelIdContext);
|
|
19
18
|
return {
|
|
20
|
-
id:
|
|
19
|
+
id: React.useContext(InputIdContext),
|
|
21
20
|
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
22
21
|
'aria-describedby': React.useContext(InputDescribedByContext),
|
|
23
22
|
'aria-invalid': React.useContext(InputInvalidContext)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.js","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst FieldLabelIdContext = createContext<string | undefined>(undefined);\nexport const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;\n\nconst InputIdContext = createContext<string | undefined>(undefined);\nexport const InputIdContextProvider = InputIdContext.Provider;\n\nconst InputDescribedByContext = createContext<string | undefined>(undefined);\nexport const InputDescribedByProvider = InputDescribedByContext.Provider;\n\nconst InputInvalidContext = createContext<boolean | undefined>(undefined);\nexport const InputInvalidProvider = InputInvalidContext.Provider;\n\ninterface UseInputAttributesArgs {\n /** Set this to `true` if the underlying element is not directly [labelable as per the HTML specification](https://html.spec.whatwg.org/multipage/forms.html#category-label). */\n nonLabelable?: boolean;\n}\n\nexport function useInputAttributes({ nonLabelable }: UseInputAttributesArgs = {}) {\n const
|
|
1
|
+
{"version":3,"file":"contexts.js","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst FieldLabelIdContext = createContext<string | undefined>(undefined);\nexport const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;\n\nconst InputIdContext = createContext<string | undefined>(undefined);\nexport const InputIdContextProvider = InputIdContext.Provider;\n\nconst InputDescribedByContext = createContext<string | undefined>(undefined);\nexport const InputDescribedByProvider = InputDescribedByContext.Provider;\n\nconst InputInvalidContext = createContext<boolean | undefined>(undefined);\nexport const InputInvalidProvider = InputInvalidContext.Provider;\n\ninterface UseInputAttributesArgs {\n /** Set this to `true` if the underlying element is not directly [labelable as per the HTML specification](https://html.spec.whatwg.org/multipage/forms.html#category-label). */\n nonLabelable?: boolean;\n}\n\nexport function useInputAttributes({ nonLabelable }: UseInputAttributesArgs = {}) {\n const labelId = useContext(FieldLabelIdContext);\n return {\n id: useContext(InputIdContext),\n 'aria-labelledby': nonLabelable ? labelId : undefined,\n 'aria-describedby': useContext(InputDescribedByContext),\n 'aria-invalid': useContext(InputInvalidContext),\n } satisfies React.HTMLAttributes<HTMLElement>;\n}\n\nexport interface WithInputAttributesProps {\n inputAttributes: ReturnType<typeof useInputAttributes>;\n}\n\nexport function withInputAttributes<T extends Partial<WithInputAttributesProps>>(\n Component: React.ComponentType<T>,\n args?: UseInputAttributesArgs,\n) {\n function ComponentWithInputAttributes(props: Omit<T, keyof WithInputAttributesProps>) {\n return <Component inputAttributes={useInputAttributes(args)} {...(props as T)} />;\n }\n\n ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;\n\n return ComponentWithInputAttributes;\n}\n"],"names":["FieldLabelIdContext","createContext","undefined","FieldLabelIdContextProvider","Provider","InputIdContext","InputIdContextProvider","InputDescribedByContext","InputDescribedByProvider","InputInvalidContext","InputInvalidProvider","useInputAttributes","nonLabelable","labelId","useContext","id","withInputAttributes","Component","args","ComponentWithInputAttributes","props","_jsx","input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AAc,CAAA,CAAA,CAAA;AAE3H,EAAA,OAAOL,4BAA4B,CAAA;AACrC;;;;;;;;;"}
|
|
@@ -12,10 +12,9 @@ const InputInvalidProvider = InputInvalidContext.Provider;
|
|
|
12
12
|
function useInputAttributes({
|
|
13
13
|
nonLabelable
|
|
14
14
|
} = {}) {
|
|
15
|
-
const id = useContext(InputIdContext);
|
|
16
15
|
const labelId = useContext(FieldLabelIdContext);
|
|
17
16
|
return {
|
|
18
|
-
id:
|
|
17
|
+
id: useContext(InputIdContext),
|
|
19
18
|
'aria-labelledby': nonLabelable ? labelId : undefined,
|
|
20
19
|
'aria-describedby': useContext(InputDescribedByContext),
|
|
21
20
|
'aria-invalid': useContext(InputInvalidContext)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.mjs","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst FieldLabelIdContext = createContext<string | undefined>(undefined);\nexport const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;\n\nconst InputIdContext = createContext<string | undefined>(undefined);\nexport const InputIdContextProvider = InputIdContext.Provider;\n\nconst InputDescribedByContext = createContext<string | undefined>(undefined);\nexport const InputDescribedByProvider = InputDescribedByContext.Provider;\n\nconst InputInvalidContext = createContext<boolean | undefined>(undefined);\nexport const InputInvalidProvider = InputInvalidContext.Provider;\n\ninterface UseInputAttributesArgs {\n /** Set this to `true` if the underlying element is not directly [labelable as per the HTML specification](https://html.spec.whatwg.org/multipage/forms.html#category-label). */\n nonLabelable?: boolean;\n}\n\nexport function useInputAttributes({ nonLabelable }: UseInputAttributesArgs = {}) {\n const
|
|
1
|
+
{"version":3,"file":"contexts.mjs","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\nconst FieldLabelIdContext = createContext<string | undefined>(undefined);\nexport const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;\n\nconst InputIdContext = createContext<string | undefined>(undefined);\nexport const InputIdContextProvider = InputIdContext.Provider;\n\nconst InputDescribedByContext = createContext<string | undefined>(undefined);\nexport const InputDescribedByProvider = InputDescribedByContext.Provider;\n\nconst InputInvalidContext = createContext<boolean | undefined>(undefined);\nexport const InputInvalidProvider = InputInvalidContext.Provider;\n\ninterface UseInputAttributesArgs {\n /** Set this to `true` if the underlying element is not directly [labelable as per the HTML specification](https://html.spec.whatwg.org/multipage/forms.html#category-label). */\n nonLabelable?: boolean;\n}\n\nexport function useInputAttributes({ nonLabelable }: UseInputAttributesArgs = {}) {\n const labelId = useContext(FieldLabelIdContext);\n return {\n id: useContext(InputIdContext),\n 'aria-labelledby': nonLabelable ? labelId : undefined,\n 'aria-describedby': useContext(InputDescribedByContext),\n 'aria-invalid': useContext(InputInvalidContext),\n } satisfies React.HTMLAttributes<HTMLElement>;\n}\n\nexport interface WithInputAttributesProps {\n inputAttributes: ReturnType<typeof useInputAttributes>;\n}\n\nexport function withInputAttributes<T extends Partial<WithInputAttributesProps>>(\n Component: React.ComponentType<T>,\n args?: UseInputAttributesArgs,\n) {\n function ComponentWithInputAttributes(props: Omit<T, keyof WithInputAttributesProps>) {\n return <Component inputAttributes={useInputAttributes(args)} {...(props as T)} />;\n }\n\n ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;\n\n return ComponentWithInputAttributes;\n}\n"],"names":["FieldLabelIdContext","createContext","undefined","FieldLabelIdContextProvider","Provider","InputIdContext","InputIdContextProvider","InputDescribedByContext","InputDescribedByProvider","InputInvalidContext","InputInvalidProvider","useInputAttributes","nonLabelable","labelId","useContext","id","withInputAttributes","Component","args","ComponentWithInputAttributes","props","_jsx","inputAttributes","displayName","name"],"mappings":";;;AAEA,MAAMA,mBAAmB,gBAAGC,aAAa,CAAqBC,SAAS,CAAC,CAAA;AAC3DC,MAAAA,2BAA2B,GAAGH,mBAAmB,CAACI,SAAQ;AAEvE,MAAMC,cAAc,gBAAGJ,aAAa,CAAqBC,SAAS,CAAC,CAAA;AACtDI,MAAAA,sBAAsB,GAAGD,cAAc,CAACD,SAAQ;AAE7D,MAAMG,uBAAuB,gBAAGN,aAAa,CAAqBC,SAAS,CAAC,CAAA;AAC/DM,MAAAA,wBAAwB,GAAGD,uBAAuB,CAACH,SAAQ;AAExE,MAAMK,mBAAmB,gBAAGR,aAAa,CAAsBC,SAAS,CAAC,CAAA;AAC5DQ,MAAAA,oBAAoB,GAAGD,mBAAmB,CAACL,SAAQ;SAOhDO,kBAAkBA,CAAC;AAAEC,EAAAA,YAAAA;IAAyC,EAAE,EAAA;AAC9E,EAAA,MAAMC,OAAO,GAAGC,UAAU,CAACd,mBAAmB,CAAC,CAAA;EAC/C,OAAO;AACLe,IAAAA,EAAE,EAAED,UAAU,CAACT,cAAc,CAAC;AAC9B,IAAA,iBAAiB,EAAEO,YAAY,GAAGC,OAAO,GAAGX,SAAS;AACrD,IAAA,kBAAkB,EAAEY,UAAU,CAACP,uBAAuB,CAAC;IACvD,cAAc,EAAEO,UAAU,CAACL,mBAAmB,CAAA;GACH,CAAA;AAC/C,CAAA;AAMgB,SAAAO,mBAAmBA,CACjCC,SAAiC,EACjCC,IAA6B,EAAA;EAE7B,SAASC,4BAA4BA,CAACC,KAA8C,EAAA;IAClF,oBAAOC,GAAA,CAACJ,SAAS,EAAA;AAACK,MAAAA,eAAe,EAAEX,kBAAkB,CAACO,IAAI,CAAE;MAAA,GAAME,KAAAA;AAAW,MAAI,CAAA;AACnF,GAAA;AAEAD,EAAAA,4BAA4B,CAACI,WAAW,GAAG,CAAA,oBAAA,EAAuBN,SAAS,CAACM,WAAW,IAAIN,SAAS,CAACO,IAAI,IAAI,YAAc,CAAA,CAAA,CAAA;AAE3H,EAAA,OAAOL,4BAA4B,CAAA;AACrC;;;;"}
|
package/build/main.css
CHANGED
|
@@ -4755,9 +4755,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4755
4755
|
transition: background 300ms;
|
|
4756
4756
|
color: var(--color-interactive-primary);
|
|
4757
4757
|
}
|
|
4758
|
-
.np-theme-personal .form-group .segmented-control__segment {
|
|
4759
|
-
margin-bottom: 0;
|
|
4760
|
-
}
|
|
4761
4758
|
.segmented-control__segment:first-child {
|
|
4762
4759
|
margin-left: 0;
|
|
4763
4760
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var classNames = require('classnames');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var Body = require('../body/Body.js');
|
|
6
|
-
var contexts = require('../inputs/contexts.js');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var typography = require('../common/propsValues/typography.js');
|
|
9
8
|
|
|
@@ -18,9 +17,6 @@ const SegmentedControl = ({
|
|
|
18
17
|
segments,
|
|
19
18
|
onChange
|
|
20
19
|
}) => {
|
|
21
|
-
const inputAttributes = contexts.useInputAttributes({
|
|
22
|
-
nonLabelable: true
|
|
23
|
-
});
|
|
24
20
|
const [animate, setAnimate] = React.useState(false);
|
|
25
21
|
const segmentsRef = React.useRef(null);
|
|
26
22
|
if (segments.length > 3) {
|
|
@@ -66,8 +62,7 @@ const SegmentedControl = ({
|
|
|
66
62
|
className: classNames__default.default('segmented-control__segments', {
|
|
67
63
|
'segmented-control__segments--no-animate': !animate
|
|
68
64
|
}),
|
|
69
|
-
role: mode !== 'input' ? 'tablist' :
|
|
70
|
-
...inputAttributes,
|
|
65
|
+
role: mode !== 'input' ? 'tablist' : undefined,
|
|
71
66
|
children: segmentsWithRefs.map(segment => {
|
|
72
67
|
const onSelect = () => {
|
|
73
68
|
setAnimate(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.js","sources":["../../src/segmentedControl/SegmentedControl.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, useEffect, useRef, useState } from 'react';\n\nimport Body from '../body';\nimport { Typography } from '../common';\
|
|
1
|
+
{"version":3,"file":"SegmentedControl.js","sources":["../../src/segmentedControl/SegmentedControl.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, useEffect, useRef, useState } from 'react';\n\nimport Body from '../body';\nimport { Typography } from '../common';\n\ntype SegmentBase = { id: string; label: string; value: string };\n\ntype Segment = SegmentBase & { controls?: never };\ntype SegmentWithControls = SegmentBase & { controls: string };\n\nexport type Segments = readonly Segment[] | readonly SegmentWithControls[];\n\ntype SegmentedControlPropsBase = {\n name: string;\n value: string;\n mode: 'input' | 'view';\n onChange: (value: string) => void;\n};\n\ntype SegmentedControlViewProps = {\n mode: 'view';\n segments: readonly SegmentWithControls[];\n};\n\ntype SegmentedControlInputProps = {\n mode: 'input';\n segments: readonly Segment[];\n};\n\nexport type SegmentedControlProps = SegmentedControlPropsBase &\n (SegmentedControlViewProps | SegmentedControlInputProps);\n\nconst SegmentedControl = ({\n name,\n value,\n mode = 'input',\n segments,\n onChange,\n}: SegmentedControlProps) => {\n const [animate, setAnimate] = useState(false);\n\n const segmentsRef = useRef<HTMLDivElement>(null);\n\n if (segments.length > 3) {\n throw new Error(\n 'SegmentedControl only supports up to 3 segments. Please refer to: https://wise.design/components/segmented-control',\n );\n }\n\n const segmentsWithRefs = segments.map((segment) => ({\n ...segment,\n ref: createRef<HTMLLabelElement | HTMLButtonElement>(),\n }));\n\n const updateSegmentPosition = () => {\n const selectedSegmentRef = segmentsWithRefs.find((segment) => segment.value === value)?.ref;\n\n // We grab the active segments style object from the ref\n // and set the css variables to the selected segments width and x position.\n // This is so we can animate the highlight to the selected segment\n if (selectedSegmentRef?.current && segmentsRef.current) {\n const { style } = segmentsRef.current;\n style.setProperty('--segment-highlight-width', `${selectedSegmentRef.current.offsetWidth}px`);\n style.setProperty('--segment-highlight-x', `${selectedSegmentRef.current.offsetLeft}px`);\n }\n };\n\n useEffect(() => {\n setAnimate(true);\n updateSegmentPosition();\n\n const handleWindowSizeChange = () => {\n setAnimate(false);\n updateSegmentPosition();\n };\n\n window.addEventListener('resize', handleWindowSizeChange);\n return () => {\n window.removeEventListener('resize', handleWindowSizeChange);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [segmentsWithRefs, value]);\n\n return (\n <div\n ref={segmentsRef}\n data-testid=\"segmented-control\"\n className={classNames('segmented-control', {\n 'segmented-control--input': mode === 'input',\n })}\n >\n <div\n className={classNames('segmented-control__segments', {\n 'segmented-control__segments--no-animate': !animate,\n })}\n role={mode !== 'input' ? 'tablist' : undefined}\n >\n {segmentsWithRefs.map((segment) => {\n const onSelect = () => {\n setAnimate(true);\n onChange(segment.value);\n };\n return mode === 'input' ? (\n <label\n ref={segment.ref as React.MutableRefObject<HTMLLabelElement | null>}\n key={segment.id}\n htmlFor={segment.id}\n className={classNames('segmented-control__segment', {\n 'segmented-control__selected-segment': value === segment.value,\n })}\n >\n <input\n type=\"radio\"\n className=\"segmented-control__radio-input\"\n id={segment.id}\n name={name}\n value={segment.value}\n checked={value === segment.value}\n onChange={onSelect}\n />\n <Body\n className=\"segmented-control__text\"\n as=\"span\"\n type={\n value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT\n }\n >\n {segment.label}\n </Body>\n </label>\n ) : (\n <button\n ref={segment.ref as React.MutableRefObject<HTMLButtonElement | null>}\n key={segment.id}\n type=\"button\"\n role=\"tab\"\n id={segment.id}\n aria-controls={segment.controls}\n aria-selected={value === segment.value}\n className={classNames('segmented-control__segment', 'segmented-control__button', {\n 'segmented-control__selected-segment': value === segment.value,\n })}\n onClick={onSelect}\n >\n <Body\n as=\"span\"\n className=\"segmented-control__text\"\n type={\n value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT\n }\n >\n {segment.label}\n </Body>\n </button>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default SegmentedControl;\n"],"names":["SegmentedControl","name","value","mode","segments","onChange","animate","setAnimate","useState","segmentsRef","useRef","length","Error","segmentsWithRefs","map","segment","ref","createRef","updateSegmentPosition","selectedSegmentRef","find","current","style","setProperty","offsetWidth","offsetLeft","useEffect","handleWindowSizeChange","window","addEventListener","removeEventListener","_jsx","className","classNames","children","role","undefined","onSelect","_jsxs","htmlFor","id","type","checked","Body","as","Typography","BODY_DEFAULT_BOLD","BODY_DEFAULT","label","controls","onClick"],"mappings":";;;;;;;;;;;;AAiCMA,MAAAA,gBAAgB,GAAGA,CAAC;EACxBC,IAAI;EACJC,KAAK;AACLC,EAAAA,IAAI,GAAG,OAAO;EACdC,QAAQ;AACRC,EAAAA,QAAAA;AAAQ,CACc,KAAI;EAC1B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAA;AAE7C,EAAA,MAAMC,WAAW,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AAEhD,EAAA,IAAIN,QAAQ,CAACO,MAAM,GAAG,CAAC,EAAE;AACvB,IAAA,MAAM,IAAIC,KAAK,CACb,oHAAoH,CACrH,CAAA;AACH,GAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGT,QAAQ,CAACU,GAAG,CAAEC,OAAO,KAAM;AAClD,IAAA,GAAGA,OAAO;IACVC,GAAG,eAAEC,eAAS,EAAwC;AACvD,GAAA,CAAC,CAAC,CAAA;EAEH,MAAMC,qBAAqB,GAAGA,MAAK;AACjC,IAAA,MAAMC,kBAAkB,GAAGN,gBAAgB,CAACO,IAAI,CAAEL,OAAO,IAAKA,OAAO,CAACb,KAAK,KAAKA,KAAK,CAAC,EAAEc,GAAG,CAAA;AAE3F;AACA;AACA;AACA,IAAA,IAAIG,kBAAkB,EAAEE,OAAO,IAAIZ,WAAW,CAACY,OAAO,EAAE;MACtD,MAAM;AAAEC,QAAAA,KAAAA;OAAO,GAAGb,WAAW,CAACY,OAAO,CAAA;AACrCC,MAAAA,KAAK,CAACC,WAAW,CAAC,2BAA2B,EAAE,CAAA,EAAGJ,kBAAkB,CAACE,OAAO,CAACG,WAAW,CAAA,EAAA,CAAI,CAAC,CAAA;AAC7FF,MAAAA,KAAK,CAACC,WAAW,CAAC,uBAAuB,EAAE,CAAA,EAA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a,OAAO,CAACb,KAAM;AACvC8B,UAAAA,SAAS,EAAEC,2BAAU,CAAC,4BAA4B,EAAE,2BAA2B,EAAE;AAC/E,YAAA,qCAAqC,EAAE/B,KAAK,KAAKa,OAAO,CAACb,KAAAA;AAC1D,WAAA,CAAE;AACHgD,UAAAA,OAAO,EAAEb,QAAS;UAAAH,QAAA,eAElBH,cAAA,CAACY,IAAI,EAAA;AACHC,YAAAA,EAAE,EAAC,MAAM;AACTZ,YAAAA,SAAS,EAAC,yBAAyB;AACnCS,YAAAA,IAAI,EACFvC,KAAK,KAAKa,OAAO,CAACb,KAAK,GAAG2C,qBAAU,CAACC,iBAAiB,GAAGD,qBAAU,CAACE,YACrE;YAAAb,QAAA,EAEAnB,OAAO,CAACiC,KAAAA;WACL,CAAA;SAnBDjC,EAAAA,OAAO,CAACyB,EAoBP,CACT,CAAA;OACF,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { useState, useRef, createRef, useEffect } from 'react';
|
|
3
3
|
import Body from '../body/Body.mjs';
|
|
4
|
-
import { useInputAttributes } from '../inputs/contexts.mjs';
|
|
5
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
5
|
import { Typography } from '../common/propsValues/typography.mjs';
|
|
7
6
|
|
|
@@ -12,9 +11,6 @@ const SegmentedControl = ({
|
|
|
12
11
|
segments,
|
|
13
12
|
onChange
|
|
14
13
|
}) => {
|
|
15
|
-
const inputAttributes = useInputAttributes({
|
|
16
|
-
nonLabelable: true
|
|
17
|
-
});
|
|
18
14
|
const [animate, setAnimate] = useState(false);
|
|
19
15
|
const segmentsRef = useRef(null);
|
|
20
16
|
if (segments.length > 3) {
|
|
@@ -60,8 +56,7 @@ const SegmentedControl = ({
|
|
|
60
56
|
className: classNames('segmented-control__segments', {
|
|
61
57
|
'segmented-control__segments--no-animate': !animate
|
|
62
58
|
}),
|
|
63
|
-
role: mode !== 'input' ? 'tablist' :
|
|
64
|
-
...inputAttributes,
|
|
59
|
+
role: mode !== 'input' ? 'tablist' : undefined,
|
|
65
60
|
children: segmentsWithRefs.map(segment => {
|
|
66
61
|
const onSelect = () => {
|
|
67
62
|
setAnimate(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.mjs","sources":["../../src/segmentedControl/SegmentedControl.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, useEffect, useRef, useState } from 'react';\n\nimport Body from '../body';\nimport { Typography } from '../common';\
|
|
1
|
+
{"version":3,"file":"SegmentedControl.mjs","sources":["../../src/segmentedControl/SegmentedControl.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, useEffect, useRef, useState } from 'react';\n\nimport Body from '../body';\nimport { Typography } from '../common';\n\ntype SegmentBase = { id: string; label: string; value: string };\n\ntype Segment = SegmentBase & { controls?: never };\ntype SegmentWithControls = SegmentBase & { controls: string };\n\nexport type Segments = readonly Segment[] | readonly SegmentWithControls[];\n\ntype SegmentedControlPropsBase = {\n name: string;\n value: string;\n mode: 'input' | 'view';\n onChange: (value: string) => void;\n};\n\ntype SegmentedControlViewProps = {\n mode: 'view';\n segments: readonly SegmentWithControls[];\n};\n\ntype SegmentedControlInputProps = {\n mode: 'input';\n segments: readonly Segment[];\n};\n\nexport type SegmentedControlProps = SegmentedControlPropsBase &\n (SegmentedControlViewProps | SegmentedControlInputProps);\n\nconst SegmentedControl = ({\n name,\n value,\n mode = 'input',\n segments,\n onChange,\n}: SegmentedControlProps) => {\n const [animate, setAnimate] = useState(false);\n\n const segmentsRef = useRef<HTMLDivElement>(null);\n\n if (segments.length > 3) {\n throw new Error(\n 'SegmentedControl only supports up to 3 segments. Please refer to: https://wise.design/components/segmented-control',\n );\n }\n\n const segmentsWithRefs = segments.map((segment) => ({\n ...segment,\n ref: createRef<HTMLLabelElement | HTMLButtonElement>(),\n }));\n\n const updateSegmentPosition = () => {\n const selectedSegmentRef = segmentsWithRefs.find((segment) => segment.value === value)?.ref;\n\n // We grab the active segments style object from the ref\n // and set the css variables to the selected segments width and x position.\n // This is so we can animate the highlight to the selected segment\n if (selectedSegmentRef?.current && segmentsRef.current) {\n const { style } = segmentsRef.current;\n style.setProperty('--segment-highlight-width', `${selectedSegmentRef.current.offsetWidth}px`);\n style.setProperty('--segment-highlight-x', `${selectedSegmentRef.current.offsetLeft}px`);\n }\n };\n\n useEffect(() => {\n setAnimate(true);\n updateSegmentPosition();\n\n const handleWindowSizeChange = () => {\n setAnimate(false);\n updateSegmentPosition();\n };\n\n window.addEventListener('resize', handleWindowSizeChange);\n return () => {\n window.removeEventListener('resize', handleWindowSizeChange);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [segmentsWithRefs, value]);\n\n return (\n <div\n ref={segmentsRef}\n data-testid=\"segmented-control\"\n className={classNames('segmented-control', {\n 'segmented-control--input': mode === 'input',\n })}\n >\n <div\n className={classNames('segmented-control__segments', {\n 'segmented-control__segments--no-animate': !animate,\n })}\n role={mode !== 'input' ? 'tablist' : undefined}\n >\n {segmentsWithRefs.map((segment) => {\n const onSelect = () => {\n setAnimate(true);\n onChange(segment.value);\n };\n return mode === 'input' ? (\n <label\n ref={segment.ref as React.MutableRefObject<HTMLLabelElement | null>}\n key={segment.id}\n htmlFor={segment.id}\n className={classNames('segmented-control__segment', {\n 'segmented-control__selected-segment': value === segment.value,\n })}\n >\n <input\n type=\"radio\"\n className=\"segmented-control__radio-input\"\n id={segment.id}\n name={name}\n value={segment.value}\n checked={value === segment.value}\n onChange={onSelect}\n />\n <Body\n className=\"segmented-control__text\"\n as=\"span\"\n type={\n value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT\n }\n >\n {segment.label}\n </Body>\n </label>\n ) : (\n <button\n ref={segment.ref as React.MutableRefObject<HTMLButtonElement | null>}\n key={segment.id}\n type=\"button\"\n role=\"tab\"\n id={segment.id}\n aria-controls={segment.controls}\n aria-selected={value === segment.value}\n className={classNames('segmented-control__segment', 'segmented-control__button', {\n 'segmented-control__selected-segment': value === segment.value,\n })}\n onClick={onSelect}\n >\n <Body\n as=\"span\"\n className=\"segmented-control__text\"\n type={\n value === segment.value ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_DEFAULT\n }\n >\n {segment.label}\n </Body>\n </button>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default SegmentedControl;\n"],"names":["SegmentedControl","name","value","mode","segments","onChange","animate","setAnimate","useState","segmentsRef","useRef","length","Error","segmentsWithRefs","map","segment","ref","createRef","updateSegmentPosition","selectedSegmentRef","find","current","style","setProperty","offsetWidth","offsetLeft","useEffect","handleWindowSizeChange","window","addEventListener","removeEventListener","_jsx","className","classNames","children","role","undefined","onSelect","_jsxs","htmlFor","id","type","checked","Body","as","Typography","BODY_DEFAULT_BOLD","BODY_DEFAULT","label","controls","onClick"],"mappings":";;;;;;AAiCMA,MAAAA,gBAAgB,GAAGA,CAAC;EACxBC,IAAI;EACJC,KAAK;AACLC,EAAAA,IAAI,GAAG,OAAO;EACdC,QAAQ;AACRC,EAAAA,QAAAA;AAAQ,CACc,KAAI;EAC1B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAE7C,EAAA,MAAMC,WAAW,GAAGC,MAAM,CAAiB,IAAI,CAAC,CAAA;AAEhD,EAAA,IAAIN,QAAQ,CAACO,MAAM,GAAG,CAAC,EAAE;AACvB,IAAA,MAAM,IAAIC,KAAK,CACb,oHAAoH,CACrH,CAAA;AACH,GAAA;AAEA,EAAA,MAAMC,gBAAgB,GAAGT,QAAQ,CAACU,GAAG,CAAEC,OAAO,KAAM;AAClD,IAAA,GAAGA,OAAO;IACVC,GAAG,eAAEC,SAAS,EAAwC;AACvD,GAAA,CAAC,CAAC,CAAA;EAEH,MAAMC,qBAAqB,GAAGA,MAAK;AACjC,IAAA,MAAMC,kBAAkB,GAAGN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AAK,KAAKa,OAAO,CAACb,KAAK,GAAG2C,UAAU,CAACC,iBAAiB,GAAGD,UAAU,CAACE,YACrE;YAAAb,QAAA,EAEAnB,OAAO,CAACiC,KAAAA;AAAK,WACV,CACR,CAAA;AAAA,SAAA,EAxBOjC,OAAO,CAACyB,EAwBR,CAAC,gBAERT,GAAA,CAAA,QAAA,EAAA;UACEf,GAAG,EAAED,OAAO,CAACC,GAAwD;AAErEyB,UAAAA,IAAI,EAAC,QAAQ;AACbN,UAAAA,IAAI,EAAC,KAAK;UACVK,EAAE,EAAEzB,OAAO,CAACyB,EAAG;UACf,eAAezB,EAAAA,OAAO,CAACkC,QAAS;AAChC,UAAA,eAAA,EAAe/C,KAAK,KAAKa,OAAO,CAACb,KAAM;AACvC8B,UAAAA,SAAS,EAAEC,UAAU,CAAC,4BAA4B,EAAE,2BAA2B,EAAE;AAC/E,YAAA,qCAAqC,EAAE/B,KAAK,KAAKa,OAAO,CAACb,KAAAA;AAC1D,WAAA,CAAE;AACHgD,UAAAA,OAAO,EAAEb,QAAS;UAAAH,QAAA,eAElBH,GAAA,CAACY,IAAI,EAAA;AACHC,YAAAA,EAAE,EAAC,MAAM;AACTZ,YAAAA,SAAS,EAAC,yBAAyB;AACnCS,YAAAA,IAAI,EACFvC,KAAK,KAAKa,OAAO,CAACb,KAAK,GAAG2C,UAAU,CAACC,iBAAiB,GAAGD,UAAU,CAACE,YACrE;YAAAb,QAAA,EAEAnB,OAAO,CAACiC,KAAAA;WACL,CAAA;SAnBDjC,EAAAA,OAAO,CAACyB,EAoBP,CACT,CAAA;OACF,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
|
package/build/styles/main.css
CHANGED
|
@@ -4755,9 +4755,6 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4755
4755
|
transition: background 300ms;
|
|
4756
4756
|
color: var(--color-interactive-primary);
|
|
4757
4757
|
}
|
|
4758
|
-
.np-theme-personal .form-group .segmented-control__segment {
|
|
4759
|
-
margin-bottom: 0;
|
|
4760
|
-
}
|
|
4761
4758
|
.segmented-control__segment:first-child {
|
|
4762
4759
|
margin-left: 0;
|
|
4763
4760
|
}
|
package/build/tabs/TabList.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var PropTypes = require('prop-types');
|
|
3
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
5
|
|
|
5
|
-
function
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
9
|
+
|
|
10
|
+
const TabList = ({
|
|
6
11
|
children
|
|
7
|
-
}) {
|
|
12
|
+
}) => {
|
|
8
13
|
return /*#__PURE__*/jsxRuntime.jsx("ul", {
|
|
9
14
|
className: "tabs__tab-list",
|
|
10
15
|
role: "tablist",
|
|
11
16
|
children: children
|
|
12
17
|
});
|
|
13
|
-
}
|
|
18
|
+
};
|
|
19
|
+
TabList.propTypes = {
|
|
20
|
+
children: PropTypes__default.default.oneOfType([PropTypes__default.default.object, PropTypes__default.default.array]).isRequired
|
|
21
|
+
};
|
|
14
22
|
|
|
15
23
|
module.exports = TabList;
|
|
16
24
|
//# sourceMappingURL=TabList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.js","sources":["../../src/tabs/TabList.
|
|
1
|
+
{"version":3,"file":"TabList.js","sources":["../../src/tabs/TabList.js"],"sourcesContent":["import PropTypes from 'prop-types';\n\nconst TabList = ({ children }) => {\n return (\n <ul className=\"tabs__tab-list\" role=\"tablist\">\n {children}\n </ul>\n );\n};\n\nTabList.propTypes = {\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,\n};\n\nexport default TabList;\n"],"names":["TabList","children","_jsx","className","role","propTypes","PropTypes","oneOfType","object","array","isRequired"],"mappings":";;;;;;;;;AAEMA,MAAAA,OAAO,GAAGA,CAAC;AAAEC,EAAAA,QAAAA;AAAS,CAAC,KAAK;AAChC,EAAA,oBACEC,cAAA,CAAA,IAAA,EAAA;AAAIC,IAAAA,SAAS,EAAC,gBAAgB;AAACC,IAAAA,IAAI,EAAC,SAAS;AAAAH,IAAAA,QAAA,EAC1CA,QAAAA;AAAQ,GACP,CAAC,CAAA;AAET,EAAC;AAEDD,OAAO,CAACK,SAAS,GAAG;AAClBJ,EAAAA,QAAQ,EAAEK,0BAAS,CAACC,SAAS,CAAC,CAACD,0BAAS,CAACE,MAAM,EAAEF,0BAAS,CAACG,KAAK,CAAC,CAAC,CAACC,UAAAA;AACrE,CAAC;;;;"}
|
package/build/tabs/TabList.mjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const TabList = ({
|
|
4
5
|
children
|
|
5
|
-
}) {
|
|
6
|
+
}) => {
|
|
6
7
|
return /*#__PURE__*/jsx("ul", {
|
|
7
8
|
className: "tabs__tab-list",
|
|
8
9
|
role: "tablist",
|
|
9
10
|
children: children
|
|
10
11
|
});
|
|
11
|
-
}
|
|
12
|
+
};
|
|
13
|
+
TabList.propTypes = {
|
|
14
|
+
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired
|
|
15
|
+
};
|
|
12
16
|
|
|
13
17
|
export { TabList as default };
|
|
14
18
|
//# sourceMappingURL=TabList.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.mjs","sources":["../../src/tabs/TabList.
|
|
1
|
+
{"version":3,"file":"TabList.mjs","sources":["../../src/tabs/TabList.js"],"sourcesContent":["import PropTypes from 'prop-types';\n\nconst TabList = ({ children }) => {\n return (\n <ul className=\"tabs__tab-list\" role=\"tablist\">\n {children}\n </ul>\n );\n};\n\nTabList.propTypes = {\n children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired,\n};\n\nexport default TabList;\n"],"names":["TabList","children","_jsx","className","role","propTypes","PropTypes","oneOfType","object","array","isRequired"],"mappings":";;;AAEMA,MAAAA,OAAO,GAAGA,CAAC;AAAEC,EAAAA,QAAAA;AAAS,CAAC,KAAK;AAChC,EAAA,oBACEC,GAAA,CAAA,IAAA,EAAA;AAAIC,IAAAA,SAAS,EAAC,gBAAgB;AAACC,IAAAA,IAAI,EAAC,SAAS;AAAAH,IAAAA,QAAA,EAC1CA,QAAAA;AAAQ,GACP,CAAC,CAAA;AAET,EAAC;AAEDD,OAAO,CAACK,SAAS,GAAG;AAClBJ,EAAAA,QAAQ,EAAEK,SAAS,CAACC,SAAS,CAAC,CAACD,SAAS,CAACE,MAAM,EAAEF,SAAS,CAACG,KAAK,CAAC,CAAC,CAACC,UAAAA;AACrE,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/field/Field.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAUtC,MAAM,MAAM,UAAU,GAAG;IACvB,6IAA6I;IAC7I,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,sGAAsG;IACtG,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,KAAK,4FAQf,UAAU,
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/field/Field.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAUtC,MAAM,MAAM,UAAU,GAAG;IACvB,6IAA6I;IAC7I,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,sGAAsG;IACtG,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,KAAK,4FAQf,UAAU,gCAiDZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/inputs/contexts.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,2BAA2B,8CAA+B,CAAC;AAGxE,eAAO,MAAM,sBAAsB,8CAA0B,CAAC;AAG9D,eAAO,MAAM,wBAAwB,8CAAmC,CAAC;AAGzE,eAAO,MAAM,oBAAoB,+CAA+B,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,gLAAgL;IAChL,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,YAAY,EAAE,GAAE,sBAA2B;;;;;
|
|
1
|
+
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/inputs/contexts.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,2BAA2B,8CAA+B,CAAC;AAGxE,eAAO,MAAM,sBAAsB,8CAA0B,CAAC;AAG9D,eAAO,MAAM,wBAAwB,8CAAmC,CAAC;AAGzE,eAAO,MAAM,oBAAoB,+CAA+B,CAAC;AAEjE,UAAU,sBAAsB;IAC9B,gLAAgL;IAChL,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,YAAY,EAAE,GAAE,sBAA2B;;;;;EAQ/E;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;CACxD;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,OAAO,CAAC,wBAAwB,CAAC,EAC7E,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,IAAI,CAAC,EAAE,sBAAsB;YAEgB,IAAI,CAAC,CAAC,EAAE,MAAM,wBAAwB,CAAC;;EAOrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/segmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SegmentedControl.d.ts","sourceRoot":"","sources":["../../../src/segmentedControl/SegmentedControl.tsx"],"names":[],"mappings":"AAMA,KAAK,WAAW,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,KAAK,OAAO,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAClD,KAAK,mBAAmB,GAAG,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,SAAS,OAAO,EAAE,GAAG,SAAS,mBAAmB,EAAE,CAAC;AAE3E,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC1C,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,yBAAyB,GAC3D,CAAC,yBAAyB,GAAG,0BAA0B,CAAC,CAAC;AAE3D,QAAA,MAAM,gBAAgB,+CAMnB,qBAAqB,gCA0HvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export default TabList;
|
|
2
|
+
declare function TabList({ children }: {
|
|
3
|
+
children: any;
|
|
4
|
+
}): import("react").JSX.Element;
|
|
5
|
+
declare namespace TabList {
|
|
6
|
+
namespace propTypes {
|
|
7
|
+
let children: any;
|
|
8
|
+
}
|
|
3
9
|
}
|
|
4
|
-
export default function TabList({ children }: TabListProps): import("react").JSX.Element;
|
|
5
10
|
//# sourceMappingURL=TabList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../src/tabs/TabList.
|
|
1
|
+
{"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../src/tabs/TabList.js"],"names":[],"mappings":";AAEA;;gCAMC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadInput.d.ts","sourceRoot":"","sources":["../../../src/uploadInput/UploadInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAiC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"UploadInput.d.ts","sourceRoot":"","sources":["../../../src/uploadInput/UploadInput.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAiC,MAAM,WAAW,CAAC;AAOvE,OAAO,EAAE,YAAY,EAAe,cAAc,EAAE,MAAM,SAAS,CAAC;AACpE,OAAqB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAE9E,OAAmB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAEhC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,YAAY,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAE9D;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAErD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAEjD;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,aAAa,CAAC,EAAE;QACd;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;QAEf;;WAEG;QACH,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QAEvB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAEF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,GAAG,IAAI,CACN,iBAAiB,EACjB,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,IAAI,GAAG,mBAAmB,CACjG,GACC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,GACnC,WAAW,CAAC;AAQd,QAAA,MAAM,WAAW,uQAoBd,gBAAgB,gCA8PlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -4,6 +4,7 @@ var classNames = require('classnames');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactIntl = require('react-intl');
|
|
6
6
|
var Button = require('../button/Button.js');
|
|
7
|
+
var contexts = require('../inputs/contexts.js');
|
|
7
8
|
var Modal = require('../modal/Modal.js');
|
|
8
9
|
var isSizeValid = require('../upload/utils/isSizeValid/isSizeValid.js');
|
|
9
10
|
var isTypeValid = require('../upload/utils/isTypeValid/isTypeValid.js');
|
|
@@ -48,6 +49,9 @@ const UploadInput = ({
|
|
|
48
49
|
sizeLimitErrorMessage,
|
|
49
50
|
uploadButtonTitle
|
|
50
51
|
}) => {
|
|
52
|
+
const inputAttributes = contexts.useInputAttributes({
|
|
53
|
+
nonLabelable: true
|
|
54
|
+
});
|
|
51
55
|
const [markedFileForDelete, setMarkedFileForDelete] = React.useState(null);
|
|
52
56
|
const [mounted, setMounted] = React.useState(false);
|
|
53
57
|
const {
|
|
@@ -204,9 +208,11 @@ const UploadInput = ({
|
|
|
204
208
|
}, [onFilesChange, uploadedFiles]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
205
209
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
206
210
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
211
|
+
role: "group",
|
|
207
212
|
className: classNames__default.default('np-upload-input', className, {
|
|
208
213
|
disabled
|
|
209
214
|
}),
|
|
215
|
+
...inputAttributes,
|
|
210
216
|
children: [uploadedFiles.map(file => /*#__PURE__*/jsxRuntime.jsx(UploadItem.default, {
|
|
211
217
|
file: file,
|
|
212
218
|
singleFileUpload: !multiple,
|