@helpdice/ui 1.8.4 → 2.0.5
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/dist/CurrencyInput/components/CurrencyInput.d.ts +4 -0
- package/dist/CurrencyInput/components/CurrencyInputProps.d.ts +160 -0
- package/dist/CurrencyInput/components/utils/cleanValue.d.ts +8 -0
- package/dist/CurrencyInput/components/utils/escapeRegExp.d.ts +6 -0
- package/dist/CurrencyInput/components/utils/fixedDecimalValue.d.ts +1 -0
- package/dist/CurrencyInput/components/utils/formatValue.d.ts +49 -0
- package/dist/CurrencyInput/components/utils/getLocaleConfig.d.ts +13 -0
- package/dist/CurrencyInput/components/utils/getSuffix.d.ts +6 -0
- package/dist/CurrencyInput/components/utils/index.d.ts +8 -0
- package/dist/CurrencyInput/components/utils/isNumber.d.ts +1 -0
- package/dist/CurrencyInput/components/utils/padTrimValue.d.ts +1 -0
- package/dist/CurrencyInput/components/utils/parseAbbrValue.d.ts +10 -0
- package/dist/CurrencyInput/components/utils/removeInvalidChars.d.ts +4 -0
- package/dist/CurrencyInput/components/utils/removeSeparators.d.ts +4 -0
- package/dist/CurrencyInput/components/utils/repositionCursor.d.ts +16 -0
- package/dist/CurrencyInput/index.d.ts +5 -0
- package/dist/CurrencyInput/index.js +3 -2122
- package/dist/ITooltip/index.d.ts +13 -0
- package/dist/Loadable/index.js +29 -3
- package/dist/PhoneInput/index.js +21 -2140
- package/dist/Placeholder/index.js +5 -2124
- package/dist/auto-complete/index.js +73 -12092
- package/dist/avatar/index.js +15 -2134
- package/dist/badge/index.js +8 -2127
- package/dist/breadcrumbs/index.js +19 -2138
- package/dist/button/index.js +36 -2229
- package/dist/button-dropdown/index.js +28 -2147
- package/dist/button-group/index.js +9 -2128
- package/dist/capacity/index.js +10 -2129
- package/dist/card/index.js +46 -2165
- package/dist/carousal/index.js +644 -12666
- package/dist/checkbox/index.js +10 -2129
- package/dist/code/index.js +14 -2133
- package/dist/collapse/index.js +16 -2135
- package/dist/description/index.js +9 -2128
- package/dist/display/index.js +11 -2130
- package/dist/divider/index.js +12 -2131
- package/dist/dot/index.js +6 -2125
- package/dist/drawer/index.js +21 -2139
- package/dist/fieldset/index.js +22 -2141
- package/dist/grid/index.js +8 -2127
- package/dist/image/index.js +31 -2150
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2065 -23539
- package/dist/input/index.js +42 -2158
- package/dist/keyboard/index.js +11 -2130
- package/dist/link/index.js +11 -2130
- package/dist/list/index.js +25 -2143
- package/dist/list/list-item.d.ts +1 -0
- package/dist/loading/index.js +14 -2133
- package/dist/menu/index.js +2 -10245
- package/dist/modal/index.js +59 -2177
- package/dist/note/index.js +10 -2129
- package/dist/page/index.js +6 -2125
- package/dist/pagination/index.js +11 -2130
- package/dist/popover/index.js +23 -2141
- package/dist/progress/index.js +10 -2129
- package/dist/radio/index.js +17 -2136
- package/dist/rating/index.js +7 -2126
- package/dist/row/index.js +5 -2124
- package/dist/select/index.js +54 -2173
- package/dist/slider/index.js +21 -2140
- package/dist/snippet/index.js +12 -2131
- package/dist/spacer/index.js +2 -2121
- package/dist/spinner/index.js +5 -2124
- package/dist/table/index.js +910 -12918
- package/dist/tabs/index.js +16 -2135
- package/dist/tag/index.js +5 -2124
- package/dist/text/index.js +5 -2124
- package/dist/textarea/index.js +10 -2129
- package/dist/toggle/index.js +14 -2133
- package/dist/tooltip/index.js +17 -2135
- package/dist/tree/index.js +39 -2158
- package/dist/use-input/index.js +2 -2122
- package/dist/use-modal/index.js +2 -2122
- package/dist/use-scale/index.js +2 -2121
- package/dist/use-tabs/index.js +2 -2122
- package/dist/user/index.js +31 -2150
- package/esm/CurrencyInput/components/CurrencyInput.d.ts +4 -0
- package/esm/CurrencyInput/components/CurrencyInputProps.d.ts +160 -0
- package/esm/CurrencyInput/components/utils/cleanValue.d.ts +8 -0
- package/esm/CurrencyInput/components/utils/escapeRegExp.d.ts +6 -0
- package/esm/CurrencyInput/components/utils/fixedDecimalValue.d.ts +1 -0
- package/esm/CurrencyInput/components/utils/formatValue.d.ts +49 -0
- package/esm/CurrencyInput/components/utils/getLocaleConfig.d.ts +13 -0
- package/esm/CurrencyInput/components/utils/getSuffix.d.ts +6 -0
- package/esm/CurrencyInput/components/utils/index.d.ts +8 -0
- package/esm/CurrencyInput/components/utils/isNumber.d.ts +1 -0
- package/esm/CurrencyInput/components/utils/padTrimValue.d.ts +1 -0
- package/esm/CurrencyInput/components/utils/parseAbbrValue.d.ts +10 -0
- package/esm/CurrencyInput/components/utils/removeInvalidChars.d.ts +4 -0
- package/esm/CurrencyInput/components/utils/removeSeparators.d.ts +4 -0
- package/esm/CurrencyInput/components/utils/repositionCursor.d.ts +16 -0
- package/esm/CurrencyInput/index.d.ts +5 -0
- package/esm/ITooltip/index.d.ts +13 -0
- package/esm/ITooltip/index.js +97 -0
- package/esm/Loadable/loader.js +13 -0
- package/esm/button/button.compact.js +13 -86
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -1
- package/esm/input/input.js +13 -10
- package/esm/link/link.js +3 -3
- package/esm/list/list-item.d.ts +1 -0
- package/esm/list/list-item.js +4 -2
- package/esm/login-with/LoginSocialAmazon/index.js +1 -1
- package/esm/login-with/LoginSocialApple/index.js +1 -1
- package/esm/login-with/LoginSocialFacebook/index.js +1 -1
- package/esm/login-with/LoginSocialGoogle/index.js +1 -1
- package/esm/table/table-body.js +14 -4
- package/esm/table/table-cell.js +1 -1
- package/esm/table/table-head.js +13 -13
- package/esm/table/table.js +8 -8
- package/package.json +5 -5
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
3
|
+
/**
|
|
4
|
+
* Value in different formats
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export type CurrencyInputOnChangeValues = {
|
|
9
|
+
/**
|
|
10
|
+
* Value as float or null if empty
|
|
11
|
+
*
|
|
12
|
+
* Example:
|
|
13
|
+
* "1.99" > 1.99
|
|
14
|
+
* "" > null
|
|
15
|
+
*/
|
|
16
|
+
float: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Value after applying formatting
|
|
19
|
+
*
|
|
20
|
+
* Example: "1000000" > "1,000,0000"
|
|
21
|
+
*/
|
|
22
|
+
formatted: string;
|
|
23
|
+
/**
|
|
24
|
+
* Non formatted value as string
|
|
25
|
+
*/
|
|
26
|
+
value: string;
|
|
27
|
+
};
|
|
28
|
+
export type IntlConfig = {
|
|
29
|
+
locale: string;
|
|
30
|
+
currency?: string;
|
|
31
|
+
};
|
|
32
|
+
export type CurrencyInputProps = Overwrite<React.ComponentPropsWithRef<'input'>, {
|
|
33
|
+
/**
|
|
34
|
+
* Allow decimals
|
|
35
|
+
*
|
|
36
|
+
* Default = true
|
|
37
|
+
*/
|
|
38
|
+
allowDecimals?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Allow user to enter negative value
|
|
41
|
+
*
|
|
42
|
+
* Default = true
|
|
43
|
+
*/
|
|
44
|
+
allowNegativeValue?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Component id
|
|
47
|
+
*/
|
|
48
|
+
id?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum characters the user can enter
|
|
51
|
+
*/
|
|
52
|
+
maxLength?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Class names
|
|
55
|
+
*/
|
|
56
|
+
className?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Custom component
|
|
59
|
+
*
|
|
60
|
+
* Default = <input/>
|
|
61
|
+
*/
|
|
62
|
+
customInput?: ElementType;
|
|
63
|
+
/**
|
|
64
|
+
* Limit length of decimals allowed
|
|
65
|
+
*
|
|
66
|
+
* Default = 2
|
|
67
|
+
*/
|
|
68
|
+
decimalsLimit?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Specify decimal scale for padding/trimming
|
|
71
|
+
*
|
|
72
|
+
* Example:
|
|
73
|
+
* 1.5 -> 1.50
|
|
74
|
+
* 1.234 -> 1.23
|
|
75
|
+
*/
|
|
76
|
+
decimalScale?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Default value if not passing in value via props
|
|
79
|
+
*/
|
|
80
|
+
defaultValue?: number | string;
|
|
81
|
+
/**
|
|
82
|
+
* Disabled
|
|
83
|
+
*
|
|
84
|
+
* Default = false
|
|
85
|
+
*/
|
|
86
|
+
disabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Value will always have the specified length of decimals
|
|
89
|
+
*
|
|
90
|
+
* Example:
|
|
91
|
+
* 123 -> 1.23
|
|
92
|
+
*
|
|
93
|
+
* Note: This formatting only happens onBlur
|
|
94
|
+
*/
|
|
95
|
+
fixedDecimalLength?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Handle change in value
|
|
98
|
+
*/
|
|
99
|
+
onValueChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Placeholder if there is no value
|
|
102
|
+
*/
|
|
103
|
+
placeholder?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Include a prefix eg. £
|
|
106
|
+
*/
|
|
107
|
+
prefix?: string;
|
|
108
|
+
/**
|
|
109
|
+
* Include a suffix eg. €
|
|
110
|
+
*/
|
|
111
|
+
suffix?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Incremental value change on arrow down and arrow up key press
|
|
114
|
+
*/
|
|
115
|
+
step?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Separator between integer part and fractional part of value.
|
|
118
|
+
*
|
|
119
|
+
* This cannot be a number
|
|
120
|
+
*/
|
|
121
|
+
decimalSeparator?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Separator between thousand, million and billion
|
|
124
|
+
*
|
|
125
|
+
* This cannot be a number
|
|
126
|
+
*/
|
|
127
|
+
groupSeparator?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Disable auto adding separator between values eg. 1000 -> 1,000
|
|
130
|
+
*
|
|
131
|
+
* Default = false
|
|
132
|
+
*/
|
|
133
|
+
disableGroupSeparators?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Disable abbreviations (m, k, b)
|
|
136
|
+
*
|
|
137
|
+
* Default = false
|
|
138
|
+
*/
|
|
139
|
+
disableAbbreviations?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* International locale config, examples:
|
|
142
|
+
* { locale: 'ja-JP', currency: 'JPY' }
|
|
143
|
+
* { locale: 'en-IN', currency: 'INR' }
|
|
144
|
+
*
|
|
145
|
+
* Any prefix, groupSeparator or decimalSeparator options passed in
|
|
146
|
+
* will override Intl Locale config
|
|
147
|
+
*/
|
|
148
|
+
intlConfig?: IntlConfig;
|
|
149
|
+
/**
|
|
150
|
+
* Transform the raw value form the input before parsing
|
|
151
|
+
*/
|
|
152
|
+
transformRawValue?: (rawValue: string) => string;
|
|
153
|
+
/**
|
|
154
|
+
* When set to false, the formatValueOnBlur flag disables the application of the __onValueChange__ function
|
|
155
|
+
* specifically on blur events. If disabled or set to false, the onValueChange will not trigger on blur.
|
|
156
|
+
* Default = true
|
|
157
|
+
*/
|
|
158
|
+
formatValueOnBlur?: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CurrencyInputProps } from '../CurrencyInputProps';
|
|
2
|
+
export type CleanValueOptions = Pick<CurrencyInputProps, 'decimalSeparator' | 'groupSeparator' | 'allowDecimals' | 'decimalsLimit' | 'allowNegativeValue' | 'disableAbbreviations' | 'prefix' | 'transformRawValue'> & {
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Remove prefix, separators and extra decimals from value
|
|
7
|
+
*/
|
|
8
|
+
export declare const cleanValue: ({ value, groupSeparator, decimalSeparator, allowDecimals, decimalsLimit, allowNegativeValue, disableAbbreviations, prefix, transformRawValue }: CleanValueOptions) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fixedDecimalValue: (value: string, decimalSeparator: string, fixedDecimalLength?: number) => string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IntlConfig } from '../CurrencyInputProps';
|
|
2
|
+
export type FormatValueOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Value to format
|
|
5
|
+
*/
|
|
6
|
+
value: string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Decimal separator
|
|
9
|
+
*
|
|
10
|
+
* Default = '.'
|
|
11
|
+
*/
|
|
12
|
+
decimalSeparator?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Group separator
|
|
15
|
+
*
|
|
16
|
+
* Default = ','
|
|
17
|
+
*/
|
|
18
|
+
groupSeparator?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Turn off separators
|
|
21
|
+
*
|
|
22
|
+
* This will override Group separators
|
|
23
|
+
*
|
|
24
|
+
* Default = false
|
|
25
|
+
*/
|
|
26
|
+
disableGroupSeparators?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Intl locale currency config
|
|
29
|
+
*/
|
|
30
|
+
intlConfig?: IntlConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Specify decimal scale for padding/trimming
|
|
33
|
+
*
|
|
34
|
+
* Eg. 1.5 -> 1.50 or 1.234 -> 1.23
|
|
35
|
+
*/
|
|
36
|
+
decimalScale?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Prefix
|
|
39
|
+
*/
|
|
40
|
+
prefix?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Suffix
|
|
43
|
+
*/
|
|
44
|
+
suffix?: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Format value with decimal separator, group separator and prefix
|
|
48
|
+
*/
|
|
49
|
+
export declare const formatValue: (options: FormatValueOptions) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IntlConfig } from '../CurrencyInputProps';
|
|
2
|
+
type LocaleConfig = {
|
|
3
|
+
currencySymbol: string;
|
|
4
|
+
groupSeparator: string;
|
|
5
|
+
decimalSeparator: string;
|
|
6
|
+
prefix: string;
|
|
7
|
+
suffix: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Get locale config from input or default
|
|
11
|
+
*/
|
|
12
|
+
export declare const getLocaleConfig: (intlConfig?: IntlConfig) => LocaleConfig;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './cleanValue';
|
|
2
|
+
export * from './fixedDecimalValue';
|
|
3
|
+
export * from './formatValue';
|
|
4
|
+
export * from './getLocaleConfig';
|
|
5
|
+
export * from './getSuffix';
|
|
6
|
+
export * from './isNumber';
|
|
7
|
+
export * from './padTrimValue';
|
|
8
|
+
export * from './repositionCursor';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isNumber: (input: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const padTrimValue: (value: string, decimalSeparator?: string, decimalScale?: number) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abbreviate number eg. 1000 = 1k
|
|
3
|
+
*
|
|
4
|
+
* Source: https://stackoverflow.com/a/9345181
|
|
5
|
+
*/
|
|
6
|
+
export declare const abbrValue: (value: number, decimalSeparator?: string, _decimalPlaces?: number) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Parse a value with abbreviation e.g 1k = 1000
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseAbbrValue: (value: string, decimalSeparator?: string) => number | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type RepositionCursorProps = {
|
|
2
|
+
selectionStart?: number | null;
|
|
3
|
+
value: string;
|
|
4
|
+
lastKeyStroke: string | null;
|
|
5
|
+
stateValue?: string;
|
|
6
|
+
groupSeparator?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Based on the last key stroke and the cursor position, update the value
|
|
10
|
+
* and reposition the cursor to the right place
|
|
11
|
+
*/
|
|
12
|
+
export declare const repositionCursor: ({ selectionStart, value, lastKeyStroke, stateValue, groupSeparator }: RepositionCursorProps) => {
|
|
13
|
+
modifiedValue: string;
|
|
14
|
+
cursorPosition: number | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import CurrencyInput from './components/CurrencyInput';
|
|
2
|
+
export type { CurrencyInputProps, CurrencyInputOnChangeValues } from './components/CurrencyInputProps';
|
|
3
|
+
export { formatValue } from './components/utils/formatValue';
|
|
4
|
+
export { cleanValue } from './components/utils/cleanValue';
|
|
5
|
+
export default CurrencyInput;
|