@transferwise/components 0.0.0-experimental-a7b7094 → 0.0.0-experimental-580125e
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 +32 -63
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +34 -65
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +0 -1
- package/build/i18n/en.json.js +0 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/TextArea.js +0 -25
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs +2 -27
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/inputs/contexts.js +0 -16
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +2 -16
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/main.css +3 -21
- package/build/popover/Popover.js +9 -12
- package/build/popover/Popover.js.map +1 -1
- package/build/popover/Popover.mjs +9 -12
- package/build/popover/Popover.mjs.map +1 -1
- package/build/styles/field/Field.css +3 -19
- package/build/styles/main.css +3 -21
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +0 -6
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/field/Field.css +3 -19
- package/src/field/Field.less +3 -17
- package/src/field/Field.story.tsx +1 -5
- package/src/field/Field.test.tsx +0 -90
- package/src/field/Field.tsx +37 -84
- package/src/i18n/en.json +0 -1
- package/src/inputs/TextArea.tsx +3 -34
- package/src/inputs/contexts.tsx +1 -18
- package/src/main.css +3 -21
- package/src/popover/Popover.story.tsx +45 -0
- package/src/popover/Popover.test.story.tsx +63 -0
- package/src/popover/Popover.test.tsx +56 -0
- package/src/popover/Popover.tsx +10 -12
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +0 -1
- package/build/field/Field.messages.js +0 -14
- package/build/field/Field.messages.js.map +0 -1
- package/build/field/Field.messages.mjs +0 -10
- package/build/field/Field.messages.mjs.map +0 -1
- package/build/types/field/Field.messages.d.ts +0 -8
- package/build/types/field/Field.messages.d.ts.map +0 -1
- package/src/field/Field.messages.ts +0 -8
- package/src/inputs/TextArea.story.tsx +0 -56
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useContext
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
const FieldLabelContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -23,20 +23,6 @@ function useInputAttributes({
|
|
|
23
23
|
function useFieldLabelRef() {
|
|
24
24
|
return useContext(FieldLabelContext)?.ref;
|
|
25
25
|
}
|
|
26
|
-
const TextareaCharacterCountContext = /*#__PURE__*/createContext(undefined);
|
|
27
|
-
const TextareaCharacterCountProvider = TextareaCharacterCountContext.Provider;
|
|
28
|
-
function useTextareaCharacterCount(current, max) {
|
|
29
|
-
const setCharacterCount = useContext(TextareaCharacterCountContext);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (setCharacterCount && max != null) {
|
|
32
|
-
setCharacterCount({
|
|
33
|
-
current,
|
|
34
|
-
max
|
|
35
|
-
});
|
|
36
|
-
return () => setCharacterCount(null);
|
|
37
|
-
}
|
|
38
|
-
}, [setCharacterCount, current, max]);
|
|
39
|
-
}
|
|
40
26
|
function withInputAttributes(Component, args) {
|
|
41
27
|
function ComponentWithInputAttributes(props) {
|
|
42
28
|
return /*#__PURE__*/jsx(Component, {
|
|
@@ -48,5 +34,5 @@ function withInputAttributes(Component, args) {
|
|
|
48
34
|
return ComponentWithInputAttributes;
|
|
49
35
|
}
|
|
50
36
|
|
|
51
|
-
export { FieldLabelContextProvider, InputDescribedByProvider, InputIdContextProvider, InputInvalidProvider,
|
|
37
|
+
export { FieldLabelContextProvider, InputDescribedByProvider, InputIdContextProvider, InputInvalidProvider, useFieldLabelRef, useInputAttributes, withInputAttributes };
|
|
52
38
|
//# sourceMappingURL=contexts.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.mjs","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext
|
|
1
|
+
{"version":3,"file":"contexts.mjs","sources":["../../src/inputs/contexts.tsx"],"sourcesContent":["import { createContext, useContext } from 'react';\n\ntype FieldLabelContextType = {\n id?: string;\n ref?: React.RefObject<HTMLLabelElement>;\n};\n\nconst FieldLabelContext = createContext<FieldLabelContextType | undefined>(undefined);\nexport const FieldLabelContextProvider = FieldLabelContext.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(FieldLabelContext)?.id;\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 function useFieldLabelRef() {\n return useContext(FieldLabelContext)?.ref;\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":["FieldLabelContext","createContext","undefined","FieldLabelContextProvider","Provider","InputIdContext","InputIdContextProvider","InputDescribedByContext","InputDescribedByProvider","InputInvalidContext","InputInvalidProvider","useInputAttributes","nonLabelable","labelId","useContext","id","useFieldLabelRef","ref","withInputAttributes","Component","args","ComponentWithInputAttributes","props","_jsx","inputAttributes","displayName","name"],"mappings":";;;AAOA,MAAMA,iBAAiB,gBAAGC,aAAa,CAAoCC,SAAS,CAAC;AAC9E,MAAMC,yBAAyB,GAAGH,iBAAiB,CAACI;AAE3D,MAAMC,cAAc,gBAAGJ,aAAa,CAAqBC,SAAS,CAAC;AAC5D,MAAMI,sBAAsB,GAAGD,cAAc,CAACD;AAErD,MAAMG,uBAAuB,gBAAGN,aAAa,CAAqBC,SAAS,CAAC;AACrE,MAAMM,wBAAwB,GAAGD,uBAAuB,CAACH;AAEhE,MAAMK,mBAAmB,gBAAGR,aAAa,CAAsBC,SAAS,CAAC;AAClE,MAAMQ,oBAAoB,GAAGD,mBAAmB,CAACL;SAOxCO,kBAAkBA,CAAC;AAAEC,EAAAA;IAAyC,EAAE,EAAA;AAC9E,EAAA,MAAMC,OAAO,GAAGC,UAAU,CAACd,iBAAiB,CAAC,EAAEe,EAAE;EACjD,OAAO;AACLA,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;GACH;AAC/C;SAEgBO,gBAAgBA,GAAA;AAC9B,EAAA,OAAOF,UAAU,CAACd,iBAAiB,CAAC,EAAEiB,GAAG;AAC3C;AAMM,SAAUC,mBAAmBA,CACjCC,SAAiC,EACjCC,IAA6B,EAAA;EAE7B,SAASC,4BAA4BA,CAACC,KAA8C,EAAA;IAClF,oBAAOC,GAAA,CAACJ,SAAS,EAAA;AAACK,MAAAA,eAAe,EAAEb,kBAAkB,CAACS,IAAI,CAAE;MAAA,GAAME;AAAW,MAAI;AACnF,EAAA;AAEAD,EAAAA,4BAA4B,CAACI,WAAW,GAAG,CAAA,oBAAA,EAAuBN,SAAS,CAACM,WAAW,IAAIN,SAAS,CAACO,IAAI,IAAI,WAAW,CAAA,CAAA,CAAG;AAE3H,EAAA,OAAOL,4BAA4B;AACrC;;;;"}
|
package/build/main.css
CHANGED
|
@@ -30194,36 +30194,18 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
30194
30194
|
stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
|
|
30195
30195
|
}
|
|
30196
30196
|
|
|
30197
|
-
.np-field-control
|
|
30197
|
+
.np-field-control,
|
|
30198
|
+
.np-field__prompt {
|
|
30198
30199
|
margin-top: 4px;
|
|
30199
30200
|
margin-top: var(--size-4);
|
|
30200
30201
|
}
|
|
30201
30202
|
|
|
30202
|
-
.np-field-validation {
|
|
30203
|
-
display: flex;
|
|
30204
|
-
align-items: flex-start;
|
|
30205
|
-
margin-top: 4px;
|
|
30206
|
-
margin-top: var(--size-4);
|
|
30207
|
-
gap: 8px;
|
|
30208
|
-
gap: var(--size-8);
|
|
30209
|
-
}
|
|
30210
|
-
|
|
30211
|
-
.np-field-textarea-char-counter {
|
|
30212
|
-
min-width: 55px;
|
|
30213
|
-
text-align: right;
|
|
30214
|
-
margin-left: auto;
|
|
30215
|
-
padding: 4px 0;
|
|
30216
|
-
padding: var(--size-4) 0;
|
|
30217
|
-
color: #768e9c;
|
|
30218
|
-
color: var(--color-content-tertiary);
|
|
30219
|
-
}
|
|
30220
|
-
|
|
30221
30203
|
.np-field .form-group--typeahead[class],
|
|
30222
30204
|
.np-field .np-checkbox-label[class] {
|
|
30223
30205
|
margin-bottom: 0;
|
|
30224
30206
|
}
|
|
30225
30207
|
|
|
30226
|
-
.np-field:has(.wds-radio-group) .np-
|
|
30208
|
+
.np-field:has(.wds-radio-group) .np-field__prompt {
|
|
30227
30209
|
margin-top: 12px;
|
|
30228
30210
|
margin-top: var(--size-12);
|
|
30229
30211
|
}
|
package/build/popover/Popover.js
CHANGED
|
@@ -67,24 +67,21 @@ function Popover({
|
|
|
67
67
|
onClose?.();
|
|
68
68
|
};
|
|
69
69
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}) : children
|
|
80
|
-
}), /*#__PURE__*/jsxRuntime.jsx(ResponsivePanel.default, {
|
|
70
|
+
ref: anchorReference,
|
|
71
|
+
className: "np-popover d-inline-block",
|
|
72
|
+
children: [/*#__PURE__*/React.isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, {
|
|
73
|
+
onClick: () => {
|
|
74
|
+
children.props.onClick?.();
|
|
75
|
+
setOpen(prevOpen => !prevOpen);
|
|
76
|
+
}
|
|
77
|
+
}) : children, /*#__PURE__*/jsxRuntime.jsx(ResponsivePanel.default, {
|
|
81
78
|
"aria-label": ariaLabel,
|
|
82
79
|
"aria-labelledby": title && !ariaLabel ? titleId : undefined,
|
|
83
80
|
open: open,
|
|
84
81
|
anchorRef: anchorReference,
|
|
85
82
|
position: resolvedPlacement,
|
|
86
83
|
arrow: true,
|
|
87
|
-
className:
|
|
84
|
+
className: clsx.clsx('np-popover__container', className),
|
|
88
85
|
onClose: handleOnClose,
|
|
89
86
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
90
87
|
className: "np-popover__content np-text-default-body",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { useRef, useState, cloneElement, useEffect, isValidElement, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport ResponsivePanel from '../common/responsivePanel';\nimport Title from '../title';\nimport { logActionRequired } from '../utilities';\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype PopoverPreferredPlacementDeprecated =\n | `${Position.LEFT_TOP}`\n | `${Position.RIGHT_TOP}`\n | `${Position.BOTTOM_RIGHT}`\n | `${Position.BOTTOM_LEFT}`;\n\nexport type PopoverPreferredPlacement =\n | `${Position.TOP}`\n | `${Position.RIGHT}`\n | `${Position.BOTTOM}`\n | `${Position.LEFT}`\n | PopoverPreferredPlacementDeprecated;\n\nexport interface PopoverProps {\n children?: React.ReactNode;\n title?: React.ReactNode;\n /** Screen-reader-friendly title. Must be provided if `title` prop is not set. */\n 'aria-label'?: string;\n /** @default 'right' */\n preferredPlacement?: PopoverPreferredPlacement;\n content: React.ReactNode;\n onClose?: () => void;\n className?: string;\n}\n\nfunction resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {\n switch (preferredPlacement) {\n case 'left-top':\n case 'right-top':\n return 'top';\n case 'bottom-left':\n case 'bottom-right':\n return 'bottom';\n default:\n return preferredPlacement;\n }\n}\n\nexport default function Popover({\n children,\n className,\n content,\n preferredPlacement = Position.RIGHT,\n title,\n onClose,\n 'aria-label': ariaLabel,\n}: PopoverProps) {\n const titleId = useId();\n\n const resolvedPlacement = resolvePlacement(preferredPlacement);\n useEffect(() => {\n if (resolvedPlacement !== preferredPlacement) {\n logActionRequired(\n `Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`,\n );\n }\n }, [preferredPlacement, resolvedPlacement]);\n\n const anchorReference = useRef(null);\n const [open, setOpen] = useState(false);\n\n const handleOnClose = () => {\n setOpen(false);\n onClose?.();\n };\n\n return (\n <span
|
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { useRef, useState, cloneElement, useEffect, isValidElement, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport ResponsivePanel from '../common/responsivePanel';\nimport Title from '../title';\nimport { logActionRequired } from '../utilities';\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype PopoverPreferredPlacementDeprecated =\n | `${Position.LEFT_TOP}`\n | `${Position.RIGHT_TOP}`\n | `${Position.BOTTOM_RIGHT}`\n | `${Position.BOTTOM_LEFT}`;\n\nexport type PopoverPreferredPlacement =\n | `${Position.TOP}`\n | `${Position.RIGHT}`\n | `${Position.BOTTOM}`\n | `${Position.LEFT}`\n | PopoverPreferredPlacementDeprecated;\n\nexport interface PopoverProps {\n children?: React.ReactNode;\n title?: React.ReactNode;\n /** Screen-reader-friendly title. Must be provided if `title` prop is not set. */\n 'aria-label'?: string;\n /** @default 'right' */\n preferredPlacement?: PopoverPreferredPlacement;\n content: React.ReactNode;\n onClose?: () => void;\n className?: string;\n}\n\nfunction resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {\n switch (preferredPlacement) {\n case 'left-top':\n case 'right-top':\n return 'top';\n case 'bottom-left':\n case 'bottom-right':\n return 'bottom';\n default:\n return preferredPlacement;\n }\n}\n\nexport default function Popover({\n children,\n className,\n content,\n preferredPlacement = Position.RIGHT,\n title,\n onClose,\n 'aria-label': ariaLabel,\n}: PopoverProps) {\n const titleId = useId();\n\n const resolvedPlacement = resolvePlacement(preferredPlacement);\n useEffect(() => {\n if (resolvedPlacement !== preferredPlacement) {\n logActionRequired(\n `Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`,\n );\n }\n }, [preferredPlacement, resolvedPlacement]);\n\n const anchorReference = useRef(null);\n const [open, setOpen] = useState(false);\n\n const handleOnClose = () => {\n setOpen(false);\n onClose?.();\n };\n\n return (\n <span ref={anchorReference} className=\"np-popover d-inline-block\">\n {isValidElement<{ onClick?: () => void }>(children)\n ? cloneElement(children, {\n onClick: () => {\n children.props.onClick?.();\n setOpen((prevOpen) => !prevOpen);\n },\n })\n : children}\n <ResponsivePanel\n aria-label={ariaLabel}\n aria-labelledby={title && !ariaLabel ? titleId : undefined}\n open={open}\n anchorRef={anchorReference}\n position={resolvedPlacement}\n arrow\n className={clsx('np-popover__container', className)}\n onClose={handleOnClose}\n >\n <div className=\"np-popover__content np-text-default-body\">\n {title && (\n <Title type={Typography.TITLE_BODY} id={titleId} className=\"m-b-1\">\n {title}\n </Title>\n )}\n {content}\n </div>\n </ResponsivePanel>\n </span>\n );\n}\n"],"names":["resolvePlacement","preferredPlacement","Popover","children","className","content","Position","RIGHT","title","onClose","ariaLabel","titleId","useId","resolvedPlacement","useEffect","logActionRequired","anchorReference","useRef","open","setOpen","useState","handleOnClose","_jsxs","ref","isValidElement","cloneElement","onClick","props","prevOpen","_jsx","ResponsivePanel","undefined","anchorRef","position","arrow","clsx","Title","type","Typography","TITLE_BODY","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAASA,gBAAgBA,CAACC,kBAA6C,EAAA;AACrE,EAAA,QAAQA,kBAAkB;AACxB,IAAA,KAAK,UAAU;AACf,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,KAAK;AACd,IAAA,KAAK,aAAa;AAClB,IAAA,KAAK,cAAc;AACjB,MAAA,OAAO,QAAQ;AACjB,IAAA;AACE,MAAA,OAAOA,kBAAkB;AAC7B;AACF;AAEc,SAAUC,OAAOA,CAAC;EAC9BC,QAAQ;EACRC,SAAS;EACTC,OAAO;EACPJ,kBAAkB,GAAGK,iBAAQ,CAACC,KAAK;EACnCC,KAAK;EACLC,OAAO;AACP,EAAA,YAAY,EAAEC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AA,QAAQ,EAAEpB,iBAAkB;MAC5BqB,KAAK,EAAA,IAAA;AACL9B,MAAAA,SAAS,EAAE+B,SAAI,CAAC,uBAAuB,EAAE/B,SAAS,CAAE;AACpDK,MAAAA,OAAO,EAAEY,aAAc;AAAAlB,MAAAA,QAAA,eAEvBmB,eAAA,CAAA,KAAA,EAAA;AAAKlB,QAAAA,SAAS,EAAC,0CAA0C;AAAAD,QAAAA,QAAA,EAAA,CACtDK,KAAK,iBACJqB,cAAA,CAACO,aAAK,EAAA;UAACC,IAAI,EAAEC,qBAAU,CAACC,UAAW;AAACC,UAAAA,EAAE,EAAE7B,OAAQ;AAACP,UAAAA,SAAS,EAAC,OAAO;AAAAD,UAAAA,QAAA,EAC/DK;SACI,CACR,EACAH,OAAO;OACL;AACP,KAAiB,CACnB;AAAA,GAAM,CAAC;AAEX;;;;"}
|
|
@@ -63,24 +63,21 @@ function Popover({
|
|
|
63
63
|
onClose?.();
|
|
64
64
|
};
|
|
65
65
|
return /*#__PURE__*/jsxs("span", {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}) : children
|
|
76
|
-
}), /*#__PURE__*/jsx(ResponsivePanel, {
|
|
66
|
+
ref: anchorReference,
|
|
67
|
+
className: "np-popover d-inline-block",
|
|
68
|
+
children: [/*#__PURE__*/isValidElement(children) ? /*#__PURE__*/cloneElement(children, {
|
|
69
|
+
onClick: () => {
|
|
70
|
+
children.props.onClick?.();
|
|
71
|
+
setOpen(prevOpen => !prevOpen);
|
|
72
|
+
}
|
|
73
|
+
}) : children, /*#__PURE__*/jsx(ResponsivePanel, {
|
|
77
74
|
"aria-label": ariaLabel,
|
|
78
75
|
"aria-labelledby": title && !ariaLabel ? titleId : undefined,
|
|
79
76
|
open: open,
|
|
80
77
|
anchorRef: anchorReference,
|
|
81
78
|
position: resolvedPlacement,
|
|
82
79
|
arrow: true,
|
|
83
|
-
className:
|
|
80
|
+
className: clsx('np-popover__container', className),
|
|
84
81
|
onClose: handleOnClose,
|
|
85
82
|
children: /*#__PURE__*/jsxs("div", {
|
|
86
83
|
className: "np-popover__content np-text-default-body",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.mjs","sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { useRef, useState, cloneElement, useEffect, isValidElement, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport ResponsivePanel from '../common/responsivePanel';\nimport Title from '../title';\nimport { logActionRequired } from '../utilities';\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype PopoverPreferredPlacementDeprecated =\n | `${Position.LEFT_TOP}`\n | `${Position.RIGHT_TOP}`\n | `${Position.BOTTOM_RIGHT}`\n | `${Position.BOTTOM_LEFT}`;\n\nexport type PopoverPreferredPlacement =\n | `${Position.TOP}`\n | `${Position.RIGHT}`\n | `${Position.BOTTOM}`\n | `${Position.LEFT}`\n | PopoverPreferredPlacementDeprecated;\n\nexport interface PopoverProps {\n children?: React.ReactNode;\n title?: React.ReactNode;\n /** Screen-reader-friendly title. Must be provided if `title` prop is not set. */\n 'aria-label'?: string;\n /** @default 'right' */\n preferredPlacement?: PopoverPreferredPlacement;\n content: React.ReactNode;\n onClose?: () => void;\n className?: string;\n}\n\nfunction resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {\n switch (preferredPlacement) {\n case 'left-top':\n case 'right-top':\n return 'top';\n case 'bottom-left':\n case 'bottom-right':\n return 'bottom';\n default:\n return preferredPlacement;\n }\n}\n\nexport default function Popover({\n children,\n className,\n content,\n preferredPlacement = Position.RIGHT,\n title,\n onClose,\n 'aria-label': ariaLabel,\n}: PopoverProps) {\n const titleId = useId();\n\n const resolvedPlacement = resolvePlacement(preferredPlacement);\n useEffect(() => {\n if (resolvedPlacement !== preferredPlacement) {\n logActionRequired(\n `Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`,\n );\n }\n }, [preferredPlacement, resolvedPlacement]);\n\n const anchorReference = useRef(null);\n const [open, setOpen] = useState(false);\n\n const handleOnClose = () => {\n setOpen(false);\n onClose?.();\n };\n\n return (\n <span
|
|
1
|
+
{"version":3,"file":"Popover.mjs","sources":["../../src/popover/Popover.tsx"],"sourcesContent":["import { useTheme } from '@wise/components-theming';\nimport { clsx } from 'clsx';\nimport { useRef, useState, cloneElement, useEffect, isValidElement, useId } from 'react';\n\nimport { Position, Typography } from '../common';\nimport ResponsivePanel from '../common/responsivePanel';\nimport Title from '../title';\nimport { logActionRequired } from '../utilities';\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype PopoverPreferredPlacementDeprecated =\n | `${Position.LEFT_TOP}`\n | `${Position.RIGHT_TOP}`\n | `${Position.BOTTOM_RIGHT}`\n | `${Position.BOTTOM_LEFT}`;\n\nexport type PopoverPreferredPlacement =\n | `${Position.TOP}`\n | `${Position.RIGHT}`\n | `${Position.BOTTOM}`\n | `${Position.LEFT}`\n | PopoverPreferredPlacementDeprecated;\n\nexport interface PopoverProps {\n children?: React.ReactNode;\n title?: React.ReactNode;\n /** Screen-reader-friendly title. Must be provided if `title` prop is not set. */\n 'aria-label'?: string;\n /** @default 'right' */\n preferredPlacement?: PopoverPreferredPlacement;\n content: React.ReactNode;\n onClose?: () => void;\n className?: string;\n}\n\nfunction resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {\n switch (preferredPlacement) {\n case 'left-top':\n case 'right-top':\n return 'top';\n case 'bottom-left':\n case 'bottom-right':\n return 'bottom';\n default:\n return preferredPlacement;\n }\n}\n\nexport default function Popover({\n children,\n className,\n content,\n preferredPlacement = Position.RIGHT,\n title,\n onClose,\n 'aria-label': ariaLabel,\n}: PopoverProps) {\n const titleId = useId();\n\n const resolvedPlacement = resolvePlacement(preferredPlacement);\n useEffect(() => {\n if (resolvedPlacement !== preferredPlacement) {\n logActionRequired(\n `Popover has deprecated ${preferredPlacement} value for the 'preferredPlacement' prop. Please use ${resolvedPlacement} instead.`,\n );\n }\n }, [preferredPlacement, resolvedPlacement]);\n\n const anchorReference = useRef(null);\n const [open, setOpen] = useState(false);\n\n const handleOnClose = () => {\n setOpen(false);\n onClose?.();\n };\n\n return (\n <span ref={anchorReference} className=\"np-popover d-inline-block\">\n {isValidElement<{ onClick?: () => void }>(children)\n ? cloneElement(children, {\n onClick: () => {\n children.props.onClick?.();\n setOpen((prevOpen) => !prevOpen);\n },\n })\n : children}\n <ResponsivePanel\n aria-label={ariaLabel}\n aria-labelledby={title && !ariaLabel ? titleId : undefined}\n open={open}\n anchorRef={anchorReference}\n position={resolvedPlacement}\n arrow\n className={clsx('np-popover__container', className)}\n onClose={handleOnClose}\n >\n <div className=\"np-popover__content np-text-default-body\">\n {title && (\n <Title type={Typography.TITLE_BODY} id={titleId} className=\"m-b-1\">\n {title}\n </Title>\n )}\n {content}\n </div>\n </ResponsivePanel>\n </span>\n );\n}\n"],"names":["resolvePlacement","preferredPlacement","Popover","children","className","content","Position","RIGHT","title","onClose","ariaLabel","titleId","useId","resolvedPlacement","useEffect","logActionRequired","anchorReference","useRef","open","setOpen","useState","handleOnClose","_jsxs","ref","isValidElement","cloneElement","onClick","props","prevOpen","_jsx","ResponsivePanel","undefined","anchorRef","position","arrow","clsx","Title","type","Typography","TITLE_BODY","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAASA,gBAAgBA,CAACC,kBAA6C,EAAA;AACrE,EAAA,QAAQA,kBAAkB;AACxB,IAAA,KAAK,UAAU;AACf,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,KAAK;AACd,IAAA,KAAK,aAAa;AAClB,IAAA,KAAK,cAAc;AACjB,MAAA,OAAO,QAAQ;AACjB,IAAA;AACE,MAAA,OAAOA,kBAAkB;AAC7B;AACF;AAEc,SAAUC,OAAOA,CAAC;EAC9BC,Q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SAAS,GAAGC,OAAO,GAAGoB,SAAU;AAC3Db,MAAAA,IAAI,EAAEA,IAAK;AACXc,MAAAA,SAAS,EAAEhB,eAAgB;AAC3BiB,MAAAA,QAAQ,EAAEpB,iBAAkB;MAC5BqB,KAAK,EAAA,IAAA;AACL9B,MAAAA,SAAS,EAAE+B,IAAI,CAAC,uBAAuB,EAAE/B,SAAS,CAAE;AACpDK,MAAAA,OAAO,EAAEY,aAAc;AAAAlB,MAAAA,QAAA,eAEvBmB,IAAA,CAAA,KAAA,EAAA;AAAKlB,QAAAA,SAAS,EAAC,0CAA0C;AAAAD,QAAAA,QAAA,EAAA,CACtDK,KAAK,iBACJqB,GAAA,CAACO,KAAK,EAAA;UAACC,IAAI,EAAEC,UAAU,CAACC,UAAW;AAACC,UAAAA,EAAE,EAAE7B,OAAQ;AAACP,UAAAA,SAAS,EAAC,OAAO;AAAAD,UAAAA,QAAA,EAC/DK;SACI,CACR,EACAH,OAAO;OACL;AACP,KAAiB,CACnB;AAAA,GAAM,CAAC;AAEX;;;;"}
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
.np-field-control
|
|
1
|
+
.np-field-control,
|
|
2
|
+
.np-field__prompt {
|
|
2
3
|
margin-top: 4px;
|
|
3
4
|
margin-top: var(--size-4);
|
|
4
5
|
}
|
|
5
|
-
.np-field-validation {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: flex-start;
|
|
8
|
-
margin-top: 4px;
|
|
9
|
-
margin-top: var(--size-4);
|
|
10
|
-
gap: 8px;
|
|
11
|
-
gap: var(--size-8);
|
|
12
|
-
}
|
|
13
|
-
.np-field-textarea-char-counter {
|
|
14
|
-
min-width: 55px;
|
|
15
|
-
text-align: right;
|
|
16
|
-
margin-left: auto;
|
|
17
|
-
padding: 4px 0;
|
|
18
|
-
padding: var(--size-4) 0;
|
|
19
|
-
color: #768e9c;
|
|
20
|
-
color: var(--color-content-tertiary);
|
|
21
|
-
}
|
|
22
6
|
.np-field .form-group--typeahead[class],
|
|
23
7
|
.np-field .np-checkbox-label[class] {
|
|
24
8
|
margin-bottom: 0;
|
|
25
9
|
}
|
|
26
|
-
.np-field:has(.wds-radio-group) .np-
|
|
10
|
+
.np-field:has(.wds-radio-group) .np-field__prompt {
|
|
27
11
|
margin-top: 12px;
|
|
28
12
|
margin-top: var(--size-12);
|
|
29
13
|
}
|
package/build/styles/main.css
CHANGED
|
@@ -30194,36 +30194,18 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
30194
30194
|
stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
|
|
30195
30195
|
}
|
|
30196
30196
|
|
|
30197
|
-
.np-field-control
|
|
30197
|
+
.np-field-control,
|
|
30198
|
+
.np-field__prompt {
|
|
30198
30199
|
margin-top: 4px;
|
|
30199
30200
|
margin-top: var(--size-4);
|
|
30200
30201
|
}
|
|
30201
30202
|
|
|
30202
|
-
.np-field-validation {
|
|
30203
|
-
display: flex;
|
|
30204
|
-
align-items: flex-start;
|
|
30205
|
-
margin-top: 4px;
|
|
30206
|
-
margin-top: var(--size-4);
|
|
30207
|
-
gap: 8px;
|
|
30208
|
-
gap: var(--size-8);
|
|
30209
|
-
}
|
|
30210
|
-
|
|
30211
|
-
.np-field-textarea-char-counter {
|
|
30212
|
-
min-width: 55px;
|
|
30213
|
-
text-align: right;
|
|
30214
|
-
margin-left: auto;
|
|
30215
|
-
padding: 4px 0;
|
|
30216
|
-
padding: var(--size-4) 0;
|
|
30217
|
-
color: #768e9c;
|
|
30218
|
-
color: var(--color-content-tertiary);
|
|
30219
|
-
}
|
|
30220
|
-
|
|
30221
30203
|
.np-field .form-group--typeahead[class],
|
|
30222
30204
|
.np-field .np-checkbox-label[class] {
|
|
30223
30205
|
margin-bottom: 0;
|
|
30224
30206
|
}
|
|
30225
30207
|
|
|
30226
|
-
.np-field:has(.wds-radio-group) .np-
|
|
30208
|
+
.np-field:has(.wds-radio-group) .np-field__prompt {
|
|
30227
30209
|
margin-top: 12px;
|
|
30228
30210
|
margin-top: var(--size-12);
|
|
30229
30211
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/field/Field.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/field/Field.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AASjE,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,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kDAAkD;IAClD,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;SAGK;IACL,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,8EAA8E;IAC9E,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,iCAAiC;IACjC,SAAS,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,wJAanB,UAAU,gCA4EZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/inputs/TextArea.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,aAAc,SAAQ,KAAK,CAC1C,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,EACvC;IACE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CACF;CAAG;AAEJ,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/inputs/TextArea.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAIjC,MAAM,WAAW,aAAc,SAAQ,KAAK,CAC1C,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,EACvC;IACE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CACF;CAAG;AAEJ,eAAO,MAAM,QAAQ,mIAcnB,CAAC"}
|
|
@@ -17,12 +17,6 @@ export declare function useInputAttributes({ nonLabelable }?: UseInputAttributes
|
|
|
17
17
|
'aria-invalid': boolean | undefined;
|
|
18
18
|
};
|
|
19
19
|
export declare function useFieldLabelRef(): import("react").RefObject<HTMLLabelElement> | undefined;
|
|
20
|
-
export type TextareaCharacterCountState = {
|
|
21
|
-
current: number;
|
|
22
|
-
max: number;
|
|
23
|
-
} | null;
|
|
24
|
-
export declare const TextareaCharacterCountProvider: import("react").Provider<((state: TextareaCharacterCountState) => void) | undefined>;
|
|
25
|
-
export declare function useTextareaCharacterCount(current: number, max: number | undefined): void;
|
|
26
20
|
export interface WithInputAttributesProps {
|
|
27
21
|
inputAttributes: ReturnType<typeof useInputAttributes>;
|
|
28
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/inputs/contexts.tsx"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;CACzC,CAAC;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AC;;EAOrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/popover/Popover.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAc,MAAM,WAAW,CAAC;AAKjD,kDAAkD;AAClD,KAAK,mCAAmC,GACpC,GAAG,QAAQ,CAAC,QAAQ,EAAE,GACtB,GAAG,QAAQ,CAAC,SAAS,EAAE,GACvB,GAAG,QAAQ,CAAC,YAAY,EAAE,GAC1B,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAE9B,MAAM,MAAM,yBAAyB,GACjC,GAAG,QAAQ,CAAC,GAAG,EAAE,GACjB,GAAG,QAAQ,CAAC,KAAK,EAAE,GACnB,GAAG,QAAQ,CAAC,MAAM,EAAE,GACpB,GAAG,QAAQ,CAAC,IAAI,EAAE,GAClB,mCAAmC,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,iFAAiF;IACjF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,kBAAmC,EACnC,KAAK,EACL,OAAO,EACP,YAAY,EAAE,SAAS,GACxB,EAAE,YAAY,+
|
|
1
|
+
{"version":3,"file":"Popover.d.ts","sourceRoot":"","sources":["../../../src/popover/Popover.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAc,MAAM,WAAW,CAAC;AAKjD,kDAAkD;AAClD,KAAK,mCAAmC,GACpC,GAAG,QAAQ,CAAC,QAAQ,EAAE,GACtB,GAAG,QAAQ,CAAC,SAAS,EAAE,GACvB,GAAG,QAAQ,CAAC,YAAY,EAAE,GAC1B,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAE9B,MAAM,MAAM,yBAAyB,GACjC,GAAG,QAAQ,CAAC,GAAG,EAAE,GACjB,GAAG,QAAQ,CAAC,KAAK,EAAE,GACnB,GAAG,QAAQ,CAAC,MAAM,EAAE,GACpB,GAAG,QAAQ,CAAC,IAAI,EAAE,GAClB,mCAAmC,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,iFAAiF;IACjF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAeD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,kBAAmC,EACnC,KAAK,EACL,OAAO,EACP,YAAY,EAAE,SAAS,GACxB,EAAE,YAAY,+BAmDd"}
|
|
@@ -30,7 +30,6 @@ declare function customRender(ui: ReactElement, { locale, messages, ...renderOpt
|
|
|
30
30
|
"neptune.Expander.expandAriaLabel": string;
|
|
31
31
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": string;
|
|
32
32
|
"neptune.ExpressiveMoneyInput.currency.select.currency": string;
|
|
33
|
-
"neptune.Field.characterCount": string;
|
|
34
33
|
"neptune.FlowNavigation.back": string;
|
|
35
34
|
"neptune.Info.ariaLabel": string;
|
|
36
35
|
"neptune.Label.optional": string;
|
|
@@ -118,7 +117,6 @@ declare function customRenderHook(callback: () => unknown, { locale, messages }?
|
|
|
118
117
|
"neptune.Expander.expandAriaLabel": string;
|
|
119
118
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": string;
|
|
120
119
|
"neptune.ExpressiveMoneyInput.currency.select.currency": string;
|
|
121
|
-
"neptune.Field.characterCount": string;
|
|
122
120
|
"neptune.FlowNavigation.back": string;
|
|
123
121
|
"neptune.Info.ariaLabel": string;
|
|
124
122
|
"neptune.Label.optional": string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test-utils/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAM,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,MAAM,EAAc,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAMxD;;;;GAIG;AACH,iBAAS,YAAY,CACnB,EAAE,EAAE,YAAY,EAChB,EAAE,MAAuB,EAAE,QAAa,EAAE,GAAG,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,GAChE,UAAU,CAAC,OAAO,MAAM,CAAC,CAK3B;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CACvB,QAAQ,EAAE,MAAM,OAAO,EACvB,EAAE,MAAuB,EAAE,QAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAK,uEAKhD;AAED,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,gBAAgB,IAAI,UAAU,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/field/Field.css
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
.np-field-control
|
|
1
|
+
.np-field-control,
|
|
2
|
+
.np-field__prompt {
|
|
2
3
|
margin-top: 4px;
|
|
3
4
|
margin-top: var(--size-4);
|
|
4
5
|
}
|
|
5
|
-
.np-field-validation {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: flex-start;
|
|
8
|
-
margin-top: 4px;
|
|
9
|
-
margin-top: var(--size-4);
|
|
10
|
-
gap: 8px;
|
|
11
|
-
gap: var(--size-8);
|
|
12
|
-
}
|
|
13
|
-
.np-field-textarea-char-counter {
|
|
14
|
-
min-width: 55px;
|
|
15
|
-
text-align: right;
|
|
16
|
-
margin-left: auto;
|
|
17
|
-
padding: 4px 0;
|
|
18
|
-
padding: var(--size-4) 0;
|
|
19
|
-
color: #768e9c;
|
|
20
|
-
color: var(--color-content-tertiary);
|
|
21
|
-
}
|
|
22
6
|
.np-field .form-group--typeahead[class],
|
|
23
7
|
.np-field .np-checkbox-label[class] {
|
|
24
8
|
margin-bottom: 0;
|
|
25
9
|
}
|
|
26
|
-
.np-field:has(.wds-radio-group) .np-
|
|
10
|
+
.np-field:has(.wds-radio-group) .np-field__prompt {
|
|
27
11
|
margin-top: 12px;
|
|
28
12
|
margin-top: var(--size-12);
|
|
29
13
|
}
|
package/src/field/Field.less
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
.np-field {
|
|
2
|
-
&-control
|
|
2
|
+
&-control,
|
|
3
|
+
&__prompt {
|
|
3
4
|
margin-top: var(--size-4);
|
|
4
5
|
}
|
|
5
6
|
|
|
6
|
-
&-validation {
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: flex-start;
|
|
9
|
-
margin-top: var(--size-4);
|
|
10
|
-
gap: var(--size-8);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
&-textarea-char-counter {
|
|
14
|
-
min-width: 55px;
|
|
15
|
-
text-align: right;
|
|
16
|
-
margin-left: auto;
|
|
17
|
-
padding: var(--size-4) 0;
|
|
18
|
-
color: var(--color-content-tertiary);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
7
|
// @FIXME space between individual fields should be 24px, while some older inputs
|
|
22
8
|
// inject extraneous space.
|
|
23
9
|
.form-group--typeahead[class],
|
|
24
10
|
.np-checkbox-label[class] {
|
|
25
11
|
margin-bottom: 0;
|
|
26
12
|
}
|
|
27
|
-
&:has(.wds-radio-group)
|
|
13
|
+
&:has(.wds-radio-group) &__prompt {
|
|
28
14
|
margin-top: var(--size-12);
|
|
29
15
|
}
|
|
30
16
|
}
|
|
@@ -84,11 +84,7 @@ export const Basic = (args: FieldProps) => {
|
|
|
84
84
|
messageIconLabel={args.messageIconLabel}
|
|
85
85
|
messageLoading={args.messageLoading}
|
|
86
86
|
>
|
|
87
|
-
<TextArea
|
|
88
|
-
maxLength={200}
|
|
89
|
-
value={value}
|
|
90
|
-
onChange={({ target }) => setValue(target.value)}
|
|
91
|
-
/>
|
|
87
|
+
<TextArea />
|
|
92
88
|
</Field>
|
|
93
89
|
|
|
94
90
|
<Field
|
package/src/field/Field.test.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Info from '../info/Info';
|
|
2
2
|
import { Input } from '../inputs/Input';
|
|
3
|
-
import { TextArea } from '../inputs/TextArea';
|
|
4
3
|
import { mockMatchMedia, render, screen, userEvent } from '../test-utils';
|
|
5
4
|
|
|
6
5
|
import { Field } from './Field';
|
|
@@ -164,93 +163,4 @@ describe('Field', () => {
|
|
|
164
163
|
expect(screen.getByTestId('InlinePrompt_ProcessIndicator')).toBeInTheDocument();
|
|
165
164
|
expect(screen.getByText('Processing your request')).toBeInTheDocument();
|
|
166
165
|
});
|
|
167
|
-
|
|
168
|
-
describe('TextArea character count', () => {
|
|
169
|
-
it('renders counter when TextArea has maxLength', () => {
|
|
170
|
-
render(
|
|
171
|
-
<Field label="Message">
|
|
172
|
-
<TextArea maxLength={200} value="hello" onChange={() => {}} />
|
|
173
|
-
</Field>,
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
expect(screen.getByText('5/200')).toBeInTheDocument();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('does not render counter when TextArea has no maxLength', () => {
|
|
180
|
-
render(
|
|
181
|
-
<Field label="Message">
|
|
182
|
-
<TextArea value="hello" onChange={() => {}} />
|
|
183
|
-
</Field>,
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
expect(screen.queryByText(/\/\d+/)).not.toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('includes counter id in aria-describedby of the textarea', () => {
|
|
190
|
-
render(
|
|
191
|
-
<Field label="Message">
|
|
192
|
-
<TextArea maxLength={200} value="hello" onChange={() => {}} />
|
|
193
|
-
</Field>,
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
const textarea = screen.getByRole('textbox');
|
|
197
|
-
const counter = screen.getByText('5/200');
|
|
198
|
-
expect(textarea).toHaveAttribute('aria-describedby', expect.stringContaining(counter.id));
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('does not have role=status below 80% threshold', () => {
|
|
202
|
-
render(
|
|
203
|
-
<Field label="Message">
|
|
204
|
-
<TextArea maxLength={200} value="short" onChange={() => {}} />
|
|
205
|
-
</Field>,
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
const counter = screen.getByText('5/200');
|
|
209
|
-
expect(counter).not.toHaveAttribute('role');
|
|
210
|
-
expect(counter).not.toHaveAttribute('aria-live');
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('has role=status and aria-live=polite at 80% threshold', () => {
|
|
214
|
-
const value = 'x'.repeat(160);
|
|
215
|
-
render(
|
|
216
|
-
<Field label="Message">
|
|
217
|
-
<TextArea maxLength={200} value={value} onChange={() => {}} />
|
|
218
|
-
</Field>,
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
const counter = screen.getByText('160/200');
|
|
222
|
-
expect(counter).toHaveAttribute('role', 'status');
|
|
223
|
-
expect(counter).toHaveAttribute('aria-live', 'polite');
|
|
224
|
-
expect(counter).toHaveAttribute('aria-atomic', 'true');
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('updates counter when text changes', () => {
|
|
228
|
-
const { rerender } = render(
|
|
229
|
-
<Field label="Message">
|
|
230
|
-
<TextArea maxLength={200} value="hi" onChange={() => {}} />
|
|
231
|
-
</Field>,
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
expect(screen.getByText('2/200')).toBeInTheDocument();
|
|
235
|
-
|
|
236
|
-
rerender(
|
|
237
|
-
<Field label="Message">
|
|
238
|
-
<TextArea maxLength={200} value="hello world" onChange={() => {}} />
|
|
239
|
-
</Field>,
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
expect(screen.getByText('11/200')).toBeInTheDocument();
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('provides accessible aria-label on the counter', () => {
|
|
246
|
-
render(
|
|
247
|
-
<Field label="Message">
|
|
248
|
-
<TextArea maxLength={200} value="hello" onChange={() => {}} />
|
|
249
|
-
</Field>,
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
const counter = screen.getByText('5/200');
|
|
253
|
-
expect(counter).toHaveAttribute('aria-label', '5 of 200 characters used');
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
166
|
});
|