design-react-kit 5.0.0-5 → 5.0.0-7
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 +9 -0
- package/README.EN.md +39 -25
- package/README.md +39 -21
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +144 -64
- package/dist/esm/index.js.map +1 -1
- package/dist/types/Input/Input.d.ts +8 -2
- package/dist/types/Input/InputContainer.d.ts +1 -0
- package/dist/types/Input/utils.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +142 -61
- package/dist/types/index.js.map +1 -1
- package/package.json +8 -4
- package/src/Input/Input.tsx +100 -3
- package/src/Input/InputContainer.tsx +4 -2
- package/src/Input/TextArea.tsx +2 -1
- package/src/Input/utils.tsx +7 -0
- package/src/index.tsx +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { InputHTMLAttributes, ElementType, Ref, ReactNode } from 'react';
|
|
2
2
|
import type { CSSModule } from 'reactstrap/types/lib/utils';
|
|
3
|
-
declare type InputType = 'text' | 'email' | 'select' | 'file' | 'radio' | 'checkbox' | 'textarea' | 'button' | 'reset' | 'submit' | 'date' | 'datetime-local' | 'hidden' | 'image' | 'month' | 'number' | 'range' | 'search' | 'tel' | 'url' | 'week' | 'password' | 'datetime' | 'time' | 'color';
|
|
3
|
+
declare type InputType = 'text' | 'email' | 'select' | 'file' | 'radio' | 'checkbox' | 'textarea' | 'button' | 'reset' | 'submit' | 'date' | 'datetime-local' | 'hidden' | 'image' | 'month' | 'number' | 'range' | 'search' | 'tel' | 'url' | 'week' | 'password' | 'datetime' | 'time' | 'color' | 'adaptive' | 'currency' | 'percentage';
|
|
4
4
|
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
5
5
|
/** Il tipo specifico di input da utilizzare. Il valore di default è `text`. */
|
|
6
6
|
type?: InputType;
|
|
@@ -9,6 +9,10 @@ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
9
9
|
size?: number;
|
|
10
10
|
/** Etichetta del campo Input. */
|
|
11
11
|
label?: string | ReactNode;
|
|
12
|
+
/** Etichetta del pulsante incremento. */
|
|
13
|
+
incrementLabel?: string | ReactNode;
|
|
14
|
+
/** Etichetta del pulsante decremento. */
|
|
15
|
+
decrementLabel?: string | ReactNode;
|
|
12
16
|
/** Testo di esempio da utilizzare per il campo. */
|
|
13
17
|
placeholder?: string;
|
|
14
18
|
/** Testo di validazione per l'elemento del moduleo form. */
|
|
@@ -30,6 +34,8 @@ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
30
34
|
plaintext?: boolean;
|
|
31
35
|
/** Utilizzare per mostrare un elemento addon a fianco (prima o dopo) il campo input all'interno del componente */
|
|
32
36
|
addon?: boolean;
|
|
37
|
+
/** Utilizzare per mostrare un elemento un simbolo attivando la proprietà addon nel campo input all'interno del componente */
|
|
38
|
+
addonText?: string;
|
|
33
39
|
/** Oggetto contenente la nuova mappatura per le classi CSS. */
|
|
34
40
|
cssModule?: CSSModule;
|
|
35
41
|
/** Classi aggiuntive da usare per il wrapper del componente Input */
|
|
@@ -57,5 +63,5 @@ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
57
63
|
noWrapper?: boolean;
|
|
58
64
|
testId?: string;
|
|
59
65
|
}
|
|
60
|
-
export declare const Input: ({ id, className, cssModule, type, state, tag, addon, static: staticInput, plaintext, innerRef, label, validationText, infoText, placeholder, normalized, value, wrapperClass: originalWrapperClassOld, wrapperClassName: originalWrapperClass, size, testId, noWrapper, ...attributes }: InputProps) => React.JSX.Element;
|
|
66
|
+
export declare const Input: ({ id, className, cssModule, type, state, tag, addon, addonText, static: staticInput, plaintext, innerRef, label, incrementLabel, decrementLabel, validationText, infoText, placeholder, normalized, value, wrapperClass: originalWrapperClassOld, wrapperClassName: originalWrapperClass, size, testId, noWrapper, ...attributes }: InputProps) => React.JSX.Element;
|
|
61
67
|
export {};
|
|
@@ -2,6 +2,7 @@ import { FC, HTMLAttributes, ReactNode } from 'react';
|
|
|
2
2
|
export interface InputContainerProps extends HTMLAttributes<HTMLElement> {
|
|
3
3
|
wrapperClass: string;
|
|
4
4
|
activeClass: string;
|
|
5
|
+
extraLabelClass: string;
|
|
5
6
|
validationTextClass: string;
|
|
6
7
|
label: string | ReactNode | undefined;
|
|
7
8
|
validationText: string | undefined;
|
|
@@ -20,6 +20,7 @@ export declare function getClasses(className: string | undefined, type: string,
|
|
|
20
20
|
wrapperClass: string;
|
|
21
21
|
inputClasses: string;
|
|
22
22
|
activeClass: string;
|
|
23
|
+
extraLabelClass: string;
|
|
23
24
|
validationTextClass: string;
|
|
24
25
|
};
|
|
25
26
|
export declare function useFocus<T extends HTMLInputElement | HTMLTextAreaElement>({ onFocus, onBlur }: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { CardTagsHeader } from './Card/CardTagsHeader';
|
|
|
31
31
|
export { CardSignature } from './Card/CardSignature';
|
|
32
32
|
export { CardFooterCTA } from './Card/CardFooterCTA';
|
|
33
33
|
export { CardReadMore } from './Card/CardReadMore';
|
|
34
|
+
export { Collapse } from './Collapse/Collapse';
|
|
34
35
|
export { GridItem, GridItemText, GridItemTextWrapper, GridList, GridRow } from './Grid/index';
|
|
35
36
|
export { Header } from './Header/Header';
|
|
36
37
|
export { Headers } from './Header/Headers';
|
package/dist/types/index.js
CHANGED
|
@@ -1766,6 +1766,64 @@ const CardReadMore = _ref => {
|
|
|
1766
1766
|
}));
|
|
1767
1767
|
};
|
|
1768
1768
|
|
|
1769
|
+
const Collapse = _ref => {
|
|
1770
|
+
let {
|
|
1771
|
+
header = false,
|
|
1772
|
+
className,
|
|
1773
|
+
navbar,
|
|
1774
|
+
megamenu,
|
|
1775
|
+
children,
|
|
1776
|
+
isOpen = false,
|
|
1777
|
+
onOverlayClick,
|
|
1778
|
+
cssModule,
|
|
1779
|
+
testId,
|
|
1780
|
+
...attributes
|
|
1781
|
+
} = _ref;
|
|
1782
|
+
const newCssModule = {
|
|
1783
|
+
'navbar-collapse': 'navbar-collapsable',
|
|
1784
|
+
...cssModule
|
|
1785
|
+
};
|
|
1786
|
+
if (megamenu || navbar || header) {
|
|
1787
|
+
const classes = classNames(className, 'navbar-collapse', {
|
|
1788
|
+
expanded: isOpen
|
|
1789
|
+
});
|
|
1790
|
+
const style = {
|
|
1791
|
+
display: isOpen ? 'block' : 'none'
|
|
1792
|
+
};
|
|
1793
|
+
return React__default.createElement(reactstrap.Collapse, Object.assign({
|
|
1794
|
+
className: classes,
|
|
1795
|
+
cssModule: newCssModule,
|
|
1796
|
+
navbar: navbar,
|
|
1797
|
+
style: style,
|
|
1798
|
+
"data-testid": testId
|
|
1799
|
+
}, attributes), React__default.createElement("div", {
|
|
1800
|
+
className: 'overlay',
|
|
1801
|
+
style: style,
|
|
1802
|
+
onClick: onOverlayClick
|
|
1803
|
+
}), React__default.createElement("div", {
|
|
1804
|
+
className: 'close-div visually-hidden'
|
|
1805
|
+
}, React__default.createElement("button", {
|
|
1806
|
+
className: 'btn close-menu',
|
|
1807
|
+
type: 'button'
|
|
1808
|
+
}, React__default.createElement("span", {
|
|
1809
|
+
className: 'it-close'
|
|
1810
|
+
}), "close")), megamenu ? React__default.createElement("div", {
|
|
1811
|
+
className: 'menu-wrapper'
|
|
1812
|
+
}, children) : React__default.createElement(React__default.Fragment, null, children));
|
|
1813
|
+
}
|
|
1814
|
+
const classes = classNames(className, {
|
|
1815
|
+
'link-list-wrapper': header
|
|
1816
|
+
});
|
|
1817
|
+
return React__default.createElement(reactstrap.Collapse, Object.assign({
|
|
1818
|
+
className: classes,
|
|
1819
|
+
cssModule: newCssModule
|
|
1820
|
+
}, attributes, {
|
|
1821
|
+
navbar: navbar,
|
|
1822
|
+
isOpen: isOpen,
|
|
1823
|
+
"data-testid": testId
|
|
1824
|
+
}), children);
|
|
1825
|
+
};
|
|
1826
|
+
|
|
1769
1827
|
const GridItem = _ref => {
|
|
1770
1828
|
let {
|
|
1771
1829
|
tag: Tag = 'div',
|
|
@@ -2193,6 +2251,7 @@ const InputContainer = _ref => {
|
|
|
2193
2251
|
infoText,
|
|
2194
2252
|
testId,
|
|
2195
2253
|
activeClass,
|
|
2254
|
+
extraLabelClass,
|
|
2196
2255
|
label,
|
|
2197
2256
|
validationTextClass,
|
|
2198
2257
|
validationText,
|
|
@@ -2202,10 +2261,10 @@ const InputContainer = _ref => {
|
|
|
2202
2261
|
return React__default.createElement("div", {
|
|
2203
2262
|
className: wrapperClass,
|
|
2204
2263
|
"data-testid": testId
|
|
2205
|
-
},
|
|
2264
|
+
}, React__default.createElement("label", {
|
|
2206
2265
|
htmlFor: id,
|
|
2207
|
-
className: activeClass
|
|
2208
|
-
}, label), infoText && React__default.createElement("small", {
|
|
2266
|
+
className: activeClass + ' ' + extraLabelClass
|
|
2267
|
+
}, label), children, infoText && React__default.createElement("small", {
|
|
2209
2268
|
id: infoId,
|
|
2210
2269
|
className: 'form-text'
|
|
2211
2270
|
}, infoText), React__default.createElement("div", {
|
|
@@ -2305,10 +2364,14 @@ function getClasses(className, type, _ref4, cssModule) {
|
|
|
2305
2364
|
const activeClass = mapToCssModules(classNames({
|
|
2306
2365
|
active: isFocused || placeholder || value || ['date', 'time'].includes(type)
|
|
2307
2366
|
}), cssModule);
|
|
2367
|
+
const extraLabelClass = mapToCssModules(classNames({
|
|
2368
|
+
'input-number-label': ['number', 'currency', 'adaptive', 'percentage'].includes(type)
|
|
2369
|
+
}));
|
|
2308
2370
|
return {
|
|
2309
2371
|
wrapperClass,
|
|
2310
2372
|
inputClasses,
|
|
2311
2373
|
activeClass,
|
|
2374
|
+
extraLabelClass,
|
|
2312
2375
|
validationTextClass
|
|
2313
2376
|
};
|
|
2314
2377
|
}
|
|
@@ -2344,10 +2407,13 @@ const Input = _ref => {
|
|
|
2344
2407
|
state,
|
|
2345
2408
|
tag,
|
|
2346
2409
|
addon,
|
|
2410
|
+
addonText,
|
|
2347
2411
|
static: staticInput,
|
|
2348
2412
|
plaintext,
|
|
2349
2413
|
innerRef,
|
|
2350
2414
|
label,
|
|
2415
|
+
incrementLabel,
|
|
2416
|
+
decrementLabel,
|
|
2351
2417
|
validationText,
|
|
2352
2418
|
infoText,
|
|
2353
2419
|
placeholder,
|
|
@@ -2374,6 +2440,18 @@ const Input = _ref => {
|
|
|
2374
2440
|
setHidden(!isHidden);
|
|
2375
2441
|
toggleIcon(!hasIcon);
|
|
2376
2442
|
}, [hasIcon, isHidden]);
|
|
2443
|
+
const divResizeRef = React.useRef(null);
|
|
2444
|
+
const inputRef = React.useRef(null);
|
|
2445
|
+
const [width, setWidth] = React.useState('100');
|
|
2446
|
+
React.useEffect(() => {
|
|
2447
|
+
if (divResizeRef.current != null && divResizeRef.current.classList.contains('input-number-adaptive')) {
|
|
2448
|
+
if (!value) {
|
|
2449
|
+
setWidth(`calc(70px)`);
|
|
2450
|
+
} else {
|
|
2451
|
+
setWidth(`calc(70px + ${`${value}`.length}ch)`);
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}, [value]);
|
|
2377
2455
|
let {
|
|
2378
2456
|
bsSize,
|
|
2379
2457
|
valid,
|
|
@@ -2386,6 +2464,7 @@ const Input = _ref => {
|
|
|
2386
2464
|
staticInput,
|
|
2387
2465
|
type
|
|
2388
2466
|
});
|
|
2467
|
+
addon = addonText != null ? true : addon;
|
|
2389
2468
|
const formControlClass = getFormControlClass({
|
|
2390
2469
|
plaintext,
|
|
2391
2470
|
staticInput,
|
|
@@ -2425,6 +2504,7 @@ const Input = _ref => {
|
|
|
2425
2504
|
// Styling
|
|
2426
2505
|
const {
|
|
2427
2506
|
activeClass,
|
|
2507
|
+
extraLabelClass,
|
|
2428
2508
|
validationTextClass,
|
|
2429
2509
|
inputClasses,
|
|
2430
2510
|
wrapperClass
|
|
@@ -2457,6 +2537,7 @@ const Input = _ref => {
|
|
|
2457
2537
|
infoId,
|
|
2458
2538
|
infoText,
|
|
2459
2539
|
activeClass,
|
|
2540
|
+
extraLabelClass,
|
|
2460
2541
|
label,
|
|
2461
2542
|
validationTextClass,
|
|
2462
2543
|
validationText,
|
|
@@ -2470,6 +2551,61 @@ const Input = _ref => {
|
|
|
2470
2551
|
"data-testid": testId
|
|
2471
2552
|
}));
|
|
2472
2553
|
}
|
|
2554
|
+
const clickIncrDecr = mode => {
|
|
2555
|
+
var _inputRef$current, _inputRef$current2, _inputRef$current3, _inputRef$current4, _Object$getOwnPropert, _inputRef$current5;
|
|
2556
|
+
var step = parseFloat((_inputRef$current = inputRef.current) != null && _inputRef$current.step ? inputRef.current.step : '1');
|
|
2557
|
+
const min = parseFloat((_inputRef$current2 = inputRef.current) != null && _inputRef$current2.min ? inputRef.current.min : 'Nan');
|
|
2558
|
+
const max = parseFloat((_inputRef$current3 = inputRef.current) != null && _inputRef$current3.max ? inputRef.current.max : 'Nan');
|
|
2559
|
+
step = isNaN(step) ? 1 : step;
|
|
2560
|
+
const newValue = parseFloat((_inputRef$current4 = inputRef.current) != null && _inputRef$current4.value ? inputRef.current.value : '0') + mode * step;
|
|
2561
|
+
if (!isNaN(max) && newValue > max) {
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
if (!isNaN(min) && newValue < min) {
|
|
2565
|
+
return;
|
|
2566
|
+
}
|
|
2567
|
+
const nativeInputValueSetter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')) == null ? void 0 : _Object$getOwnPropert.set;
|
|
2568
|
+
nativeInputValueSetter == null ? void 0 : nativeInputValueSetter.call(inputRef.current, `${newValue}`);
|
|
2569
|
+
var ev2 = new Event('input', {
|
|
2570
|
+
bubbles: true
|
|
2571
|
+
});
|
|
2572
|
+
(_inputRef$current5 = inputRef.current) == null ? void 0 : _inputRef$current5.dispatchEvent(ev2);
|
|
2573
|
+
};
|
|
2574
|
+
if (['currency', 'percentage', 'adaptive', 'number'].includes(type)) {
|
|
2575
|
+
return React__default.createElement(InputContainer, Object.assign({}, containerProps), React__default.createElement("div", {
|
|
2576
|
+
className: classNames({
|
|
2577
|
+
'input-group': true,
|
|
2578
|
+
'input-number': true,
|
|
2579
|
+
disabled: rest.disabled,
|
|
2580
|
+
'input-number-percentage': type == 'percentage',
|
|
2581
|
+
'input-number-currency': type == 'currency',
|
|
2582
|
+
'input-number-adaptive': type == 'adaptive'
|
|
2583
|
+
}),
|
|
2584
|
+
style: {
|
|
2585
|
+
width
|
|
2586
|
+
},
|
|
2587
|
+
ref: divResizeRef
|
|
2588
|
+
}, ['currency', 'percentage'].includes(type) && React__default.createElement("span", {
|
|
2589
|
+
className: 'input-group-text fw-semibold'
|
|
2590
|
+
}, addonText), React__default.createElement(Tag, Object.assign({}, rest, extraAttributes, sharedAttributes, {
|
|
2591
|
+
className: inputClasses,
|
|
2592
|
+
"data-testid": testId,
|
|
2593
|
+
type: 'number',
|
|
2594
|
+
ref: inputRef
|
|
2595
|
+
})), React__default.createElement("span", {
|
|
2596
|
+
className: 'input-group-text align-buttons flex-column'
|
|
2597
|
+
}, React__default.createElement("button", {
|
|
2598
|
+
className: 'input-number-add',
|
|
2599
|
+
onClick: () => clickIncrDecr(1)
|
|
2600
|
+
}, React__default.createElement("span", {
|
|
2601
|
+
className: 'visually-hidden'
|
|
2602
|
+
}, incrementLabel || '')), React__default.createElement("button", {
|
|
2603
|
+
className: 'input-number-sub',
|
|
2604
|
+
onClick: () => clickIncrDecr(-1)
|
|
2605
|
+
}, React__default.createElement("span", {
|
|
2606
|
+
className: 'visually-hidden'
|
|
2607
|
+
}, decrementLabel || '')))));
|
|
2608
|
+
}
|
|
2473
2609
|
if (placeholder) {
|
|
2474
2610
|
return React__default.createElement(InputContainer, Object.assign({}, containerProps), React__default.createElement(Tag, Object.assign({}, rest, extraAttributes, sharedAttributes, {
|
|
2475
2611
|
className: inputClasses,
|
|
@@ -2559,6 +2695,7 @@ const TextArea = _ref => {
|
|
|
2559
2695
|
// Styling
|
|
2560
2696
|
const {
|
|
2561
2697
|
activeClass,
|
|
2698
|
+
extraLabelClass,
|
|
2562
2699
|
validationTextClass,
|
|
2563
2700
|
inputClasses,
|
|
2564
2701
|
wrapperClass
|
|
@@ -2588,6 +2725,7 @@ const TextArea = _ref => {
|
|
|
2588
2725
|
infoId,
|
|
2589
2726
|
infoText,
|
|
2590
2727
|
activeClass,
|
|
2728
|
+
extraLabelClass,
|
|
2591
2729
|
label,
|
|
2592
2730
|
validationTextClass,
|
|
2593
2731
|
validationText,
|
|
@@ -2739,64 +2877,6 @@ const LinkListItem = _ref => {
|
|
|
2739
2877
|
}, handlers), children));
|
|
2740
2878
|
};
|
|
2741
2879
|
|
|
2742
|
-
const Collapse = _ref => {
|
|
2743
|
-
let {
|
|
2744
|
-
header = false,
|
|
2745
|
-
className,
|
|
2746
|
-
navbar,
|
|
2747
|
-
megamenu,
|
|
2748
|
-
children,
|
|
2749
|
-
isOpen = false,
|
|
2750
|
-
onOverlayClick,
|
|
2751
|
-
cssModule,
|
|
2752
|
-
testId,
|
|
2753
|
-
...attributes
|
|
2754
|
-
} = _ref;
|
|
2755
|
-
const newCssModule = {
|
|
2756
|
-
'navbar-collapse': 'navbar-collapsable',
|
|
2757
|
-
...cssModule
|
|
2758
|
-
};
|
|
2759
|
-
if (megamenu || navbar || header) {
|
|
2760
|
-
const classes = classNames(className, 'navbar-collapse', {
|
|
2761
|
-
expanded: isOpen
|
|
2762
|
-
});
|
|
2763
|
-
const style = {
|
|
2764
|
-
display: isOpen ? 'block' : 'none'
|
|
2765
|
-
};
|
|
2766
|
-
return React__default.createElement(reactstrap.Collapse, Object.assign({
|
|
2767
|
-
className: classes,
|
|
2768
|
-
cssModule: newCssModule,
|
|
2769
|
-
navbar: navbar,
|
|
2770
|
-
style: style,
|
|
2771
|
-
"data-testid": testId
|
|
2772
|
-
}, attributes), React__default.createElement("div", {
|
|
2773
|
-
className: 'overlay',
|
|
2774
|
-
style: style,
|
|
2775
|
-
onClick: onOverlayClick
|
|
2776
|
-
}), React__default.createElement("div", {
|
|
2777
|
-
className: 'close-div visually-hidden'
|
|
2778
|
-
}, React__default.createElement("button", {
|
|
2779
|
-
className: 'btn close-menu',
|
|
2780
|
-
type: 'button'
|
|
2781
|
-
}, React__default.createElement("span", {
|
|
2782
|
-
className: 'it-close'
|
|
2783
|
-
}), "close")), megamenu ? React__default.createElement("div", {
|
|
2784
|
-
className: 'menu-wrapper'
|
|
2785
|
-
}, children) : React__default.createElement(React__default.Fragment, null, children));
|
|
2786
|
-
}
|
|
2787
|
-
const classes = classNames(className, {
|
|
2788
|
-
'link-list-wrapper': header
|
|
2789
|
-
});
|
|
2790
|
-
return React__default.createElement(reactstrap.Collapse, Object.assign({
|
|
2791
|
-
className: classes,
|
|
2792
|
-
cssModule: newCssModule
|
|
2793
|
-
}, attributes, {
|
|
2794
|
-
navbar: navbar,
|
|
2795
|
-
isOpen: isOpen,
|
|
2796
|
-
"data-testid": testId
|
|
2797
|
-
}), children);
|
|
2798
|
-
};
|
|
2799
|
-
|
|
2800
2880
|
const Nav = _ref => {
|
|
2801
2881
|
let {
|
|
2802
2882
|
className,
|
|
@@ -4496,6 +4576,7 @@ exports.CardText = CardText;
|
|
|
4496
4576
|
exports.CardTitle = CardTitle;
|
|
4497
4577
|
exports.Chip = Chip;
|
|
4498
4578
|
exports.ChipLabel = ChipLabel;
|
|
4579
|
+
exports.Collapse = Collapse;
|
|
4499
4580
|
exports.Dimmer = Dimmer;
|
|
4500
4581
|
exports.DimmerButtons = DimmerButtons;
|
|
4501
4582
|
exports.FontLoader = FontLoader;
|