intelicoreact 0.0.96 → 0.0.97

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.
Files changed (155) hide show
  1. package/dist/Atomic/FormElements/Input/Input.js +3 -1
  2. package/dist/Atomic/FormElements/Input/Input.stories.js +5 -1
  3. package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +4 -4
  4. package/dist/Atomic/FormElements/Spinner/Spinner.js +21 -0
  5. package/{src/Atomic/FormElements/Dropdown/components/DropdownLoader.scss → dist/Atomic/FormElements/Spinner/Spinner.scss} +8 -5
  6. package/dist/Atomic/FormElements/Spinner/Spinner.stories.js +34 -0
  7. package/dist/Functions/inputExecutor.js +7 -1
  8. package/package.json +3 -2
  9. package/.babelrc +0 -12
  10. package/.eslintignore +0 -10
  11. package/.eslintrc.json +0 -93
  12. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.js +0 -28
  13. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +0 -107
  14. package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +0 -26
  15. package/src/Atomic/FormElements/DateTime/DateTime.js +0 -18
  16. package/src/Atomic/FormElements/DateTime/DateTime.scss +0 -12
  17. package/src/Atomic/FormElements/DateTime/DateTime.stories.js +0 -17
  18. package/src/Atomic/FormElements/DoubleString/DoubleString.js +0 -13
  19. package/src/Atomic/FormElements/DoubleString/DoubleString.scss +0 -20
  20. package/src/Atomic/FormElements/DoubleString/DoubleString.stories.js +0 -18
  21. package/src/Atomic/FormElements/Dropdown/Dropdown.js +0 -178
  22. package/src/Atomic/FormElements/Dropdown/Dropdown.scss +0 -192
  23. package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +0 -87
  24. package/src/Atomic/FormElements/Dropdown/components/DropdownLoader.js +0 -17
  25. package/src/Atomic/FormElements/Header/Header.js +0 -67
  26. package/src/Atomic/FormElements/Header/Header.scss +0 -93
  27. package/src/Atomic/FormElements/Header/Header.stories.js +0 -30
  28. package/src/Atomic/FormElements/Input/Input.js +0 -186
  29. package/src/Atomic/FormElements/Input/Input.scss +0 -136
  30. package/src/Atomic/FormElements/Input/Input.stories.js +0 -94
  31. package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +0 -104
  32. package/src/Atomic/FormElements/InputCalendar/InputCalendar.scss +0 -23
  33. package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +0 -39
  34. package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +0 -254
  35. package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +0 -624
  36. package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +0 -65
  37. package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +0 -432
  38. package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +0 -126
  39. package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +0 -24
  40. package/src/Atomic/FormElements/InputDateRange/dependencies.js +0 -161
  41. package/src/Atomic/FormElements/InputsRow/InputsRow.js +0 -112
  42. package/src/Atomic/FormElements/InputsRow/InputsRow.scss +0 -45
  43. package/src/Atomic/FormElements/InputsRow/InputsRow.stories.js +0 -34
  44. package/src/Atomic/FormElements/Label/Label.js +0 -13
  45. package/src/Atomic/FormElements/Label/Label.scss +0 -20
  46. package/src/Atomic/FormElements/Label/Label.stories.js +0 -23
  47. package/src/Atomic/FormElements/MobileCalendar/MobileCalendar.js +0 -315
  48. package/src/Atomic/FormElements/MobileCalendar/MobileCalendar.scss +0 -120
  49. package/src/Atomic/FormElements/MobileCalendar/MobileCalendar.stories.js +0 -30
  50. package/src/Atomic/FormElements/Modal/Modal.js +0 -69
  51. package/src/Atomic/FormElements/Modal/Modal.scss +0 -230
  52. package/src/Atomic/FormElements/Modal/Modal.stories.js +0 -116
  53. package/src/Atomic/FormElements/MultiSelect/MultiSelect.js +0 -39
  54. package/src/Atomic/FormElements/MultiSelect/MultiSelect.scss +0 -16
  55. package/src/Atomic/FormElements/MultiSelect/MultiSelect.stories.js +0 -28
  56. package/src/Atomic/FormElements/NavLine/NavLine.js +0 -67
  57. package/src/Atomic/FormElements/NavLine/NavLine.scss +0 -108
  58. package/src/Atomic/FormElements/NavLine/NavLine.stories.js +0 -108
  59. package/src/Atomic/FormElements/NumericInput/NumericInput.js +0 -263
  60. package/src/Atomic/FormElements/NumericInput/NumericInput.scss +0 -135
  61. package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +0 -78
  62. package/src/Atomic/FormElements/RadioInput/RadioInput.js +0 -28
  63. package/src/Atomic/FormElements/RadioInput/RadioInput.scss +0 -63
  64. package/src/Atomic/FormElements/RadioInput/RadioInput.stories.js +0 -23
  65. package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +0 -152
  66. package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +0 -101
  67. package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +0 -54
  68. package/src/Atomic/FormElements/RangeInputs/RangeInputs.js +0 -41
  69. package/src/Atomic/FormElements/RangeInputs/RangeInputs.scss +0 -20
  70. package/src/Atomic/FormElements/RangeInputs/RangeInputs.stories.js +0 -23
  71. package/src/Atomic/FormElements/Switcher/Switcher.js +0 -24
  72. package/src/Atomic/FormElements/Switcher/Switcher.scss +0 -56
  73. package/src/Atomic/FormElements/Switcher/Switcher.stories.js +0 -22
  74. package/src/Atomic/FormElements/Table/Partials/TdCell.js +0 -47
  75. package/src/Atomic/FormElements/Table/Partials/TdHeader.js +0 -33
  76. package/src/Atomic/FormElements/Table/Partials/TdRow.js +0 -84
  77. package/src/Atomic/FormElements/Table/Partials/TdTitle.js +0 -38
  78. package/src/Atomic/FormElements/Table/Table.js +0 -50
  79. package/src/Atomic/FormElements/Table/Table.scss +0 -78
  80. package/src/Atomic/FormElements/Table/Table.stories.js +0 -102
  81. package/src/Atomic/FormElements/Table/TdTypes/TdActions.js +0 -59
  82. package/src/Atomic/FormElements/Table/TdTypes/TdPriority.js +0 -20
  83. package/src/Atomic/FormElements/Table/TdTypes/TdRange.js +0 -15
  84. package/src/Atomic/FormElements/Table/TdTypes/TdTypes.scss +0 -35
  85. package/src/Atomic/FormElements/Table/TdTypes/TdWeight.js +0 -43
  86. package/src/Atomic/FormElements/Tag/Tag.js +0 -24
  87. package/src/Atomic/FormElements/Tag/Tag.scss +0 -38
  88. package/src/Atomic/FormElements/Tag/Tag.stories.js +0 -30
  89. package/src/Atomic/FormElements/TagsDropdown/TagsDropdown.js +0 -108
  90. package/src/Atomic/FormElements/TagsDropdown/TagsDropdown.scss +0 -131
  91. package/src/Atomic/FormElements/TagsDropdown/TagsDropdown.stories.js +0 -44
  92. package/src/Atomic/FormElements/TextSwitcher/TextSwitcher.js +0 -18
  93. package/src/Atomic/FormElements/TextSwitcher/TextSwitcher.scss +0 -50
  94. package/src/Atomic/FormElements/TextSwitcher/TextSwitcher.stories.js +0 -21
  95. package/src/Atomic/FormElements/Textarea/Textarea.js +0 -19
  96. package/src/Atomic/FormElements/Textarea/Textarea.scss +0 -35
  97. package/src/Atomic/FormElements/Textarea/Textarea.stories.js +0 -24
  98. package/src/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +0 -66
  99. package/src/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.scss +0 -10
  100. package/src/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.stories.js +0 -57
  101. package/src/Atomic/FormElements/TimeRange/TimeRange.js +0 -55
  102. package/src/Atomic/FormElements/TimeRange/TimeRange.scss +0 -17
  103. package/src/Atomic/FormElements/TimeRange/TimeRange.stories.js +0 -21
  104. package/src/Atomic/MainMenu/MainMenu.js +0 -112
  105. package/src/Atomic/MainMenu/MainMenu.scss +0 -176
  106. package/src/Atomic/MainMenu/MainMenu.stories.js +0 -91
  107. package/src/Atomic/UI/Accordion/Accordion.js +0 -45
  108. package/src/Atomic/UI/Accordion/Accordion.scss +0 -73
  109. package/src/Atomic/UI/Accordion/Accordion.stories.js +0 -78
  110. package/src/Atomic/UI/Accordion/AccordionItem.js +0 -92
  111. package/src/Atomic/UI/AdvancedTag/AdvTag.js +0 -81
  112. package/src/Atomic/UI/AdvancedTag/AdvancedTags.js +0 -32
  113. package/src/Atomic/UI/AdvancedTag/AdvancedTags.scss +0 -72
  114. package/src/Atomic/UI/AdvancedTag/AdvancedTags.stories.js +0 -49
  115. package/src/Atomic/UI/Alert/Alert.js +0 -23
  116. package/src/Atomic/UI/Alert/Alert.scss +0 -65
  117. package/src/Atomic/UI/Alert/Alert.stories.js +0 -34
  118. package/src/Atomic/UI/Arrow/Arrow.js +0 -41
  119. package/src/Atomic/UI/Arrow/Arrow.scss +0 -19
  120. package/src/Atomic/UI/Arrow/Arrow.stories.js +0 -32
  121. package/src/Atomic/UI/Button/Button.js +0 -17
  122. package/src/Atomic/UI/Button/Button.scss +0 -108
  123. package/src/Atomic/UI/Button/Button.stories.js +0 -49
  124. package/src/Atomic/UI/Calendar/Calendar.js +0 -190
  125. package/src/Atomic/UI/Calendar/Calendar.scss +0 -607
  126. package/src/Atomic/UI/Calendar/Calendar.stories.js +0 -26
  127. package/src/Atomic/UI/Header/partials/default_ava.png +0 -0
  128. package/src/Atomic/UI/Hint/Hint.js +0 -34
  129. package/src/Atomic/UI/Hint/Hint.scss +0 -92
  130. package/src/Atomic/UI/Hint/Hint.stories.js +0 -34
  131. package/src/Atomic/UI/Price/Price.js +0 -20
  132. package/src/Atomic/UI/Price/Price.stories.js +0 -30
  133. package/src/Atomic/UI/Status/Status.js +0 -38
  134. package/src/Atomic/UI/Status/Status.scss +0 -69
  135. package/src/Atomic/UI/Status/Status.stories.js +0 -47
  136. package/src/Constants/index.constants.js +0 -41
  137. package/src/Functions/customEventListener.js +0 -58
  138. package/src/Functions/inputExecutor.js +0 -53
  139. package/src/Functions/schemas.js +0 -31
  140. package/src/Functions/useClickOutside.js +0 -15
  141. package/src/Functions/useMouseUpOutside.js +0 -16
  142. package/src/Functions/useToggle.js +0 -17
  143. package/src/Functions/utils.js +0 -51
  144. package/src/Molecular/Datepicker/Datepicker.js +0 -346
  145. package/src/Molecular/Datepicker/Datepicker.scss +0 -8
  146. package/src/Molecular/Datepicker/Datepicker.stories.js +0 -27
  147. package/src/Molecular/Datepicker/components/Calendar.js +0 -118
  148. package/src/Molecular/FormElements/FormElement.js +0 -18
  149. package/src/Molecular/FormElements/FormElement.scss +0 -8
  150. package/src/Molecular/FormElements/FormElement.stories.js +0 -59
  151. package/src/index.js +0 -3
  152. package/src/scss/_fonts.scss +0 -109
  153. package/src/scss/_vars.scss +0 -48
  154. package/src/scss/main.scss +0 -40
  155. package/webpack.config.js +0 -61
