@pushwoosh/dumb-components 2.12.2 → 3.0.1

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 (177) hide show
  1. package/Alert/styles.d.ts +6 -14
  2. package/Banner/maps.d.ts +2 -6
  3. package/Banner/styles.d.ts +2 -6
  4. package/Button/maps.d.ts +12 -36
  5. package/Button/styles.d.ts +12 -36
  6. package/Calendar/CalendarMonth/styles.d.ts +2 -6
  7. package/Calendar/CalendarMonthSlider/styles.d.ts +5 -9
  8. package/CodeEditor/styles.d.ts +3 -7
  9. package/Drawer/components/Drawer/styles.d.ts +2 -2
  10. package/Drawer/components/DrawerDocs/styles.d.ts +1 -3
  11. package/DropdownMenu/components/DropdownMenuSection/styles.d.ts +3 -7
  12. package/DropdownMenu/shared/styles.d.ts +3 -7
  13. package/EmailTemplatePreview/components/NoEmailTemplatePreview/styles.d.ts +6 -14
  14. package/EnhancedInput/styles.d.ts +2 -6
  15. package/ExportResult/styles.d.ts +9 -21
  16. package/FieldBox/styles.d.ts +7 -15
  17. package/FrequencyCapping/styles.d.ts +6 -14
  18. package/GetStartedPage/styles.d.ts +1 -3
  19. package/InboxPreview/components/InboxCellCarousel/styles.d.ts +9 -21
  20. package/InboxPreview/styles.d.ts +7 -17
  21. package/InputFile/styles.d.ts +1 -3
  22. package/Modal/components/Modal/styles.d.ts +2 -2
  23. package/Modal/components/ModalContent/styles.d.ts +9 -21
  24. package/Modal/components/ModalTitle/styles.d.ts +3 -7
  25. package/NativeRichMediaPreview/components/NativeRichMediaRewardPanel/styles.d.ts +3 -7
  26. package/NativeRichMediaPreview/components/NativeRichMediaThemeChip/styles.d.ts +1 -3
  27. package/NativeRichMediaPreview/components/NativeRichMediaTitle/styles.d.ts +3 -7
  28. package/NativeRichMediaPreview/views/NativeRichMediaModalView/styles.d.ts +2 -6
  29. package/NativeRichMediaPreview/views/NativeRichMediaScratchcardView/styles.d.ts +2 -6
  30. package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/styles.d.ts +2 -6
  31. package/NotificationInbox/styles.d.ts +21 -51
  32. package/Pagination/styles.d.ts +2 -6
  33. package/ProgressBar/styles.d.ts +1 -3
  34. package/PushPreview/styles.d.ts +7 -15
  35. package/Radio/styles.d.ts +3 -7
  36. package/RadioCard/styles.d.ts +7 -15
  37. package/RichMessageEditor/slate/styles.d.ts +2 -4
  38. package/RichMessageEditor/styles.d.ts +7 -15
  39. package/RichmediaPreview/styles.d.ts +3 -7
  40. package/SendRate/styles.d.ts +6 -14
  41. package/Switch/styles.d.ts +2 -2
  42. package/Tabs/components/TabBarScrollableFrame/styles.d.ts +1 -3
  43. package/Tooltip/styles.d.ts +3 -7
  44. package/Tooltip/useTooltipPosition.d.ts +1 -1
  45. package/WhatsAppPreview/components/WhatsAppAttachment/styles.d.ts +46 -102
  46. package/WhatsAppPreview/components/WhatsAppMessageContent/styles.d.ts +3 -7
  47. package/WhatsAppPreview/styles.d.ts +40 -92
  48. package/index.d.ts +0 -1
  49. package/index.js +0 -1
  50. package/package.json +6 -6
  51. package/shared/dropdownField/styles.d.ts +2 -2
  52. package/DateTimePicker/components/AutosizeInput/AutosizeInput.d.ts +0 -3
  53. package/DateTimePicker/components/AutosizeInput/AutosizeInput.js +0 -39
  54. package/DateTimePicker/components/AutosizeInput/index.d.ts +0 -1
  55. package/DateTimePicker/components/AutosizeInput/index.js +0 -1
  56. package/DateTimePicker/components/AutosizeInput/styles.d.ts +0 -3
  57. package/DateTimePicker/components/AutosizeInput/styles.js +0 -5
  58. package/DateTimePicker/components/AutosizeInput/types.d.ts +0 -10
  59. package/DateTimePicker/components/AutosizeInput/types.js +0 -1
  60. package/DateTimePicker/components/DatePicker/DatePicker.d.ts +0 -8
  61. package/DateTimePicker/components/DatePicker/DatePicker.js +0 -65
  62. package/DateTimePicker/components/DatePicker/index.d.ts +0 -1
  63. package/DateTimePicker/components/DatePicker/index.js +0 -1
  64. package/DateTimePicker/components/DatePicker/types.d.ts +0 -20
  65. package/DateTimePicker/components/DatePicker/types.js +0 -1
  66. package/DateTimePicker/components/DatePickerField/DatePickerField.d.ts +0 -8
  67. package/DateTimePicker/components/DatePickerField/DatePickerField.js +0 -86
  68. package/DateTimePicker/components/DatePickerField/index.d.ts +0 -1
  69. package/DateTimePicker/components/DatePickerField/index.js +0 -1
  70. package/DateTimePicker/components/DatePickerField/types.d.ts +0 -20
  71. package/DateTimePicker/components/DatePickerField/types.js +0 -1
  72. package/DateTimePicker/components/DateTimePicker/DateTimePicker.d.ts +0 -8
  73. package/DateTimePicker/components/DateTimePicker/DateTimePicker.js +0 -64
  74. package/DateTimePicker/components/DateTimePicker/index.d.ts +0 -1
  75. package/DateTimePicker/components/DateTimePicker/index.js +0 -1
  76. package/DateTimePicker/components/DateTimePicker/types.d.ts +0 -13
  77. package/DateTimePicker/components/DateTimePicker/types.js +0 -1
  78. package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.d.ts +0 -8
  79. package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.js +0 -91
  80. package/DateTimePicker/components/DateTimePickerField/helpers.d.ts +0 -8
  81. package/DateTimePicker/components/DateTimePickerField/helpers.js +0 -13
  82. package/DateTimePicker/components/DateTimePickerField/index.d.ts +0 -1
  83. package/DateTimePicker/components/DateTimePickerField/index.js +0 -1
  84. package/DateTimePicker/components/DateTimePickerField/types.d.ts +0 -20
  85. package/DateTimePicker/components/DateTimePickerField/types.js +0 -1
  86. package/DateTimePicker/components/DecadeView/DecadeView.d.ts +0 -3
  87. package/DateTimePicker/components/DecadeView/DecadeView.js +0 -35
  88. package/DateTimePicker/components/DecadeView/index.d.ts +0 -1
  89. package/DateTimePicker/components/DecadeView/index.js +0 -1
  90. package/DateTimePicker/components/DecadeView/types.d.ts +0 -6
  91. package/DateTimePicker/components/DecadeView/types.js +0 -1
  92. package/DateTimePicker/components/Input/Input.d.ts +0 -3
  93. package/DateTimePicker/components/Input/Input.js +0 -17
  94. package/DateTimePicker/components/Input/index.d.ts +0 -1
  95. package/DateTimePicker/components/Input/index.js +0 -1
  96. package/DateTimePicker/components/Input/styles.d.ts +0 -3
  97. package/DateTimePicker/components/Input/styles.js +0 -6
  98. package/DateTimePicker/components/Input/types.d.ts +0 -11
  99. package/DateTimePicker/components/Input/types.js +0 -1
  100. package/DateTimePicker/components/Month/Month.d.ts +0 -3
  101. package/DateTimePicker/components/Month/Month.js +0 -78
  102. package/DateTimePicker/components/Month/index.d.ts +0 -1
  103. package/DateTimePicker/components/Month/index.js +0 -1
  104. package/DateTimePicker/components/Month/types.d.ts +0 -8
  105. package/DateTimePicker/components/Month/types.js +0 -1
  106. package/DateTimePicker/components/MonthView/MonthView.d.ts +0 -3
  107. package/DateTimePicker/components/MonthView/MonthView.js +0 -41
  108. package/DateTimePicker/components/MonthView/index.d.ts +0 -1
  109. package/DateTimePicker/components/MonthView/index.js +0 -1
  110. package/DateTimePicker/components/MonthView/types.d.ts +0 -11
  111. package/DateTimePicker/components/MonthView/types.js +0 -1
  112. package/DateTimePicker/components/NumberPicker/NumberPicker.d.ts +0 -3
  113. package/DateTimePicker/components/NumberPicker/NumberPicker.js +0 -133
  114. package/DateTimePicker/components/NumberPicker/helpers.d.ts +0 -2
  115. package/DateTimePicker/components/NumberPicker/helpers.js +0 -5
  116. package/DateTimePicker/components/NumberPicker/index.d.ts +0 -1
  117. package/DateTimePicker/components/NumberPicker/index.js +0 -1
  118. package/DateTimePicker/components/NumberPicker/styles.d.ts +0 -3
  119. package/DateTimePicker/components/NumberPicker/styles.js +0 -6
  120. package/DateTimePicker/components/NumberPicker/types.d.ts +0 -13
  121. package/DateTimePicker/components/NumberPicker/types.js +0 -1
  122. package/DateTimePicker/components/PickerPlate/PickerPlate.d.ts +0 -3
  123. package/DateTimePicker/components/PickerPlate/PickerPlate.js +0 -27
  124. package/DateTimePicker/components/PickerPlate/index.d.ts +0 -1
  125. package/DateTimePicker/components/PickerPlate/index.js +0 -1
  126. package/DateTimePicker/components/PickerPlate/styles.d.ts +0 -17
  127. package/DateTimePicker/components/PickerPlate/styles.js +0 -9
  128. package/DateTimePicker/components/PickerPlate/types.d.ts +0 -7
  129. package/DateTimePicker/components/PickerPlate/types.js +0 -1
  130. package/DateTimePicker/components/YearView/YearView.d.ts +0 -3
  131. package/DateTimePicker/components/YearView/YearView.js +0 -36
  132. package/DateTimePicker/components/YearView/index.d.ts +0 -1
  133. package/DateTimePicker/components/YearView/index.js +0 -1
  134. package/DateTimePicker/components/YearView/types.d.ts +0 -6
  135. package/DateTimePicker/components/YearView/types.js +0 -1
  136. package/DateTimePicker/constants.d.ts +0 -5
  137. package/DateTimePicker/constants.js +0 -9
  138. package/DateTimePicker/helpers.d.ts +0 -13
  139. package/DateTimePicker/helpers.js +0 -81
  140. package/DateTimePicker/index.d.ts +0 -8
  141. package/DateTimePicker/index.js +0 -8
  142. package/DateTimePicker/polyglot/index.d.ts +0 -2
  143. package/DateTimePicker/polyglot/index.js +0 -33
  144. package/DateTimePicker/polyglot/messages_ar.d.ts +0 -3
  145. package/DateTimePicker/polyglot/messages_ar.js +0 -11
  146. package/DateTimePicker/polyglot/messages_bn.d.ts +0 -3
  147. package/DateTimePicker/polyglot/messages_bn.js +0 -11
  148. package/DateTimePicker/polyglot/messages_de.d.ts +0 -3
  149. package/DateTimePicker/polyglot/messages_de.js +0 -11
  150. package/DateTimePicker/polyglot/messages_en.d.ts +0 -3
  151. package/DateTimePicker/polyglot/messages_en.js +0 -11
  152. package/DateTimePicker/polyglot/messages_es.d.ts +0 -3
  153. package/DateTimePicker/polyglot/messages_es.js +0 -11
  154. package/DateTimePicker/polyglot/messages_fr.d.ts +0 -3
  155. package/DateTimePicker/polyglot/messages_fr.js +0 -11
  156. package/DateTimePicker/polyglot/messages_he.d.ts +0 -3
  157. package/DateTimePicker/polyglot/messages_he.js +0 -11
  158. package/DateTimePicker/polyglot/messages_hi.d.ts +0 -3
  159. package/DateTimePicker/polyglot/messages_hi.js +0 -11
  160. package/DateTimePicker/polyglot/messages_ja.d.ts +0 -3
  161. package/DateTimePicker/polyglot/messages_ja.js +0 -11
  162. package/DateTimePicker/polyglot/messages_ko.d.ts +0 -3
  163. package/DateTimePicker/polyglot/messages_ko.js +0 -11
  164. package/DateTimePicker/polyglot/messages_pt.d.ts +0 -3
  165. package/DateTimePicker/polyglot/messages_pt.js +0 -11
  166. package/DateTimePicker/polyglot/messages_ru.d.ts +0 -3
  167. package/DateTimePicker/polyglot/messages_ru.js +0 -11
  168. package/DateTimePicker/polyglot/messages_th.d.ts +0 -3
  169. package/DateTimePicker/polyglot/messages_th.js +0 -11
  170. package/DateTimePicker/polyglot/messages_zh.d.ts +0 -3
  171. package/DateTimePicker/polyglot/messages_zh.js +0 -11
  172. package/DateTimePicker/polyglot/types.d.ts +0 -12
  173. package/DateTimePicker/polyglot/types.js +0 -1
  174. package/DateTimePicker/styles.d.ts +0 -371
  175. package/DateTimePicker/styles.js +0 -66
  176. package/DateTimePicker/types.d.ts +0 -11
  177. package/DateTimePicker/types.js +0 -1
