design-react-kit 5.10.0 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/Accordion/AccordionBody.cjs +1 -1
- package/dist/Accordion/AccordionBody.cjs.map +1 -1
- package/dist/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/Autocomplete/Autocomplete.cjs.map +1 -1
- package/dist/Autocomplete/Autocomplete.js +45 -6
- package/dist/Autocomplete/Autocomplete.js.map +1 -1
- package/dist/Input/Input.cjs +1 -1
- package/dist/Input/Input.cjs.map +1 -1
- package/dist/Input/Input.js +15 -5
- package/dist/Input/Input.js.map +1 -1
- package/dist/Input/InputContainer.cjs +1 -1
- package/dist/Input/InputContainer.cjs.map +1 -1
- package/dist/Input/InputContainer.js +3 -3
- package/dist/Input/InputContainer.js.map +1 -1
- package/dist/Input/TextArea.cjs +1 -1
- package/dist/Input/TextArea.cjs.map +1 -1
- package/dist/Input/TextArea.js +12 -4
- package/dist/Input/TextArea.js.map +1 -1
- package/dist/Input/utils.cjs +1 -1
- package/dist/Input/utils.cjs.map +1 -1
- package/dist/Modal/ModalHeader.cjs.map +1 -1
- package/dist/NavScroll/index.cjs +1 -1
- package/dist/NavScroll/index.cjs.map +1 -1
- package/dist/NavScroll/useNavScroll.cjs +1 -1
- package/dist/NavScroll/useNavScroll.cjs.map +1 -1
- package/dist/Progress/Progress.cjs +1 -1
- package/dist/Progress/Progress.cjs.map +1 -1
- package/dist/Rating/Rating.cjs +1 -1
- package/dist/Rating/Rating.cjs.map +1 -1
- package/dist/Section/Section.cjs +1 -1
- package/dist/Section/Section.cjs.map +1 -1
- package/dist/Transfer/Item.cjs +1 -1
- package/dist/Transfer/Item.cjs.map +1 -1
- package/dist/Transfer/SelectAllCheckbox.cjs +1 -1
- package/dist/Transfer/SelectAllCheckbox.cjs.map +1 -1
- package/dist/Transfer/Source.cjs +1 -1
- package/dist/Transfer/Source.cjs.map +1 -1
- package/dist/Transfer/Target.cjs +1 -1
- package/dist/Transfer/Target.cjs.map +1 -1
- package/dist/Transfer/Transfer.cjs +1 -1
- package/dist/Transfer/Transfer.cjs.map +1 -1
- package/dist/Upload/UploadListItem.cjs +1 -1
- package/dist/Upload/UploadListItem.cjs.map +1 -1
- package/dist/Video/Video.cjs +1 -1
- package/dist/Video/Video.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/types/Autocomplete/Autocomplete.d.ts +7 -1
- package/dist/types/Input/InputContainer.d.ts +1 -0
- package/dist/types/utils.d.ts +5 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -1
- package/package.json +4 -5
- package/src/Autocomplete/Autocomplete.tsx +62 -7
- package/src/Input/Input.tsx +18 -5
- package/src/Input/InputContainer.tsx +8 -2
- package/src/Input/TextArea.tsx +13 -5
- package/src/utils.tsx +11 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
export interface AutocompleteAttributes {
|
|
3
3
|
/** Identificativo */
|
|
4
4
|
id: string;
|
|
5
5
|
/** Label */
|
|
6
6
|
label: string;
|
|
7
|
+
/** Minimo di caratteri per attivare l'autocomplete */
|
|
8
|
+
minLength?: number;
|
|
7
9
|
/** Valori all'interno della select */
|
|
8
10
|
source: (query: string, syncResults: () => void) => void;
|
|
9
11
|
/** Valori chiave - valore all'interno della select */
|
|
@@ -32,6 +34,10 @@ export interface AutocompleteAttributes {
|
|
|
32
34
|
tStatusResults?: () => string;
|
|
33
35
|
/** Classi aggiuntive da usare per il componente Button */
|
|
34
36
|
className?: string;
|
|
37
|
+
/** ID dei contenuti che descrivono il campo. */
|
|
38
|
+
'aria-describedby'?: string;
|
|
39
|
+
/** Stato di non validità fornito dal consumer. */
|
|
40
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
35
41
|
testId?: string;
|
|
36
42
|
}
|
|
37
43
|
export declare const Autocomplete: FC<AutocompleteAttributes>;
|
|
@@ -6,6 +6,7 @@ export interface InputContainerProps extends HTMLAttributes<HTMLElement> {
|
|
|
6
6
|
validationTextClass: string;
|
|
7
7
|
label: string | ReactNode | undefined;
|
|
8
8
|
validationText: string | undefined;
|
|
9
|
+
errorId?: string;
|
|
9
10
|
id: string | undefined;
|
|
10
11
|
infoId: string | undefined;
|
|
11
12
|
infoText: string | undefined;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export declare const notifyDeprecation: (message: string, options?: {
|
|
|
5
5
|
once: boolean;
|
|
6
6
|
}) => void;
|
|
7
7
|
export declare function mapToCssModules(className: string | null, cssModules?: Record<string, string>): string;
|
|
8
|
+
/**
|
|
9
|
+
* Combines ID reference lists for `aria-describedby` without losing a
|
|
10
|
+
* description that was already supplied by the consumer.
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeAriaDescribedBy(...descriptions: Array<string | undefined | null>): string | undefined;
|
|
8
13
|
type UnknownObject = Record<string, unknown>;
|
|
9
14
|
export declare function pick<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T>;
|
|
10
15
|
export declare function omit<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T>;
|
package/dist/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var u=(n,o)=>{for(var r in o)s(n,r,{get:o[r],enumerable:!0})},p=(n,o,r,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of l(o))!a.call(n,t)&&t!==r&&s(n,t,{get:()=>o[t],enumerable:!(e=f(o,t))||e.enumerable});return n};var y=n=>p(s({},"__esModule",{value:!0}),n);var b={};u(b,{flushMessageCache:()=>T,logError:()=>c,mapToCssModules:()=>k,mergeAriaDescribedBy:()=>x,noop:()=>d,notifyDeprecation:()=>g,omit:()=>w,pick:()=>A});module.exports=y(b);var d=()=>{},c=n=>{typeof console<"u"&&(console.error?console.error(n):console.log(n))},T=()=>{for(let n in i)delete i[n]},i={},g=(n,o={once:!0})=>{o.once?i[n]||(c(n),i[n]=1):c(n)};function k(n,o){let r=n??"";return o?r.split(" ").map(e=>o[e]??e).join(" "):r}function x(...n){let o=n.flatMap(e=>e?.trim().split(/\s+/)??[]),r=[...new Set(o.filter(Boolean))];return r.length>0?r.join(" "):void 0}function A(n,o){let r=Array.isArray(o)?o:[o],e={};for(let t of r)t in n&&(e[t]=n[t]);return e}function w(n,o){let r=new Set(Array.isArray(o)?o:[o]),e={};for(let t in n)r.has(t)||(e[t]=n[t]);return e}0&&(module.exports={flushMessageCache,logError,mapToCssModules,mergeAriaDescribedBy,noop,notifyDeprecation,omit,pick});
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.tsx"],"sourcesContent":["export const noop = () => {};\n\nexport const logError = (message: string) => {\n if (typeof console !== 'undefined') {\n if (console.error) {\n console.error(message);\n } else {\n console.log(message);\n }\n }\n};\n\n// @internal Used for testing purposes only\nexport const flushMessageCache = () => {\n for (const key in messages) {\n delete messages[key];\n }\n};\n\nconst messages: Record<string, 1> = {};\nexport const notifyDeprecation = (message: string, options: { once: boolean } = { once: true }) => {\n if (!options.once) {\n logError(message);\n } else {\n if (!messages[message]) {\n logError(message);\n messages[message] = 1;\n }\n }\n};\n\nexport function mapToCssModules(className: string | null, cssModules?: Record<string, string>) {\n const finalClassNames = className == null ? '' : className;\n if (!cssModules) {\n return finalClassNames;\n }\n return finalClassNames\n .split(' ')\n .map((klass) => cssModules[klass] ?? klass)\n .join(' ');\n}\n\ntype UnknownObject = Record<string, unknown>;\n\nexport function pick<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T> {\n const keysArray = Array.isArray(keys) ? keys : [keys];\n const newObj: Partial<T> = {};\n for (const key of keysArray) {\n if (key in obj) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nexport function omit<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T> {\n const keysLookup = new Set(Array.isArray(keys) ? keys : [keys]);\n\n const newObj: Partial<T> = {};\n for (const key in obj) {\n if (!keysLookup.has(key)) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,aAAAC,EAAA,oBAAAC,EAAA,SAAAC,EAAA,sBAAAC,EAAA,SAAAC,EAAA,SAAAC,IAAA,eAAAC,
|
|
1
|
+
{"version":3,"sources":["../src/utils.tsx"],"sourcesContent":["export const noop = () => {};\n\nexport const logError = (message: string) => {\n if (typeof console !== 'undefined') {\n if (console.error) {\n console.error(message);\n } else {\n console.log(message);\n }\n }\n};\n\n// @internal Used for testing purposes only\nexport const flushMessageCache = () => {\n for (const key in messages) {\n delete messages[key];\n }\n};\n\nconst messages: Record<string, 1> = {};\nexport const notifyDeprecation = (message: string, options: { once: boolean } = { once: true }) => {\n if (!options.once) {\n logError(message);\n } else {\n if (!messages[message]) {\n logError(message);\n messages[message] = 1;\n }\n }\n};\n\nexport function mapToCssModules(className: string | null, cssModules?: Record<string, string>) {\n const finalClassNames = className == null ? '' : className;\n if (!cssModules) {\n return finalClassNames;\n }\n return finalClassNames\n .split(' ')\n .map((klass) => cssModules[klass] ?? klass)\n .join(' ');\n}\n\n/**\n * Combines ID reference lists for `aria-describedby` without losing a\n * description that was already supplied by the consumer.\n */\nexport function mergeAriaDescribedBy(...descriptions: Array<string | undefined | null>) {\n const ids = descriptions.flatMap((description) => description?.trim().split(/\\s+/) ?? []);\n const uniqueIds = [...new Set(ids.filter(Boolean))];\n\n return uniqueIds.length > 0 ? uniqueIds.join(' ') : undefined;\n}\n\ntype UnknownObject = Record<string, unknown>;\n\nexport function pick<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T> {\n const keysArray = Array.isArray(keys) ? keys : [keys];\n const newObj: Partial<T> = {};\n for (const key of keysArray) {\n if (key in obj) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n\nexport function omit<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T> {\n const keysLookup = new Set(Array.isArray(keys) ? keys : [keys]);\n\n const newObj: Partial<T> = {};\n for (const key in obj) {\n if (!keysLookup.has(key)) {\n newObj[key] = obj[key];\n }\n }\n return newObj;\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,uBAAAE,EAAA,aAAAC,EAAA,oBAAAC,EAAA,yBAAAC,EAAA,SAAAC,EAAA,sBAAAC,EAAA,SAAAC,EAAA,SAAAC,IAAA,eAAAC,EAAAV,GAAO,IAAMM,EAAO,IAAM,CAAC,EAEdH,EAAYQ,GAAoB,CACvC,OAAO,QAAY,MACjB,QAAQ,MACV,QAAQ,MAAMA,CAAO,EAErB,QAAQ,IAAIA,CAAO,EAGzB,EAGaT,EAAoB,IAAM,CACrC,QAAWU,KAAOC,EAChB,OAAOA,EAASD,CAAG,CAEvB,EAEMC,EAA8B,CAAC,EACxBN,EAAoB,CAACI,EAAiBG,EAA6B,CAAE,KAAM,EAAK,IAAM,CAC5FA,EAAQ,KAGND,EAASF,CAAO,IACnBR,EAASQ,CAAO,EAChBE,EAASF,CAAO,EAAI,GAJtBR,EAASQ,CAAO,CAOpB,EAEO,SAASP,EAAgBW,EAA0BC,EAAqC,CAC7F,IAAMC,EAAkBF,GAAoB,GAC5C,OAAKC,EAGEC,EACJ,MAAM,GAAG,EACT,IAAKC,GAAUF,EAAWE,CAAK,GAAKA,CAAK,EACzC,KAAK,GAAG,EALFD,CAMX,CAMO,SAASZ,KAAwBc,EAAgD,CACtF,IAAMC,EAAMD,EAAa,QAASE,GAAgBA,GAAa,KAAK,EAAE,MAAM,KAAK,GAAK,CAAC,CAAC,EAClFC,EAAY,CAAC,GAAG,IAAI,IAAIF,EAAI,OAAO,OAAO,CAAC,CAAC,EAElD,OAAOE,EAAU,OAAS,EAAIA,EAAU,KAAK,GAAG,EAAI,MACtD,CAIO,SAASb,EAA8Bc,EAAQC,EAA4C,CAChG,IAAMC,EAAY,MAAM,QAAQD,CAAI,EAAIA,EAAO,CAACA,CAAI,EAC9CE,EAAqB,CAAC,EAC5B,QAAWd,KAAOa,EACZb,KAAOW,IACTG,EAAOd,CAAG,EAAIW,EAAIX,CAAG,GAGzB,OAAOc,CACT,CAEO,SAASlB,EAA8Be,EAAQC,EAA4C,CAChG,IAAMG,EAAa,IAAI,IAAI,MAAM,QAAQH,CAAI,EAAIA,EAAO,CAACA,CAAI,CAAC,EAExDE,EAAqB,CAAC,EAC5B,QAAWd,KAAOW,EACXI,EAAW,IAAIf,CAAG,IACrBc,EAAOd,CAAG,EAAIW,EAAIX,CAAG,GAGzB,OAAOc,CACT","names":["utils_exports","__export","flushMessageCache","logError","mapToCssModules","mergeAriaDescribedBy","noop","notifyDeprecation","omit","pick","__toCommonJS","message","key","messages","options","className","cssModules","finalClassNames","klass","descriptions","ids","description","uniqueIds","obj","keys","keysArray","newObj","keysLookup"]}
|
package/dist/utils.js
CHANGED
|
@@ -37,6 +37,15 @@ export function mapToCssModules(className, cssModules) {
|
|
|
37
37
|
.map((klass) => cssModules[klass] ?? klass)
|
|
38
38
|
.join(' ');
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Combines ID reference lists for `aria-describedby` without losing a
|
|
42
|
+
* description that was already supplied by the consumer.
|
|
43
|
+
*/
|
|
44
|
+
export function mergeAriaDescribedBy(...descriptions) {
|
|
45
|
+
const ids = descriptions.flatMap((description) => description?.trim().split(/\s+/) ?? []);
|
|
46
|
+
const uniqueIds = [...new Set(ids.filter(Boolean))];
|
|
47
|
+
return uniqueIds.length > 0 ? uniqueIds.join(' ') : undefined;
|
|
48
|
+
}
|
|
40
49
|
export function pick(obj, keys) {
|
|
41
50
|
const keysArray = Array.isArray(keys) ? keys : [keys];
|
|
42
51
|
const newObj = {};
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE7B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAe,EAAE,EAAE;IAC1C,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACnC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,2CAA2C;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAsB,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAE,UAA6B,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;IAChG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,OAAO,CAAC,CAAC;YAClB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACxB,CAA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AC;AAChB,CAAC;AAED,MAAM,UAAU,IAAI,CAA0B,GAAM,EAAE,IAA8B;IAClF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhE,MAAM,MAAM,GAAe,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/italia/design-react-kit/issues"
|
|
27
27
|
},
|
|
28
|
-
"version": "5.
|
|
28
|
+
"version": "5.11.0",
|
|
29
29
|
"license": "BSD-3",
|
|
30
30
|
"type": "module",
|
|
31
31
|
"module": "./dist/index.js",
|
|
@@ -67,12 +67,11 @@
|
|
|
67
67
|
"storybook:serve": "storybook dev -p 9001",
|
|
68
68
|
"storybook:build": "storybook build --docs",
|
|
69
69
|
"storybook:build:base": "storybook build",
|
|
70
|
-
"storybook:deploy": "npx gh-pages -d storybook-static -m 'chore: update documentation [ci skip]' --nojekyll",
|
|
71
70
|
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && node scripts/wait-confirm && git add CHANGELOG.md",
|
|
72
71
|
"postversion": "echo \"You can now publish your version using 'git push --follow-tags'\""
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
75
|
-
"bootstrap-italia": "^2.18.
|
|
74
|
+
"bootstrap-italia": "^2.18.3",
|
|
76
75
|
"react": ">=18.2.0"
|
|
77
76
|
},
|
|
78
77
|
"browserslist": [
|
|
@@ -105,7 +104,7 @@
|
|
|
105
104
|
"@types/react-dom": "^18.2.24",
|
|
106
105
|
"@types/react-transition-group": "^4.4.10",
|
|
107
106
|
"@types/uuid": "^10.0.0",
|
|
108
|
-
"bootstrap-italia": "^2.18.
|
|
107
|
+
"bootstrap-italia": "^2.18.3",
|
|
109
108
|
"browserslist-config-design-italia": "^1.0.0",
|
|
110
109
|
"conventional-changelog": "^7.1.1",
|
|
111
110
|
"eslint": "^9.10.0",
|
|
@@ -132,7 +131,7 @@
|
|
|
132
131
|
"typeface-roboto-mono": "^1.1.13",
|
|
133
132
|
"typescript": "^5.4.5",
|
|
134
133
|
"typescript-eslint": "^8.4.0",
|
|
135
|
-
"vite": "^
|
|
134
|
+
"vite": "^6.4.2"
|
|
136
135
|
},
|
|
137
136
|
"dependencies": {
|
|
138
137
|
"@splidejs/react-splide": "^0.7.12",
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React, { FC, useEffect } from 'react';
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
3
|
// @ts-ignore non ci sono i types
|
|
4
|
-
import
|
|
4
|
+
import AccessibleAutocomplete from 'accessible-autocomplete/react';
|
|
5
|
+
import { mergeAriaDescribedBy } from '../utils';
|
|
6
|
+
|
|
7
|
+
// accessible-autocomplete/react è un bundle UMD: alcuni bundler (es. Vite 8 con Rolldown) restituiscono
|
|
8
|
+
// l'oggetto del modulo invece del componente, quindi si prende `default` quando c'è
|
|
9
|
+
const BaseAutocomplete = AccessibleAutocomplete.default ?? AccessibleAutocomplete;
|
|
5
10
|
// Reference to https://www.npmjs.com/package/accessible-autocomplete
|
|
6
11
|
// Implementation example: https://github.com/alphagov/accessible-autocomplete/blob/main/examples/react/index.html
|
|
7
12
|
|
|
@@ -10,6 +15,8 @@ export interface AutocompleteAttributes {
|
|
|
10
15
|
id: string;
|
|
11
16
|
/** Label */
|
|
12
17
|
label: string;
|
|
18
|
+
/** Minimo di caratteri per attivare l'autocomplete */
|
|
19
|
+
minLength?: number;
|
|
13
20
|
/** Valori all'interno della select */
|
|
14
21
|
source: (query: string, syncResults: () => void) => void;
|
|
15
22
|
/** Valori chiave - valore all'interno della select */
|
|
@@ -38,6 +45,10 @@ export interface AutocompleteAttributes {
|
|
|
38
45
|
tStatusResults?: () => string;
|
|
39
46
|
/** Classi aggiuntive da usare per il componente Button */
|
|
40
47
|
className?: string;
|
|
48
|
+
/** ID dei contenuti che descrivono il campo. */
|
|
49
|
+
'aria-describedby'?: string;
|
|
50
|
+
/** Stato di non validità fornito dal consumer. */
|
|
51
|
+
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
41
52
|
testId?: string;
|
|
42
53
|
}
|
|
43
54
|
|
|
@@ -60,6 +71,8 @@ const tStatusResultsDefault = (length: number, contentSelectedOption: number) =>
|
|
|
60
71
|
};
|
|
61
72
|
|
|
62
73
|
export const Autocomplete: FC<AutocompleteAttributes> = ({
|
|
74
|
+
id,
|
|
75
|
+
label,
|
|
63
76
|
tAssistiveHint = tAssistiveHintDefault,
|
|
64
77
|
tNoResults = tNoResultsDefault,
|
|
65
78
|
tStatusQueryTooShort = tStatusQueryTooShortDefault,
|
|
@@ -68,14 +81,17 @@ export const Autocomplete: FC<AutocompleteAttributes> = ({
|
|
|
68
81
|
tStatusResults = tStatusResultsDefault,
|
|
69
82
|
placeholder = '',
|
|
70
83
|
defaultValue = '',
|
|
84
|
+
minLength = 0,
|
|
71
85
|
displayMenu = 'inline',
|
|
72
86
|
source,
|
|
73
87
|
validationText,
|
|
74
88
|
onConfirm,
|
|
75
|
-
|
|
89
|
+
valid,
|
|
90
|
+
'aria-describedby': ariaDescribedBy,
|
|
91
|
+
'aria-invalid': ariaInvalid
|
|
76
92
|
}) => {
|
|
77
|
-
const { id, valid } = attributes;
|
|
78
93
|
const validityCheck = valid === true || valid === false;
|
|
94
|
+
const errorId = valid === false ? `${id}-error` : undefined;
|
|
79
95
|
|
|
80
96
|
useEffect(() => {
|
|
81
97
|
const inputElement: HTMLInputElement = document.getElementById(id) as HTMLInputElement;
|
|
@@ -98,17 +114,57 @@ export const Autocomplete: FC<AutocompleteAttributes> = ({
|
|
|
98
114
|
});
|
|
99
115
|
}, [id]);
|
|
100
116
|
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const inputElement: HTMLInputElement = document.getElementById(id) as HTMLInputElement;
|
|
119
|
+
if (!inputElement) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const updateAccessibilityAttributes = () => {
|
|
124
|
+
const existingDescription = inputElement.getAttribute('aria-describedby');
|
|
125
|
+
const descriptionsWithoutError = existingDescription
|
|
126
|
+
?.split(/\s+/)
|
|
127
|
+
.filter((description) => description !== `${id}-error`)
|
|
128
|
+
.join(' ');
|
|
129
|
+
const describedBy = mergeAriaDescribedBy(ariaDescribedBy, descriptionsWithoutError, errorId);
|
|
130
|
+
|
|
131
|
+
if (describedBy && existingDescription !== describedBy) {
|
|
132
|
+
inputElement.setAttribute('aria-describedby', describedBy);
|
|
133
|
+
}
|
|
134
|
+
if (!describedBy && existingDescription) {
|
|
135
|
+
inputElement.removeAttribute('aria-describedby');
|
|
136
|
+
}
|
|
137
|
+
if (valid === false) {
|
|
138
|
+
inputElement.setAttribute('aria-invalid', 'true');
|
|
139
|
+
} else if (ariaInvalid !== undefined) {
|
|
140
|
+
inputElement.setAttribute('aria-invalid', String(ariaInvalid));
|
|
141
|
+
} else {
|
|
142
|
+
inputElement.removeAttribute('aria-invalid');
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
updateAccessibilityAttributes();
|
|
147
|
+
const observer = new MutationObserver(updateAccessibilityAttributes);
|
|
148
|
+
observer.observe(inputElement, { attributes: true, attributeFilter: ['aria-describedby'] });
|
|
149
|
+
|
|
150
|
+
return () => {
|
|
151
|
+
observer.disconnect();
|
|
152
|
+
};
|
|
153
|
+
}, [ariaDescribedBy, ariaInvalid, errorId, id, valid]);
|
|
154
|
+
|
|
101
155
|
return (
|
|
102
156
|
<>
|
|
103
|
-
<label htmlFor={
|
|
157
|
+
<label htmlFor={id}>{label}</label>
|
|
104
158
|
<BaseAutocomplete
|
|
159
|
+
id={id}
|
|
105
160
|
source={source}
|
|
106
161
|
placeholder={placeholder}
|
|
107
162
|
defaultValue={defaultValue}
|
|
163
|
+
minLength={minLength}
|
|
108
164
|
displayMenu={displayMenu}
|
|
109
165
|
tAssistiveHint={tAssistiveHint}
|
|
110
166
|
tNoResults={tNoResults}
|
|
111
|
-
tStatusQueryTooShort={tStatusQueryTooShort}
|
|
167
|
+
tStatusQueryTooShort={() => tStatusQueryTooShort(minLength)}
|
|
112
168
|
tStatusNoResults={tStatusNoResults}
|
|
113
169
|
tStatusSelectedOption={tStatusSelectedOption}
|
|
114
170
|
tStatusResults={tStatusResults}
|
|
@@ -122,9 +178,8 @@ export const Autocomplete: FC<AutocompleteAttributes> = ({
|
|
|
122
178
|
confirmOnBlur={false}
|
|
123
179
|
menuAttributes={null}
|
|
124
180
|
menuClasses={null}
|
|
125
|
-
{...attributes}
|
|
126
181
|
/>
|
|
127
|
-
<div className='form-feedback just-validate-error-label form-text form-feedback just-validate-error-label'>
|
|
182
|
+
<div id={errorId} className='form-feedback just-validate-error-label form-text form-feedback just-validate-error-label'>
|
|
128
183
|
{!valid && validationText}
|
|
129
184
|
</div>
|
|
130
185
|
</>
|
package/src/Input/Input.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import React, {
|
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
import type { CSSModule } from 'reactstrap/types/lib/utils';
|
|
14
14
|
import { Icon } from '../Icon/Icon';
|
|
15
|
-
import { notifyDeprecation } from '../utils';
|
|
15
|
+
import { mergeAriaDescribedBy, notifyDeprecation } from '../utils';
|
|
16
16
|
import { InputContainer } from './InputContainer';
|
|
17
17
|
import { getClasses, getFormControlClass, getTag, getValidationTextControlClass, useFocus } from './utils';
|
|
18
18
|
|
|
@@ -172,6 +172,7 @@ export const Input = ({
|
|
|
172
172
|
type?: InputType;
|
|
173
173
|
size?: number;
|
|
174
174
|
['aria-describedby']?: string;
|
|
175
|
+
['aria-invalid']?: true;
|
|
175
176
|
} = {};
|
|
176
177
|
if (size && !isNumber(size)) {
|
|
177
178
|
notifyDeprecation('Please use the prop "bsSize" instead of the "size" to bootstrap\'s input sizing.');
|
|
@@ -184,11 +185,8 @@ export const Input = ({
|
|
|
184
185
|
extraAttributes.type = type;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
//
|
|
188
|
+
// Associate the input field with the help text and, when present, the error message.
|
|
188
189
|
const infoId = id && infoText ? `${id}Description` : undefined;
|
|
189
|
-
if (infoId) {
|
|
190
|
-
extraAttributes['aria-describedby'] = infoId;
|
|
191
|
-
}
|
|
192
190
|
|
|
193
191
|
if (
|
|
194
192
|
attributes.children &&
|
|
@@ -203,6 +201,20 @@ export const Input = ({
|
|
|
203
201
|
const inputPassword = extraAttributes.type === 'password';
|
|
204
202
|
|
|
205
203
|
const indeterminateCheckboxInput = type === 'checkbox' && className?.includes('semi-checked');
|
|
204
|
+
const rendersContainer =
|
|
205
|
+
!noWrapper &&
|
|
206
|
+
!indeterminateCheckboxInput &&
|
|
207
|
+
(['currency', 'percentage', 'adaptive', 'number'].includes(type) ||
|
|
208
|
+
Boolean(placeholder || inputPassword || normalized || label || validationText));
|
|
209
|
+
const errorId = id && valid === false && rendersContainer ? `${id}-error` : undefined;
|
|
210
|
+
const describedBy = mergeAriaDescribedBy(rest['aria-describedby'], infoId, errorId);
|
|
211
|
+
|
|
212
|
+
if (describedBy) {
|
|
213
|
+
extraAttributes['aria-describedby'] = describedBy;
|
|
214
|
+
}
|
|
215
|
+
if (valid === false) {
|
|
216
|
+
extraAttributes['aria-invalid'] = true;
|
|
217
|
+
}
|
|
206
218
|
|
|
207
219
|
// Styling
|
|
208
220
|
const { activeClass, extraLabelClass, validationTextClass, inputClasses, wrapperClass } = getClasses(
|
|
@@ -244,6 +256,7 @@ export const Input = ({
|
|
|
244
256
|
label,
|
|
245
257
|
validationTextClass,
|
|
246
258
|
validationText,
|
|
259
|
+
errorId,
|
|
247
260
|
wrapperClass,
|
|
248
261
|
hasButtonRight,
|
|
249
262
|
buttonRight,
|
|
@@ -7,6 +7,7 @@ export interface InputContainerProps extends HTMLAttributes<HTMLElement> {
|
|
|
7
7
|
validationTextClass: string;
|
|
8
8
|
label: string | ReactNode | undefined;
|
|
9
9
|
validationText: string | undefined;
|
|
10
|
+
errorId?: string;
|
|
10
11
|
id: string | undefined;
|
|
11
12
|
infoId: string | undefined;
|
|
12
13
|
infoText: string | undefined;
|
|
@@ -31,6 +32,7 @@ export const InputContainer: FC<InputContainerProps> = ({
|
|
|
31
32
|
label,
|
|
32
33
|
validationTextClass,
|
|
33
34
|
validationText,
|
|
35
|
+
errorId,
|
|
34
36
|
wrapperClass,
|
|
35
37
|
hasButtonRight,
|
|
36
38
|
buttonRight,
|
|
@@ -52,7 +54,9 @@ export const InputContainer: FC<InputContainerProps> = ({
|
|
|
52
54
|
{infoText}
|
|
53
55
|
</small>
|
|
54
56
|
)}
|
|
55
|
-
<div className={validationTextClass}>
|
|
57
|
+
<div id={errorId} className={validationTextClass}>
|
|
58
|
+
{validationText}
|
|
59
|
+
</div>
|
|
56
60
|
{hasButtonRight && <div className='input-group-append'>{buttonRight}</div>}
|
|
57
61
|
</div>
|
|
58
62
|
</div>
|
|
@@ -69,7 +73,9 @@ export const InputContainer: FC<InputContainerProps> = ({
|
|
|
69
73
|
{infoText}
|
|
70
74
|
</small>
|
|
71
75
|
)}
|
|
72
|
-
<div className={validationTextClass}>
|
|
76
|
+
<div id={errorId} className={validationTextClass}>
|
|
77
|
+
{validationText}
|
|
78
|
+
</div>
|
|
73
79
|
</div>
|
|
74
80
|
);
|
|
75
81
|
};
|
package/src/Input/TextArea.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode, Ref, TextareaHTMLAttributes } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { CSSModule } from 'reactstrap/types/lib/utils';
|
|
4
|
+
import { mergeAriaDescribedBy } from '../utils';
|
|
4
5
|
import { InputContainer } from './InputContainer';
|
|
5
6
|
import { getClasses, getFormControlClass, getValidationTextControlClass, useFocus } from './utils';
|
|
6
7
|
|
|
@@ -54,14 +55,20 @@ export const TextArea = ({
|
|
|
54
55
|
|
|
55
56
|
const validationTextControlClass = getValidationTextControlClass({ valid }, cssModule);
|
|
56
57
|
|
|
57
|
-
const extraAttributes: { ['aria-describedby']?: string } = {};
|
|
58
|
+
const extraAttributes: { ['aria-describedby']?: string; ['aria-invalid']?: true } = {};
|
|
58
59
|
|
|
59
60
|
//Chiamo questa funzione per impostare classNames a 'form-control'
|
|
60
61
|
const formControlClass = getFormControlClass({}, cssModule);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const rendersContainer = Boolean(placeholder || normalized || label || validationText);
|
|
63
|
+
// Associate the input field with the help text and, when present, the error message.
|
|
64
|
+
const infoId = id && infoText ? `${id}Description` : undefined;
|
|
65
|
+
const errorId = id && valid === false && rendersContainer ? `${id}-error` : undefined;
|
|
66
|
+
const describedBy = mergeAriaDescribedBy(attributes['aria-describedby'], infoId, errorId);
|
|
67
|
+
if (describedBy) {
|
|
68
|
+
extraAttributes['aria-describedby'] = describedBy;
|
|
69
|
+
}
|
|
70
|
+
if (valid === false) {
|
|
71
|
+
extraAttributes['aria-invalid'] = true;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
74
|
// Styling
|
|
@@ -102,6 +109,7 @@ export const TextArea = ({
|
|
|
102
109
|
label,
|
|
103
110
|
validationTextClass,
|
|
104
111
|
validationText,
|
|
112
|
+
errorId,
|
|
105
113
|
wrapperClass
|
|
106
114
|
};
|
|
107
115
|
|
package/src/utils.tsx
CHANGED
|
@@ -40,6 +40,17 @@ export function mapToCssModules(className: string | null, cssModules?: Record<st
|
|
|
40
40
|
.join(' ');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Combines ID reference lists for `aria-describedby` without losing a
|
|
45
|
+
* description that was already supplied by the consumer.
|
|
46
|
+
*/
|
|
47
|
+
export function mergeAriaDescribedBy(...descriptions: Array<string | undefined | null>) {
|
|
48
|
+
const ids = descriptions.flatMap((description) => description?.trim().split(/\s+/) ?? []);
|
|
49
|
+
const uniqueIds = [...new Set(ids.filter(Boolean))];
|
|
50
|
+
|
|
51
|
+
return uniqueIds.length > 0 ? uniqueIds.join(' ') : undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
type UnknownObject = Record<string, unknown>;
|
|
44
55
|
|
|
45
56
|
export function pick<T extends UnknownObject>(obj: T, keys: keyof T | Array<keyof T>): Partial<T> {
|