@@ -1,186 +0,0 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
- import cn from 'classnames';
3
- import InputMask from 'react-input-mask';
4
- import { KEYBOARD_SERVICE_KEYS } from '../../../Constants/index.constants';
5
- import { formatInput } from '../../../Functions/inputExecutor';
6
-
7
- import './Input.scss';
8
-
9
- const Input = ({
10
- onChange,
11
- onBlur,
12
- onFocus,
13
- onKeyUp,
14
- isNotBlinkErrors,
15
- isPriceInput,
16
- isOnlyNumber,
17
- isOnlyString,
18
- isTwoDigitAfterDot,
19
- disabled,
20
- withDelete,
21
- value,
22
- placeholder,
23
- className,
24
- type = 'text',
25
- mask,
26
- maskChar,
27
- formatChars,
28
- error,
29
- icon,
30
- symbolsLimit,
31
- blinkTime,
32
- isFocusDefault = false,
33
- }) => {
34
- const DEFAULT_BLINK_TIME = 100;
35
- // STATES
36
- const [isFocused, setIsFocused] = useState(false);
37
- const [isEditing, setEditing] = useState(false);
38
- const inputRef = useRef(null);
39
- const previousValueRef = useRef(value);
40
- const [isAttemptToChange, setIsAttemptToChange] = useState(false);
41
- const [isToHighlightError, setIsToHighlightError] = useState(false);
42
-
43
- const { onlyNumbers, onlyString } = formatInput;
44
- const { addCommas, removeComma } = formatInput.priceInput;
45
- const isUseErrorsBlink = !isNotBlinkErrors && !mask;
46
-
47
- // HANDLES
48
- const handle = {
49
- change: (e) => {
50
- let inputValue = e.target ? e.target.value : e;
51
- if (symbolsLimit && inputValue.length > +symbolsLimit) {
52
- inputValue = inputValue.substring(0, +symbolsLimit);
53
- }
54
-
55
- if (isOnlyNumber && !isTwoDigitAfterDot) inputValue = onlyNumbers(inputValue);
56
- if (isTwoDigitAfterDot) inputValue = onlyNumbers(inputValue, true);
57
- if (isOnlyString) inputValue = onlyString(inputValue);
58
-
59
- onChange(inputValue.toString());
60
- },
61
- toggleEdit: () => {
62
- setEditing(!isEditing);
63
- onChange('');
64
- },
65
- focus: (e) => {
66
- setIsFocused(true);
67
- if (isPriceInput && isOnlyNumber) onChange(removeComma(value));
68
-
69
- if (onFocus) onFocus(e);
70
- },
71
- blur: (e) => {
72
- setIsFocused(false);
73
- setEditing(false);
74
- if (isTwoDigitAfterDot) {
75
- onChange(cutOffsingleDot(value));
76
- }
77
- if (isPriceInput && isOnlyNumber) {
78
- onChange(addCommas(value));
79
- }
80
- if (onBlur) onBlur(e);
81
- },
82
- keyUp: (e) => {
83
- if (isUseErrorsBlink) {
84
- const changedValue = '' + (value ?? '');
85
- const previousValue = '' + (previousValueRef.current ?? '');
86
-
87
- const short = previousValue.length <= changedValue.length ? previousValue : changedValue;
88
- const long = previousValue.length > changedValue.length ? previousValue : changedValue;
89
-
90
- const infoAboutDifferencesSameness = short.split('').reduce(
91
- (acc, symbol, idx) => {
92
- if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);
93
- else {
94
- acc.countOn = false;
95
- acc.differences.push([idx, symbol]);
96
- }
97
- return acc;
98
- },
99
- { same: [], countOn: true, differences: [] }
100
- );
101
-
102
- const samePart = infoAboutDifferencesSameness.same.join('');
103
- const differencesLength = infoAboutDifferencesSameness.differences.length;
104
- const currentSet = changedValue.replace(samePart, '');
105
-
106
- const getNext = (inputPartToAdd, correctedSamePart) => {
107
- const partToAdd = inputPartToAdd || currentSet;
108
- const currentSamePart = correctedSamePart || samePart;
109
- return changedValue.includes(e.key) && e.key !== changedValue[changedValue.length - 1]
110
- ? currentSamePart + (partToAdd[0] || '')
111
- : changedValue;
112
- };
113
-
114
- if (!KEYBOARD_SERVICE_KEYS.includes(e.key) && changedValue === previousValue)
115
- setIsAttemptToChange(!(!differencesLength && e.key === changedValue[changedValue.length - 2]));
116
-
117
- if (!previousValueRef.current || KEYBOARD_SERVICE_KEYS.includes(e.key)) previousValueRef.current = getNext();
118
- else if (changedValue === samePart) previousValueRef.current = getNext(changedValue, changedValue.slice(0, -1));
119
- else previousValueRef.current = getNext();
120
- }
121
-
122
- if (onKeyUp) onKeyUp(e.keyCode, e);
123
- },
124
- };
125
-
126
- function cutOffsingleDot(value) {
127
- return value.toString().slice(-1) === '.' ? value.slice(0, -1) : value;
128
- }
129
-
130
- useEffect(() => {
131
- if (isEditing) inputRef.current.focus();
132
- }, [isEditing, isFocused]);
133
-
134
- const uniProps = {
135
- className: `input ${className}`,
136
- placeholder,
137
- value: value || '',
138
- disabled,
139
- onChange: handle.change,
140
- onFocus: handle.focus,
141
- onBlur: handle.blur,
142
- onKeyUp: handle.keyUp,
143
- ...(maskChar ? { maskChar } : {}),
144
- ...(formatChars ? { formatChars } : {}),
145
- };
146
-
147
- function renderInput() {
148
- if (mask) {
149
- return <InputMask {...uniProps} ref={inputRef} mask={mask} />;
150
- }
151
-
152
- return <input {...uniProps} ref={inputRef} type={isPriceInput ? 'text' : type} />;
153
- }
154
-
155
- useEffect(() => {
156
- if (isUseErrorsBlink && isAttemptToChange) {
157
- setIsAttemptToChange(null);
158
- setIsToHighlightError(true);
159
- setTimeout(() => {
160
- setIsToHighlightError(false);
161
- }, blinkTime || DEFAULT_BLINK_TIME);
162
- }
163
- }, [isAttemptToChange]);
164
-
165
- useEffect(() => {
166
- if (inputRef?.current && typeof isFocusDefault === 'boolean') setIsFocused(isFocusDefault);
167
- setEditing(isFocusDefault);
168
- }, [inputRef, isFocusDefault]);
169
-
170
- return (
171
- <div
172
- className={cn(
173
- `input__wrap`,
174
- { [`input__wrap_focus`]: isFocused },
175
- { [`input__wrap_error`]: error || isToHighlightError },
176
- { [`input__wrap_disabled`]: disabled }
177
- )}
178
- >
179
- {renderInput()}
180
- {icon}
181
- {withDelete && <span className={cn(`input__close`, { hidden: !value })} onClick={handle.toggleEdit} />}
182
- </div>
183
- );
184
- };
185
-
186
- export default Input;
@@ -1,136 +0,0 @@
1
- .input {
2
- position: relative;
3
- word-break: break-all;
4
- border: none;
5
- background: none;
6
- padding: 0 10px;
7
- width: 100%;
8
- &::-webkit-outer-spin-button,
9
- &::-webkit-inner-spin-button {
10
- -webkit-appearance: none;
11
- }
12
-
13
- &__wrap {
14
- display: flex;
15
- align-items: center;
16
- border: 1px solid #e2e5ec;
17
- box-sizing: border-box;
18
- background-color: #fff;
19
- height: 28px;
20
- border-radius: 4px;
21
-
22
- &_focus {
23
- border-color: #6b81dd;
24
- filter: drop-shadow(0px 0px 4px rgba(93, 120, 255, 0.5));
25
- }
26
-
27
- &_disabled {
28
- background: #f7f8fa;
29
- opacity: 0.5;
30
- border-color: #a6acb1;
31
- pointer-events: none;
32
- }
33
-
34
- &_error {
35
- border-color: #f06d8d;
36
- }
37
- }
38
-
39
- &_disabled {
40
- background: #f7f8fa;
41
- opacity: 0.5;
42
- border-color: #a6acb1;
43
- pointer-events: none;
44
- }
45
-
46
- &_error {
47
- border-color: #f06d8d;
48
- }
49
-
50
- svg {
51
- margin-right: 4px;
52
- }
53
-
54
- &__input {
55
- width: 100%;
56
- height: 100%;
57
- box-sizing: border-box;
58
- font-size: 13px;
59
- font-weight: 400;
60
- color: #1e1e2d;
61
- border: none;
62
- padding: 0 5px;
63
- border-radius: 4px;
64
- }
65
-
66
- &__close {
67
- position: relative;
68
- opacity: 0.6;
69
- width: 14px;
70
- height: 14px;
71
- background: none;
72
- cursor: pointer;
73
- margin-right: 4px;
74
- visibility: hidden;
75
- pointer-events: none;
76
- &:hover {
77
- opacity: 1;
78
- }
79
-
80
- &:before,
81
- &:after {
82
- content: "";
83
- position: absolute;
84
- top: 0;
85
- left: 0;
86
- right: 0;
87
- margin: auto;
88
- height: 14px;
89
- width: 2px;
90
- background-color: #9aa0b9;
91
- }
92
-
93
- &:before {
94
- transform: rotate(45deg);
95
- }
96
-
97
- &:after {
98
- transform: rotate(-45deg);
99
- }
100
- }
101
-
102
- &__nums {
103
- display: flex;
104
- align-items: center;
105
- height: 100%;
106
- }
107
-
108
- &__num-btn {
109
- cursor: pointer;
110
- display: flex;
111
- align-items: center;
112
- justify-content: center;
113
- height: 100%;
114
- width: 24px;
115
- border-left: 1px solid #e2e5ec;
116
- background: none;
117
- font-size: 20px;
118
- user-select: none;
119
- &.disabled {
120
- opacity: 0.3;
121
- }
122
- svg {
123
- margin-right: 0;
124
- }
125
- }
126
-
127
- &-label {
128
- margin-bottom: 5px;
129
- }
130
- }
131
-
132
- .input__wrap:hover .input__close {
133
- visibility: visible;
134
- pointer-events: all;
135
- }
136
-
@@ -1,94 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { User } from 'react-feather';
3
- import Input from './Input';
4
-
5
- global.lng = 'en';
6
-
7
- export default {
8
- title: 'Form Elements/Input',
9
- component: Input,
10
- argTypes: {
11
- disabled: {
12
- description: 'boolean'
13
- },
14
- error: {
15
- description: 'text - coloring input if is errored'
16
- },
17
- isPriceInput: {
18
- description: 'boolean - if true, the input will be styled as PriceInput'
19
- },
20
- withDelete: {
21
- description: 'boolean - add clear-cross by hover'
22
- },
23
- isOnlyNumber: {
24
- description: 'boolean - only numbers'
25
- },
26
- isOnlyString: {
27
- description: 'boolean - only strings'
28
- },
29
- isTwoDigitAfterDot: {
30
- description: 'boolean - only two digits after dot'
31
- },
32
- isFocusDefault: {
33
- description: 'boolean - if true, input will be focused on mount'
34
- },
35
- placeholder: {
36
- description: 'text'
37
- },
38
- type: {
39
- description:
40
- "'text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range'",
41
- control: {
42
- type: 'select',
43
- options: [
44
- 'text',
45
- 'number',
46
- 'password',
47
- 'color',
48
- 'date',
49
- 'datetime-local',
50
- 'month',
51
- 'time',
52
- 'email',
53
- 'range'
54
- ]
55
- }
56
- },
57
- icon: { description: 'JSX' },
58
- value: { description: '(* - required prop)' },
59
- className: { description: 'string' },
60
- mask: {
61
- description:
62
- 'string: force input to masked https://www.npmjs.com/package/react-input-mask'
63
- },
64
- symbolsLimit: {
65
- description: 'Set limit of symbols in input, overhead will be ignored'
66
- },
67
- onBlur: { description: 'custom callback on blur' },
68
- onFocus: { description: 'custom callback on focus' },
69
- onKeyUp: { description: 'custom callback on keyup, returns event keyCode' }
70
- }
71
- };
72
-
73
- const Template = (args) => {
74
- const [value, setValue] = useState('');
75
- return <Input {...args} value={value} onChange={setValue} />;
76
- };
77
-
78
- export const InputTemplate = Template.bind({});
79
-
80
- InputTemplate.args = {
81
- type: 'text',
82
- isFocusDefault: false,
83
- isOnlyNumber: false,
84
- isOnlyString: false,
85
- isPriceInput: false,
86
- isTwoDigitAfterDot: false,
87
- disabled: false,
88
- error: '',
89
- mask: '',
90
- withDelete: true,
91
- symbolsLimit: 255,
92
- placeholder: 'Placeholder',
93
- icon: <User />
94
- };
@@ -1,104 +0,0 @@
1
- import React, { useState, useRef } from 'react';
2
- import moment from 'moment';
3
- import InputMask from 'react-input-mask';
4
- import cn from 'classnames';
5
-
6
- import Calendar from '../../UI/Calendar/Calendar';
7
- import { useClickOutside } from '../../../Functions/useClickOutside';
8
-
9
- import './InputCalendar.scss';
10
-
11
- const InputCalendar = ({
12
- value,
13
- minDate,
14
- maxDate,
15
- format = 'MM/DD/YYYY',
16
- isDontLimitFuture,
17
- onChange,
18
- className = '',
19
- placeholder = 'mm/dd/yyyy',
20
- mask = '99/99/9999',
21
- isListTop,
22
- disabled,
23
- }) => {
24
- const [isOpened, setIsOpened] = useState(false);
25
- const calendarRef = useRef(null);
26
-
27
- const formatedMinDate = moment(minDate).format(format) !== 'Invalid date'
28
- ? moment(minDate).format(format)
29
- : null;
30
-
31
- const formatedMaxDate = moment(maxDate).format(format) !== 'Invalid date'
32
- ? moment(maxDate).format(format)
33
- : null;
34
-
35
- const momentMinDate = moment(formatedMinDate, format).startOf('day');
36
- const momentMaxDate = moment(formatedMaxDate, format).startOf('day');
37
-
38
- useClickOutside(calendarRef, () => setIsOpened(false));
39
-
40
- const changeInputValue = (val) => {
41
- if (onChange) onChange(val);
42
- };
43
-
44
- const changeCalendarDay = (val) => {
45
- if (onChange) onChange(val);
46
- };
47
-
48
- const getCalendarValue = (value) => {
49
- const date = moment(value).format('L');
50
-
51
- if (date !== 'Invalid date') return date;
52
-
53
- return moment(new Date()).format('L');
54
- };
55
-
56
- const handleBlur = (e) => {
57
- const value = e.target.value;
58
- if (moment(value).format(format) === 'Invalid date') onChange('');
59
- else if (moment(value).startOf('day').isBefore(momentMinDate, 'days')) onChange(formatedMinDate);
60
- else if (moment(value).endOf('day').isAfter(momentMaxDate, 'days')) onChange(formatedMaxDate);
61
- else onChange(moment(value).format(format));
62
- };
63
-
64
- return (
65
- <div
66
- className={cn('input__wrap calendar-container', className, {
67
- 'calendar-container_disabled': disabled,
68
- })}
69
- ref={calendarRef}
70
- >
71
- <InputMask
72
- mask={mask}
73
- placeholder={placeholder}
74
- value={value}
75
- onChange={(e) => changeInputValue(e.target.value)}
76
- className="calendar-dropdown"
77
- onFocus={() => setIsOpened(true)}
78
- onBlur={!isOpened ? handleBlur : () => {}}
79
- onKeyUp={e => {
80
- if (e.key === 'Enter') e.target.blur();
81
- setIsOpened(false);
82
- }}
83
- />
84
- {isOpened ? (
85
- <Calendar
86
- date={getCalendarValue(value)}
87
- setDate={(newDate) => changeCalendarDay(newDate)}
88
- params={{
89
- format,
90
- minDate: formatedMinDate,
91
- maxDate: formatedMaxDate,
92
- momentMinDate,
93
- momentMaxDate,
94
- isDontLimitFuture
95
- }}
96
- isListTop={isListTop}
97
- setIsOpened={setIsOpened}
98
- />
99
- ) : null}
100
- </div>
101
- );
102
- };
103
-
104
- export default InputCalendar;
@@ -1,23 +0,0 @@
1
- .calendar-container {
2
- min-width: 200px;
3
- position: relative;
4
-
5
- &_disabled {
6
- pointer-events: none;
7
- opacity: 0.5;
8
- }
9
-
10
- .calendar {
11
- position: absolute;
12
- z-index: 9;
13
- top: 100%;
14
- padding: 10px 16px;
15
- border: 1px solid var(--border-color);
16
-
17
- &_list-top {
18
- bottom: calc(100% + 4px);
19
- top: auto;
20
- box-shadow: 0 -3px 15px rgb(0 0 0 / 15%);
21
- }
22
- }
23
- }
@@ -1,39 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import InputCalendar from './InputCalendar';
3
-
4
- global.lng = 'en';
5
-
6
- export default {
7
- title: 'Form Elements/Input Calendar',
8
- component: InputCalendar,
9
- argTypes: {
10
- value: {
11
- description: 'string (mm.dd.yyyy)',
12
- },
13
- },
14
- };
15
-
16
- const Template = (args) => {
17
- const [date, setDate] = useState('');
18
- const [disabled, setDisabled] = useState(false);
19
-
20
- return (
21
- <>
22
- <InputCalendar {...args} value={date} onChange={(val) => setDate(val)} disabled={disabled} />
23
- <div style={{ display: 'flex', flexFlow: 'row nowrap', justifyContent: 'flex-end', marginTop: '10px' }}>
24
- <button style={{ border: 'solid 1px black', padding: '10px', width: '80px' }} onClick={() => setDisabled(!disabled)}>
25
- {disabled ? 'Enable' : 'Disable'}
26
- </button>
27
- </div>
28
- </>
29
- );
30
- };
31
-
32
- export const CalendarTemplate = Template.bind({});
33
-
34
- CalendarTemplate.args = {
35
- minDate: '01/10/2022',
36
- maxDate: '04/20/2022',
37
- // isDontLimitFuture: true,
38
- // isListTop: true,
39
- };