@@ -1,91 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useFloating, offset, autoPlacement } from '@floating-ui/react-dom';
3
- import { useState, useEffect } from 'react';
4
- import { CalendarIcon } from '@pushwoosh/kit-icons';
5
- import { useUTCDate } from './helpers';
6
- import { Lang } from '../../polyglot';
7
- import { InputFrame } from '../../styles';
8
- import { DateTimePicker } from '../DateTimePicker';
9
- /**
10
- * Read-only field showing the selected date-time that opens a {@link DateTimePicker} popover on click.
11
- *
12
- * @deprecated Use `CalendarDropdown` or `CalendarSuperForm` from Calendar instead.
13
- */
14
- export function DateTimePickerField(props) {
15
- const {
16
- value,
17
- minDate,
18
- maxDate,
19
- error,
20
- allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
21
- zIndex = 1000,
22
- closeOnSelect = false,
23
- onChange
24
- } = props;
25
- const [showPicker, setShowPicker] = useState(false);
26
- const {
27
- refs,
28
- floatingStyles
29
- } = useFloating({
30
- middleware: [offset(4), autoPlacement({
31
- allowedPlacements
32
- })]
33
- });
34
- useEffect(() => {
35
- if (!showPicker) {
36
- return;
37
- }
38
- const handleClickListener = event => {
39
- const path = event.composedPath();
40
- const isInsideFloating = refs.floating.current && path.includes(refs.floating.current);
41
- const isInsideReference = refs.reference.current && path.includes(refs.reference.current);
42
- if (!isInsideFloating && !isInsideReference) {
43
- setShowPicker(false);
44
- }
45
- };
46
- document.addEventListener('click', handleClickListener);
47
- return () => {
48
- document.removeEventListener('click', handleClickListener);
49
- };
50
- }, [showPicker, refs]);
51
- const onSelect = date => {
52
- onChange(date);
53
- if (closeOnSelect) {
54
- setShowPicker(false);
55
- }
56
- };
57
- const {
58
- year,
59
- month,
60
- day,
61
- hours,
62
- minutes
63
- } = useUTCDate(value);
64
- return _jsxs(_Fragment, {
65
- children: [_jsxs(InputFrame, {
66
- ref: refs.setReference,
67
- "$empty": !value,
68
- "$error": error,
69
- "$gap": 8,
70
- onClick: () => setShowPicker(!showPicker),
71
- children: [_jsx(CalendarIcon, {
72
- size: "medium",
73
- view: "lined"
74
- }), value ? `${day} ${month} ${year} ${hours}:${minutes}` : _jsx(Lang, {
75
- message: "DUMB.DATE_TIME_PICKER.SELECT_DATE_TIME"
76
- })]
77
- }), showPicker && _jsx("div", {
78
- ref: refs.setFloating,
79
- style: {
80
- ...floatingStyles,
81
- zIndex
82
- },
83
- children: _jsx(DateTimePicker, {
84
- value: value,
85
- minDate: minDate,
86
- maxDate: maxDate,
87
- onChange: onSelect
88
- })
89
- })]
90
- });
91
- }
@@ -1,8 +0,0 @@
1
- export declare const useUTCDate: (dateString: string) => {
2
- year: number;
3
- month: string;
4
- day: string;
5
- hours: string;
6
- minutes: string;
7
- seconds: string;
8
- };
@@ -1,13 +0,0 @@
1
- export const useUTCDate = dateString => {
2
- const date = new Date(dateString);
3
- return {
4
- year: date.getUTCFullYear(),
5
- month: date.toLocaleString('en-US', {
6
- month: 'long'
7
- }),
8
- day: String(date.getUTCDate()).padStart(2, '0'),
9
- hours: String(date.getUTCHours()).padStart(2, '0'),
10
- minutes: String(date.getUTCMinutes()).padStart(2, '0'),
11
- seconds: String(date.getUTCSeconds()).padStart(2, '0')
12
- };
13
- };
@@ -1 +0,0 @@
1
- export * from './DateTimePickerField';
@@ -1 +0,0 @@
1
- export * from './DateTimePickerField';
@@ -1,20 +0,0 @@
1
- import type { Placement } from '@floating-ui/react-dom';
2
- /** Props of {@link DateTimePickerField}. */
3
- export interface DateTimePickerFieldProps {
4
- /** Currently selected date-time string. */
5
- value: string;
6
- /** Earliest selectable date. */
7
- minDate?: Date | string;
8
- /** Latest selectable date. */
9
- maxDate?: Date | string;
10
- /** Render the field in the error state. */
11
- error?: boolean;
12
- /** Allowed floating placements for the popover (default bottom/top start/end). */
13
- allowedPlacements?: Placement[];
14
- /** Popover z-index (default `1000`). */
15
- zIndex?: number;
16
- /** Close the popover when a value is picked (default `false`). */
17
- closeOnSelect?: boolean;
18
- /** Fires with the picked date-time string. */
19
- onChange: (day: string) => void;
20
- }
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { DecadeViewProps } from './types';
3
- export declare function DecadeView(props: DecadeViewProps): ReactElement;
@@ -1,35 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Columns } from '@pushwoosh/kit-helpers';
3
- import { format, parseStringToArray, addPeriod, setPeriod } from '../../helpers';
4
- import { CellBox } from '../../styles';
5
- import { PickerPlate } from '../PickerPlate';
6
- export function DecadeView(props) {
7
- const {
8
- activeDay,
9
- value,
10
- onChange,
11
- onSelect
12
- } = props;
13
- const [activeDayYear] = parseStringToArray(activeDay || '');
14
- const valueYear = +value;
15
- const firstYear = valueYear - valueYear % 12;
16
- return _jsx(PickerPlate, {
17
- onPrev: () => onChange(format(addPeriod(value, 'year', -12), 'year')),
18
- onNext: () => onChange(format(addPeriod(value, 'year', 12), 'year')),
19
- children: _jsx(Columns, {
20
- "$sizes": 4,
21
- "$gap": 4,
22
- children: Array.from({
23
- length: 12
24
- }).map((_, i) => {
25
- const year = firstYear + i;
26
- return _jsx(CellBox, {
27
- "$height": "59px",
28
- "$isActive": year === activeDayYear,
29
- onClick: () => onSelect(format(setPeriod(value, 'year', year), 'year')),
30
- children: year
31
- }, year);
32
- })
33
- })
34
- });
35
- }
@@ -1 +0,0 @@
1
- export * from './DecadeView';
@@ -1 +0,0 @@
1
- export * from './DecadeView';
@@ -1,6 +0,0 @@
1
- export interface DecadeViewProps {
2
- activeDay?: string;
3
- value: string;
4
- onChange: (value: string) => void;
5
- onSelect: (value: string) => void;
6
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { InputProps } from './types';
3
- export declare function Input(props: InputProps): ReactElement;
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { InputStyled } from './styles';
3
- export function Input(props) {
4
- const {
5
- width,
6
- isDisabled,
7
- ...rest
8
- } = props;
9
- return _jsx(InputStyled, {
10
- type: "text",
11
- disabled: isDisabled,
12
- style: {
13
- width: width || '100%'
14
- },
15
- ...rest
16
- });
17
- }
@@ -1 +0,0 @@
1
- export * from './Input';
@@ -1 +0,0 @@
1
- export * from './Input';
@@ -1,3 +0,0 @@
1
- export declare const InputStyled: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
2
- style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
3
- }> & string;
@@ -1,6 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Color } from '@pushwoosh/kit-constants';
3
- export const InputStyled = styled.input.withConfig({
4
- displayName: "InputStyled",
5
- componentId: "sc-17gtn04-0"
6
- })(["color:", ";-webkit-text-fill-color:", ";background-color:transparent;&::placeholder{color:", ";-webkit-text-fill-color:", ";}&:disabled{background-color:", ";-webkit-text-fill-color:", ";}"], Color.MAIN, Color.MAIN, Color.PHANTOM, Color.PHANTOM, Color.FROZEN, Color.LOCKED);
@@ -1,11 +0,0 @@
1
- import type { ChangeEvent, KeyboardEvent, FocusEvent } from 'react';
2
- export interface InputProps {
3
- value: string;
4
- width?: number;
5
- placeholder?: string;
6
- isDisabled?: boolean;
7
- onChange: (event: ChangeEvent<HTMLInputElement>) => void;
8
- onKeyUp: (event: KeyboardEvent<HTMLInputElement>) => void;
9
- onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
10
- onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { MonthProps } from './types';
3
- export declare function Month(props: MonthProps): ReactElement;
@@ -1,78 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { Columns } from '@pushwoosh/kit-helpers';
4
- import { format, firstDayOfWeek, parseStringToDate, differenceInDays, isSamePeriod, isInRange } from '../../helpers';
5
- import { Lang } from '../../polyglot';
6
- import { CellBox, DayHeader } from '../../styles';
7
- export function Month(props) {
8
- const {
9
- month,
10
- activeDay,
11
- userInputDay,
12
- minDate,
13
- maxDate,
14
- onDaySelect
15
- } = props;
16
- const [firstDayDate, days] = useMemo(() => {
17
- const monthDate = parseStringToDate(month);
18
- const firstDayOfMonth = new Date(monthDate);
19
- firstDayOfMonth.setUTCDate(1);
20
- const lastDayOfMonth = new Date(month);
21
- lastDayOfMonth.setUTCMonth(lastDayOfMonth.getUTCMonth() + 1);
22
- lastDayOfMonth.setUTCDate(0);
23
- const firstDayOfFirstWeek = firstDayOfWeek(firstDayOfMonth);
24
- const firstDayOfLastWeek = firstDayOfWeek(lastDayOfMonth);
25
- const daysInCalendar = differenceInDays(firstDayOfLastWeek, firstDayOfFirstWeek) + 7;
26
- return [firstDayOfFirstWeek, daysInCalendar];
27
- }, [month]);
28
- return _jsxs(Columns, {
29
- "$sizes": 7,
30
- "$gap": 4,
31
- children: [_jsx(DayHeader, {
32
- children: _jsx(Lang, {
33
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_SUN"
34
- })
35
- }), _jsx(DayHeader, {
36
- children: _jsx(Lang, {
37
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_MON"
38
- })
39
- }), _jsx(DayHeader, {
40
- children: _jsx(Lang, {
41
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_TUE"
42
- })
43
- }), _jsx(DayHeader, {
44
- children: _jsx(Lang, {
45
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_WED"
46
- })
47
- }), _jsx(DayHeader, {
48
- children: _jsx(Lang, {
49
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_THU"
50
- })
51
- }), _jsx(DayHeader, {
52
- children: _jsx(Lang, {
53
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_FRI"
54
- })
55
- }), _jsx(DayHeader, {
56
- children: _jsx(Lang, {
57
- message: "DUMB.DATE_TIME_PICKER.WEEKDAY_SAT"
58
- })
59
- }), Array.from({
60
- length: days
61
- }).map((_, i) => {
62
- const curDay = new Date(Date.UTC(firstDayDate.getUTCFullYear(), firstDayDate.getUTCMonth(), firstDayDate.getUTCDate() + i));
63
- const isDisabled = isInRange({
64
- value: curDay,
65
- minDate: minDate,
66
- maxDate: maxDate
67
- });
68
- return _jsx(CellBox, {
69
- "$isActive": !!activeDay && isSamePeriod(curDay, activeDay, 'day'),
70
- "$isDisabled": isDisabled,
71
- "$secondary": !isSamePeriod(month, curDay, 'month'),
72
- "$secondActive": !!userInputDay && isSamePeriod(curDay, userInputDay, 'day'),
73
- onClick: () => onDaySelect(format(curDay, 'year-month-day')),
74
- children: curDay.getUTCDate()
75
- }, `${curDay}`);
76
- })]
77
- });
78
- }
@@ -1 +0,0 @@
1
- export * from './Month';
@@ -1 +0,0 @@
1
- export * from './Month';
@@ -1,8 +0,0 @@
1
- export interface MonthProps {
2
- month: string;
3
- activeDay?: string;
4
- userInputDay?: string;
5
- minDate?: Date | string;
6
- maxDate?: Date | string;
7
- onDaySelect: (day: string) => void;
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { MonthViewProps } from './types';
3
- export declare function MonthView(props: MonthViewProps): ReactElement;
@@ -1,41 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Horizontal } from '@pushwoosh/kit-helpers';
3
- import { addPeriod, format, monthName } from '../../helpers';
4
- import { DateInfo } from '../../styles';
5
- import { Month } from '../Month';
6
- import { PickerPlate } from '../PickerPlate';
7
- export function MonthView(props) {
8
- const {
9
- month,
10
- activeDay,
11
- userInputDay,
12
- minDate,
13
- maxDate,
14
- onDaySelect,
15
- onShowYear,
16
- onShowDecade,
17
- onChange
18
- } = props;
19
- return _jsx(PickerPlate, {
20
- onPrev: () => onChange(format(addPeriod(month, 'month', -1), 'year-month')),
21
- onNext: () => onChange(format(addPeriod(month, 'month', 1), 'year-month')),
22
- slot: _jsxs(Horizontal, {
23
- "$gap": 4,
24
- children: [_jsx(DateInfo, {
25
- onClick: onShowYear,
26
- children: monthName(+format(month, 'month'))
27
- }), _jsx(DateInfo, {
28
- onClick: onShowDecade,
29
- children: format(month, 'year')
30
- })]
31
- }),
32
- children: _jsx(Month, {
33
- month: month,
34
- activeDay: activeDay,
35
- userInputDay: userInputDay,
36
- minDate: minDate,
37
- maxDate: maxDate,
38
- onDaySelect: onDaySelect
39
- })
40
- });
41
- }
@@ -1 +0,0 @@
1
- export * from './MonthView';
@@ -1 +0,0 @@
1
- export * from './MonthView';
@@ -1,11 +0,0 @@
1
- export interface MonthViewProps {
2
- month: string;
3
- activeDay?: string;
4
- userInputDay?: string;
5
- minDate?: Date | string;
6
- maxDate?: Date | string;
7
- onDaySelect: (day: string) => void;
8
- onShowYear: () => void;
9
- onShowDecade: () => void;
10
- onChange: (day: string) => void;
11
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { NumberPickerProps } from './types';
3
- export declare function NumberPicker({ value, hint, step, placeholder, focusOnMount, minValue, maxValue, autoSize, isDisabled, onChange, onSubmit, }: NumberPickerProps): ReactElement;
@@ -1,133 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState, useEffect } from 'react';
3
- import { Vertical, useMount, usePersistentFunction } from '@pushwoosh/kit-helpers';
4
- import { ChevronIcon } from '@pushwoosh/kit-icons';
5
- import { intVal, isStringInteger } from './helpers';
6
- import { SingleInputFrame } from '../../styles';
7
- import { AutosizeInput } from '../AutosizeInput';
8
- import { Input } from '../Input';
9
- import { Hint } from './styles';
10
- export function NumberPicker({
11
- value,
12
- hint,
13
- step = 1,
14
- placeholder,
15
- focusOnMount,
16
- minValue,
17
- maxValue,
18
- autoSize,
19
- isDisabled,
20
- onChange,
21
- onSubmit
22
- }) {
23
- const ref = useRef(null);
24
- const [autoDiff, setAutoDiff] = useState(0);
25
- const [localValue, setLocalValue] = useState(value.toString() || '');
26
- const onChangeDiff = usePersistentFunction(diff => {
27
- const newValue = intVal(value) + diff;
28
- const minValueValid = minValue === undefined || newValue >= minValue;
29
- const maxValueValid = maxValue === undefined || newValue <= maxValue;
30
- if (minValueValid && maxValueValid) {
31
- onChange(newValue);
32
- }
33
- });
34
- useEffect(() => {
35
- setLocalValue(value.toString() || '');
36
- }, [value]);
37
- useEffect(() => {
38
- if (!autoDiff) {
39
- return;
40
- }
41
- const interval = setInterval(() => {
42
- onChangeDiff(autoDiff);
43
- }, 250);
44
- return () => clearInterval(interval);
45
- }, [autoDiff, onChangeDiff]);
46
- useMount(() => {
47
- if (focusOnMount && ref.current) {
48
- ref.current.children[0].focus();
49
- }
50
- });
51
- const handleChange = event => {
52
- const val = event.target.value;
53
- if (val === '' || val === '-') {
54
- setLocalValue(val);
55
- return;
56
- }
57
- const parsedValue = intVal(val);
58
- if (parsedValue === 0 && val !== '0') {
59
- return;
60
- }
61
- setLocalValue(val);
62
- const minValueValid = minValue === undefined || parsedValue >= minValue;
63
- const maxValueValid = maxValue === undefined || parsedValue <= maxValue;
64
- if (isStringInteger(val) && minValueValid && maxValueValid) {
65
- onChange(parsedValue);
66
- }
67
- };
68
- const handleKeyDown = event => {
69
- if (onSubmit && event.key === 'Enter' && isStringInteger(localValue)) {
70
- onSubmit();
71
- }
72
- if (event.key === 'ArrowUp') {
73
- onChangeDiff(1);
74
- setAutoDiff(1);
75
- }
76
- if (event.key === 'ArrowDown') {
77
- onChangeDiff(-1);
78
- setAutoDiff(-1);
79
- }
80
- };
81
- const resetAutoDiff = () => setAutoDiff(0);
82
- const InputComponent = autoSize ? AutosizeInput : Input;
83
- return _jsxs(SingleInputFrame, {
84
- ref: ref,
85
- "$hasHint": !!hint,
86
- "$isDisabled": isDisabled,
87
- children: [_jsx(InputComponent, {
88
- value: localValue,
89
- placeholder: placeholder,
90
- isDisabled: isDisabled,
91
- onChange: handleChange,
92
- onKeyDown: handleKeyDown,
93
- onKeyUp: resetAutoDiff,
94
- onBlur: event => {
95
- let blurValue = intVal(event.target.value);
96
- const minValueValid = minValue === undefined || blurValue >= minValue;
97
- const maxValueValid = maxValue === undefined || blurValue <= maxValue;
98
- if (!maxValueValid) {
99
- blurValue = maxValue;
100
- } else if (!minValueValid) {
101
- blurValue = minValue;
102
- }
103
- onChange(blurValue);
104
- setLocalValue(blurValue.toString());
105
- }
106
- }), hint && _jsx(Hint, {
107
- children: hint
108
- }), _jsxs(Vertical, {
109
- "$gap": 1,
110
- children: [_jsx("div", {
111
- children: _jsx(ChevronIcon, {
112
- direction: "up",
113
- size: "small",
114
- "aria-disabled": "true",
115
- onClick: () => onChangeDiff(step),
116
- onMouseDown: () => setAutoDiff(step),
117
- onMouseUp: resetAutoDiff,
118
- onMouseLeave: resetAutoDiff
119
- })
120
- }), _jsx("div", {
121
- children: _jsx(ChevronIcon, {
122
- size: "small",
123
- direction: "down",
124
- "aria-disabled": isDisabled,
125
- onClick: () => onChangeDiff(-1 * step),
126
- onMouseDown: () => setAutoDiff(-1 * step),
127
- onMouseUp: resetAutoDiff,
128
- onMouseLeave: resetAutoDiff
129
- })
130
- })]
131
- })]
132
- });
133
- }
@@ -1,2 +0,0 @@
1
- export declare const intVal: (value: any) => number;
2
- export declare const isStringInteger: (value: string) => boolean;
@@ -1,5 +0,0 @@
1
- export const intVal = value => {
2
- const num = parseInt(value, 10);
3
- return Number.isNaN(num) ? 0 : num;
4
- };
5
- export const isStringInteger = value => /^-?\d+$/.test(value);
@@ -1 +0,0 @@
1
- export * from './NumberPicker';
@@ -1 +0,0 @@
1
- export * from './NumberPicker';
@@ -1,3 +0,0 @@
1
- export declare const Hint: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
2
- style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
3
- }> & string;
@@ -1,6 +0,0 @@
1
- import styled from 'styled-components';
2
- import { Color } from '@pushwoosh/kit-constants';
3
- export const Hint = styled.div.withConfig({
4
- displayName: "Hint",
5
- componentId: "sc-170ev2t-0"
6
- })(["display:flex;align-items:center;font-size:100%;line-height:initial;padding-right:8px;color:", ";pointer-events:none;"], Color.PHANTOM);
@@ -1,13 +0,0 @@
1
- export interface NumberPickerProps {
2
- value: number;
3
- hint?: string;
4
- step?: number;
5
- placeholder?: string;
6
- focusOnMount?: boolean;
7
- minValue?: number;
8
- maxValue?: number;
9
- autoSize?: boolean;
10
- isDisabled?: boolean;
11
- onChange: (value: number) => void;
12
- onSubmit?: () => void;
13
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { PickerPlateProps } from './types';
3
- export declare function PickerPlate(props: PickerPlateProps): ReactElement;
@@ -1,27 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Vertical, Horizontal } from '@pushwoosh/kit-helpers';
3
- import { Arrow } from './styles';
4
- export function PickerPlate(props) {
5
- const {
6
- slot,
7
- children,
8
- onPrev,
9
- onNext
10
- } = props;
11
- return _jsxs(Vertical, {
12
- "$gap": 16,
13
- children: [_jsxs(Horizontal, {
14
- "$justifyContent": "space-between",
15
- children: [slot, _jsxs(Horizontal, {
16
- "$gap": 4,
17
- children: [_jsx(Arrow, {
18
- direction: "left",
19
- onClick: onPrev
20
- }), _jsx(Arrow, {
21
- direction: "right",
22
- onClick: onNext
23
- })]
24
- })]
25
- }), children]
26
- });
27
- }