@companix/uikit 0.0.2 → 0.0.3

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 (254) hide show
  1. package/dist/bundle.es.js +61 -0
  2. package/dist/bundle.es10.js +87 -0
  3. package/dist/bundle.es11.js +75 -0
  4. package/dist/bundle.es12.js +38 -0
  5. package/dist/bundle.es13.js +33 -0
  6. package/dist/bundle.es14.js +18 -0
  7. package/dist/bundle.es15.js +11 -0
  8. package/dist/bundle.es16.js +35 -0
  9. package/dist/bundle.es17.js +27 -0
  10. package/dist/bundle.es18.js +23 -0
  11. package/dist/bundle.es19.js +24 -0
  12. package/dist/bundle.es20.js +15 -0
  13. package/dist/bundle.es21.js +41 -0
  14. package/dist/bundle.es22.js +18 -0
  15. package/dist/bundle.es23.js +36 -0
  16. package/dist/bundle.es24.js +23 -0
  17. package/dist/bundle.es25.js +42 -0
  18. package/dist/bundle.es26.js +114 -0
  19. package/dist/bundle.es27.js +115 -0
  20. package/dist/bundle.es28.js +38 -0
  21. package/dist/bundle.es29.js +13 -0
  22. package/dist/bundle.es3.js +45 -0
  23. package/dist/bundle.es30.js +27 -0
  24. package/dist/bundle.es31.js +38 -0
  25. package/dist/bundle.es35.js +43 -0
  26. package/dist/bundle.es36.js +442 -0
  27. package/dist/bundle.es37.js +24 -0
  28. package/dist/bundle.es38.js +26 -0
  29. package/dist/bundle.es39.js +83 -0
  30. package/dist/bundle.es4.js +14 -0
  31. package/dist/bundle.es40.js +20 -0
  32. package/dist/bundle.es41.js +16 -0
  33. package/dist/bundle.es43.js +7 -0
  34. package/dist/bundle.es44.js +23 -0
  35. package/dist/bundle.es45.js +16 -0
  36. package/dist/bundle.es46.js +72 -0
  37. package/dist/bundle.es47.js +70 -0
  38. package/dist/bundle.es48.js +34 -0
  39. package/dist/bundle.es49.js +70 -0
  40. package/dist/bundle.es5.js +88 -0
  41. package/dist/bundle.es50.js +33 -0
  42. package/dist/bundle.es51.js +78 -0
  43. package/dist/bundle.es52.js +51 -0
  44. package/dist/bundle.es53.js +45 -0
  45. package/dist/bundle.es54.js +40 -0
  46. package/dist/bundle.es55.js +36 -0
  47. package/dist/bundle.es56.js +9 -0
  48. package/dist/bundle.es57.js +9 -0
  49. package/dist/bundle.es58.js +7 -0
  50. package/dist/bundle.es59.js +9 -0
  51. package/dist/bundle.es6.js +87 -0
  52. package/dist/bundle.es60.js +8 -0
  53. package/dist/bundle.es61.js +19 -0
  54. package/dist/bundle.es62.js +15 -0
  55. package/dist/bundle.es63.js +22 -0
  56. package/dist/bundle.es64.js +45 -0
  57. package/dist/bundle.es65.js +28 -0
  58. package/dist/bundle.es66.js +34 -0
  59. package/dist/bundle.es67.js +6 -0
  60. package/dist/bundle.es68.js +12 -0
  61. package/dist/bundle.es69.js +47 -0
  62. package/dist/bundle.es7.js +80 -0
  63. package/dist/bundle.es70.js +11 -0
  64. package/dist/bundle.es71.js +18 -0
  65. package/dist/bundle.es72.js +32 -0
  66. package/dist/bundle.es73.js +35 -0
  67. package/dist/bundle.es74.js +6 -0
  68. package/dist/bundle.es75.js +7 -0
  69. package/dist/bundle.es76.js +7 -0
  70. package/dist/bundle.es77.js +11 -0
  71. package/dist/bundle.es78.js +17 -0
  72. package/dist/bundle.es79.js +7 -0
  73. package/dist/bundle.es8.js +29 -0
  74. package/dist/bundle.es80.js +17 -0
  75. package/dist/bundle.es81.js +25 -0
  76. package/dist/bundle.es9.js +47 -0
  77. package/dist/types/Button/index.d.ts +20 -0
  78. package/dist/types/ButtonGroup/index.d.ts +7 -0
  79. package/dist/types/Checkbox/index.d.ts +10 -0
  80. package/dist/types/Countdown/index.d.ts +7 -0
  81. package/dist/types/DateInput/index.d.ts +13 -0
  82. package/dist/types/DatePicker/Calendar.d.ts +14 -0
  83. package/dist/types/DatePicker/CalendarHeader.d.ts +10 -0
  84. package/dist/types/DatePicker/index.d.ts +12 -0
  85. package/dist/types/Dialog/index.d.ts +12 -0
  86. package/dist/types/DialogAlert/Alert.d.ts +19 -0
  87. package/dist/types/DialogAlert/Viewport.d.ts +8 -0
  88. package/dist/types/DialogAlert/index.d.ts +11 -0
  89. package/dist/types/Drawer/index.d.ts +13 -0
  90. package/dist/types/File/index.d.ts +10 -0
  91. package/dist/types/Form/index.d.ts +17 -0
  92. package/dist/types/Icon/index.d.ts +7 -0
  93. package/dist/types/LoadButton/index.d.ts +5 -0
  94. package/dist/types/NumberInput/index.d.ts +6 -0
  95. package/dist/types/OptionItem/OptionItem.d.ts +7 -0
  96. package/dist/types/OptionItem/OptionsList.d.ts +8 -0
  97. package/dist/types/Popover/index.d.ts +26 -0
  98. package/dist/types/Radio/index.d.ts +20 -0
  99. package/dist/types/Scrollable/ImitateScroll.d.ts +10 -0
  100. package/dist/types/Scrollable/index.d.ts +33 -0
  101. package/dist/types/Select/SelectInput.d.ts +14 -0
  102. package/dist/types/Select/index.d.ts +15 -0
  103. package/dist/types/SelectTags/index.d.ts +15 -0
  104. package/dist/types/Spinner/index.d.ts +8 -0
  105. package/dist/types/Stepper/index.d.ts +8 -0
  106. package/dist/types/Switch/index.d.ts +10 -0
  107. package/dist/types/Tabs/index.d.ts +13 -0
  108. package/dist/types/TextArea/index.d.ts +7 -0
  109. package/dist/types/Toaster/RemoveListener.d.ts +3 -0
  110. package/dist/types/Toaster/Toast.d.ts +9 -0
  111. package/dist/types/Toaster/Viewport.d.ts +13 -0
  112. package/dist/types/Toaster/index.d.ts +15 -0
  113. package/dist/types/Tooltip/index.d.ts +8 -0
  114. package/dist/types/__hooks/use-frooze-closing.d.ts +5 -0
  115. package/dist/types/__hooks/use-loading.d.ts +8 -0
  116. package/dist/types/__hooks/use-local-storage.d.ts +1 -0
  117. package/dist/types/__hooks/use-popover-position.d.ts +8 -0
  118. package/dist/types/__hooks/use-previos.d.ts +2 -0
  119. package/dist/types/__hooks/use-resize.d.ts +3 -0
  120. package/dist/types/__hooks/use-scrollbox.d.ts +7 -0
  121. package/dist/types/__hooks/use-stepper-input.d.ts +13 -0
  122. package/dist/types/__hooks/use-update.d.ts +1 -0
  123. package/dist/types/__hooks/useCalendar.d.ts +17 -0
  124. package/dist/types/__hooks/useCalendarOptions-copy.d.ts +22 -0
  125. package/dist/types/__hooks/useCalendarOptions.d.ts +31 -0
  126. package/dist/types/__libs/calendar.d.ts +25 -0
  127. package/dist/types/__utils/utils.d.ts +25 -0
  128. package/dist/types/index.d.ts +31 -0
  129. package/dist/types/types.d.ts +13 -0
  130. package/dist/uikit.css +1 -0
  131. package/package.json +10 -6
  132. package/.eslintrc +0 -54
  133. package/declaration.d.ts +0 -4
  134. package/index.html +0 -12
  135. package/playground/App.tsx +0 -166
  136. package/playground/Example.tsx +0 -14
  137. package/playground/Test.tsx +0 -44
  138. package/playground/animation-test-1/index.scss +0 -20
  139. package/playground/animation-test-1/index.tsx +0 -17
  140. package/playground/animation-test-2/index.scss +0 -62
  141. package/playground/animation-test-2/index.tsx +0 -32
  142. package/playground/bootstrap.tsx +0 -19
  143. package/playground/buttons/index.tsx +0 -132
  144. package/playground/checkbox/index.tsx +0 -64
  145. package/playground/date-input/index.tsx +0 -45
  146. package/playground/date-picker/index.tsx +0 -41
  147. package/playground/dialog/index.tsx +0 -92
  148. package/playground/dialog-alert/index.tsx +0 -47
  149. package/playground/drawer/index.tsx +0 -55
  150. package/playground/index.css +0 -33
  151. package/playground/index.scss +0 -270
  152. package/playground/input/index.tsx +0 -112
  153. package/playground/number-inputs/index.tsx +0 -50
  154. package/playground/popovers/index.tsx +0 -70
  155. package/playground/radio-group/index.tsx +0 -69
  156. package/playground/select/index.tsx +0 -72
  157. package/playground/select-tags/index.tsx +0 -36
  158. package/playground/styles.scss +0 -2
  159. package/playground/switch/index.tsx +0 -44
  160. package/playground/tabs/index.tsx +0 -16
  161. package/playground/test.scss +0 -0
  162. package/playground/text-area/index.tsx +0 -17
  163. package/playground/text-input/index.tsx +0 -12
  164. package/playground/toaster/index.tsx +0 -156
  165. package/playground/tooltip/index.tsx +0 -26
  166. package/src/Button/Button.scss +0 -128
  167. package/src/Button/index.tsx +0 -72
  168. package/src/ButtonGroup/ButtonGroup.scss +0 -18
  169. package/src/ButtonGroup/index.tsx +0 -20
  170. package/src/Checkbox/Checkbox.scss +0 -115
  171. package/src/Checkbox/index.tsx +0 -46
  172. package/src/Countdown/index.tsx +0 -54
  173. package/src/DateInput/DateInput.scss +0 -11
  174. package/src/DateInput/index.tsx +0 -96
  175. package/src/DatePicker/Calendar.scss +0 -125
  176. package/src/DatePicker/Calendar.tsx +0 -157
  177. package/src/DatePicker/CalendarHeader.tsx +0 -139
  178. package/src/DatePicker/DatePicker.scss +0 -0
  179. package/src/DatePicker/index.tsx +0 -177
  180. package/src/Dialog/Dialog.scss +0 -25
  181. package/src/Dialog/Popup.scss +0 -55
  182. package/src/Dialog/index.tsx +0 -31
  183. package/src/DialogAlert/Alert.scss +0 -52
  184. package/src/DialogAlert/Alert.tsx +0 -78
  185. package/src/DialogAlert/Viewport.tsx +0 -52
  186. package/src/DialogAlert/index.tsx +0 -37
  187. package/src/Drawer/Drawer.scss +0 -112
  188. package/src/Drawer/index.tsx +0 -46
  189. package/src/File/index.tsx +0 -60
  190. package/src/Form/Form.scss +0 -70
  191. package/src/Form/Input.scss +0 -24
  192. package/src/Form/index.tsx +0 -131
  193. package/src/Icon/icon.scss +0 -18
  194. package/src/Icon/index.tsx +0 -43
  195. package/src/LoadButton/index.tsx +0 -17
  196. package/src/NumberInput/index.tsx +0 -74
  197. package/src/OptionItem/Option.scss +0 -89
  198. package/src/OptionItem/OptionItem.tsx +0 -49
  199. package/src/OptionItem/OptionsList.tsx +0 -26
  200. package/src/Popover/Popover.scss +0 -80
  201. package/src/Popover/index.tsx +0 -117
  202. package/src/Radio/Radio.scss +0 -148
  203. package/src/Radio/index.tsx +0 -68
  204. package/src/Scrollable/ImitateScroll.tsx +0 -141
  205. package/src/Scrollable/Scrollable.scss +0 -50
  206. package/src/Scrollable/index.tsx +0 -141
  207. package/src/Select/Select.scss +0 -80
  208. package/src/Select/SelectInput.tsx +0 -131
  209. package/src/Select/index.tsx +0 -134
  210. package/src/SelectTags/SelectTags.scss +0 -66
  211. package/src/SelectTags/index.tsx +0 -192
  212. package/src/Spinner/Spinner.scss +0 -14
  213. package/src/Spinner/index.tsx +0 -19
  214. package/src/Stepper/StepperInput.scss +0 -35
  215. package/src/Stepper/index.tsx +0 -76
  216. package/src/Switch/Switch.scss +0 -102
  217. package/src/Switch/index.tsx +0 -49
  218. package/src/Tabs/Tabs.scss +0 -58
  219. package/src/Tabs/index.tsx +0 -89
  220. package/src/TextArea/TextArea.scss +0 -34
  221. package/src/TextArea/index.tsx +0 -51
  222. package/src/Toaster/RemoveListener.tsx +0 -11
  223. package/src/Toaster/Toast.tsx +0 -69
  224. package/src/Toaster/Toaster.scss +0 -151
  225. package/src/Toaster/Viewport.tsx +0 -117
  226. package/src/Toaster/index.tsx +0 -52
  227. package/src/Tooltip/Tooltip.scss +0 -28
  228. package/src/Tooltip/index.tsx +0 -33
  229. package/src/__hooks/use-frooze-closing.ts +0 -51
  230. package/src/__hooks/use-loading.ts +0 -34
  231. package/src/__hooks/use-local-storage.ts +0 -19
  232. package/src/__hooks/use-popover-position.ts +0 -24
  233. package/src/__hooks/use-previos.ts +0 -25
  234. package/src/__hooks/use-resize.ts +0 -41
  235. package/src/__hooks/use-scrollbox.ts +0 -45
  236. package/src/__hooks/use-stepper-input.ts +0 -82
  237. package/src/__hooks/use-update.ts +0 -19
  238. package/src/__hooks/useCalendar.ts +0 -104
  239. package/src/__hooks/useCalendarOptions-copy.ts +0 -87
  240. package/src/__hooks/useCalendarOptions.ts +0 -68
  241. package/src/__libs/calendar.ts +0 -175
  242. package/src/__utils/utils.ts +0 -137
  243. package/src/css.scss +0 -120
  244. package/src/index.scss +0 -22
  245. package/src/index.ts +0 -36
  246. package/src/mixins.scss +0 -99
  247. package/src/theme.scss +0 -103
  248. package/src/types.ts +0 -14
  249. package/tailwind.config.js +0 -91
  250. package/themes/classic/animations.scss +0 -179
  251. package/themes/classic/classic.scss +0 -493
  252. package/tsconfig.json +0 -27
  253. package/vite.build.ts +0 -35
  254. package/vite.config.ts +0 -33
@@ -1,87 +0,0 @@
1
- import { DefaultMonths, getMonthMaxDay } from '../__utils/utils'
2
- import { range } from '@companix/utils-js'
3
- import { useMemo } from 'react'
4
-
5
- export const defaultMax = new Date(2050, 0, 1)
6
- export const defaultMin = new Date(1925, 0, 1)
7
-
8
- interface Options {
9
- min?: Date
10
- max?: Date
11
- now: Date
12
- }
13
-
14
- const getDate = (date: Date) => {
15
- return {
16
- day: date.getDate(),
17
- month: date.getMonth(),
18
- year: date.getFullYear()
19
- }
20
- }
21
-
22
- export const useCalendarOptions2 = ({ min = defaultMin, max = defaultMax, now }: Options) => {
23
- const max_values = useMemo(() => getDate(max), [max])
24
- const min_values = useMemo(() => getDate(min), [min])
25
- const now_values = useMemo(() => getDate(now), [now])
26
-
27
- const years = useMemo(() => {
28
- return range(max_values.year, min_values.year).map((value) => ({
29
- title: value.toString(),
30
- value
31
- }))
32
- }, [max_values.year, min_values.year])
33
-
34
- const months = useMemo(() => {
35
- const options = DefaultMonths.map((name, index) => ({
36
- title: name,
37
- value: index
38
- }))
39
-
40
- if (min_values.month && now_values.year === min_values.year) {
41
- const i = options.findIndex(({ value }) => value === min_values.month)
42
- options.splice(0, i)
43
- }
44
-
45
- if (max_values.month && now_values.year === max_values.year) {
46
- const i = options.findIndex(({ value }) => value === max_values.month)
47
- options.splice(i + 1, options.length)
48
- }
49
-
50
- return options
51
- }, [now_values.year, min_values.year, min_values.month, max_values.year, max_values.month])
52
-
53
- const days = useMemo(() => {
54
- if (now_values.month === 0) {
55
- return []
56
- }
57
-
58
- const maxDays = getMonthMaxDay(now_values.month, now_values.year)
59
-
60
- const options = Array.from({ length: maxDays }, (_, i) => ({
61
- title: `${i + 1}`,
62
- value: i + 1
63
- }))
64
-
65
- if (
66
- min_values.day &&
67
- now_values.month === min_values.month &&
68
- now_values.year === min_values.year
69
- ) {
70
- const i = options.findIndex(({ value }) => value === min_values.day)
71
- options.splice(0, i)
72
- }
73
-
74
- if (
75
- max_values.day &&
76
- now_values.month === max_values.month &&
77
- now_values.year === max_values.year
78
- ) {
79
- const i = options.findIndex(({ value }) => value === max_values.day)
80
- options.splice(i + 1, options.length)
81
- }
82
-
83
- return options
84
- }, [now_values.month, now_values.year, min, max])
85
-
86
- return { years, months, days }
87
- }
@@ -1,68 +0,0 @@
1
- import { DefaultMonths, getMonthMaxDay } from '../__utils/utils'
2
- import { useMemo } from 'react'
3
- import { DateFormat } from '..'
4
- import { range } from '@companix/utils-js'
5
-
6
- export const defaultMax = { day: 31, month: 12, year: 2050 }
7
- export const defaultMin = { day: 1, month: 1, year: 1900 }
8
-
9
- interface Options {
10
- min?: DateFormat
11
- max?: DateFormat
12
- now: DateFormat
13
- }
14
-
15
- export const useCalendarOptions = ({ min = defaultMin, max = defaultMax, now }: Options) => {
16
- const years = useMemo(() => {
17
- return range(max.year, min.year).map((value) => ({
18
- title: value.toString(),
19
- value
20
- }))
21
- }, [max.year, min.year])
22
-
23
- const months = useMemo(() => {
24
- const options = DefaultMonths.map((name, index) => ({
25
- title: name,
26
- value: index + 1
27
- }))
28
-
29
- if (min.month && now.year === min.year) {
30
- const i = options.findIndex(({ value }) => value === min.month)
31
- options.splice(0, i)
32
- }
33
-
34
- if (max.month && now.year === max.year) {
35
- const i = options.findIndex(({ value }) => value === max.month)
36
- options.splice(i + 1, options.length)
37
- }
38
-
39
- return options
40
- }, [now.year, min.year, min.month, max.year, max.month])
41
-
42
- const days = useMemo(() => {
43
- if (now.month === 0) {
44
- return []
45
- }
46
-
47
- const maxDays = getMonthMaxDay(now.month, now.year)
48
-
49
- const options = Array.from({ length: maxDays }, (_, i) => ({
50
- title: `${i + 1}`,
51
- value: i + 1
52
- }))
53
-
54
- if (min.day && now.month === min.month && now.year === min.year) {
55
- const i = options.findIndex(({ value }) => value === min.day)
56
- options.splice(0, i)
57
- }
58
-
59
- if (max.day && now.month === max.month && now.year === max.year) {
60
- const i = options.findIndex(({ value }) => value === max.day)
61
- options.splice(i + 1, options.length)
62
- }
63
-
64
- return options
65
- }, [now.month, now.year, min, max])
66
-
67
- return { years, months, days }
68
- }
@@ -1,175 +0,0 @@
1
- import { CalendarProps } from '../DatePicker/Calendar'
2
- import { useCallback, useMemo } from 'react'
3
-
4
- export function isSameDate(d1: Date, d2: Date): boolean {
5
- return (
6
- d1.getDate() === d2.getDate() &&
7
- d1.getMonth() === d2.getMonth() &&
8
- d1.getFullYear() === d2.getFullYear()
9
- )
10
- }
11
-
12
- export const MONDAY = 1
13
-
14
- /**
15
- * Возвращает дату начала недели
16
- */
17
- export function startOfWeek(date: Date, { weekStartsOn = MONDAY }): Date {
18
- const result = new Date(date)
19
- const day = result.getDay()
20
- const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn
21
-
22
- result.setDate(result.getDate() - diff)
23
- result.setHours(0, 0, 0, 0)
24
- return result
25
- }
26
-
27
- /**
28
- * Возвращает дату конца недели
29
- */
30
- export function endOfWeek(date: Date, { weekStartsOn = MONDAY }): Date {
31
- const result = new Date(date)
32
- const day = result.getDay()
33
- const diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn)
34
-
35
- result.setDate(result.getDate() + diff)
36
- result.setHours(23, 59, 59, 999)
37
- return result
38
- }
39
-
40
- /**
41
- * Возвращает дату начала дня
42
- */
43
- export function startOfDay(date: Date): Date {
44
- const result = new Date(date)
45
- result.setHours(0, 0, 0, 0)
46
- return result
47
- }
48
-
49
- /**
50
- * Возвращает дату конца дня
51
- */
52
- export function endOfDay(date: Date): Date {
53
- const result = new Date(date)
54
- result.setHours(23, 59, 59, 999)
55
- return result
56
- }
57
-
58
- /**
59
- * Позволяет определить удовлетворяет ли исходная дата заданным ограничения `min` и/или `max`
60
- */
61
- export function isDayMinMaxRestricted(
62
- day: Date,
63
- options: { min?: Date; max?: Date; withTime?: boolean } = {}
64
- ): boolean {
65
- const { min, max, withTime = false } = options
66
-
67
- if (!withTime && ((min && isSameDate(day, min)) || (max && isSameDate(day, max)))) {
68
- return false
69
- }
70
-
71
- return Boolean((min && day < min) || (max && day > max))
72
- }
73
-
74
- export function addMonths(date: Date, amount: number): Date {
75
- const result = new Date(date)
76
-
77
- if (!amount) {
78
- return result
79
- }
80
-
81
- const dayOfMonth = result.getDate()
82
-
83
- const endOfDesiredMonth = new Date(date)
84
- endOfDesiredMonth.setMonth(result.getMonth() + amount + 1, 0) // Конец месяца
85
- const daysInMonth = endOfDesiredMonth.getDate()
86
- if (dayOfMonth >= daysInMonth) {
87
- // Если мы уже находимся в конце месяца, то это нужная дата
88
- return endOfDesiredMonth
89
- }
90
-
91
- result.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth)
92
- return result
93
- }
94
-
95
- export function subMonths(date: Date, amount: number): Date {
96
- return addMonths(date, -amount)
97
- }
98
-
99
- // set
100
-
101
- function getDaysInMonth(date: Date): number {
102
- const result = new Date(date)
103
- const lastDayOfMonth = new Date(result)
104
- lastDayOfMonth.setFullYear(result.getFullYear(), result.getMonth() + 1, 0)
105
- lastDayOfMonth.setHours(0, 0, 0, 0)
106
- return lastDayOfMonth.getDate()
107
- }
108
-
109
- export function setYear(date: Date, year: number): Date {
110
- const result = new Date(date)
111
- result.setFullYear(year)
112
- return result
113
- }
114
-
115
- export function setMonth(date: Date, month: number): Date {
116
- const result = new Date(date)
117
- const year = result.getFullYear()
118
- const day = result.getDate()
119
-
120
- const midMonth = new Date(date)
121
- midMonth.setFullYear(year, month, 15)
122
- midMonth.setHours(0, 0, 0, 0)
123
- const daysInMonth = getDaysInMonth(midMonth)
124
-
125
- result.setMonth(month, Math.min(day, daysInMonth))
126
- return result
127
- }
128
-
129
- // custom
130
-
131
- interface DisableOptions
132
- extends Pick<
133
- CalendarProps,
134
- 'disableFuture' | 'disablePast' | 'maxDateTime' | 'minDateTime' | 'shouldDisableDate'
135
- > {}
136
-
137
- export const createDayDisableChecker = (options: DisableOptions) => {
138
- const { disableFuture, disablePast, maxDateTime, minDateTime, shouldDisableDate } = options
139
-
140
- return (day: Date, withTime?: boolean) => {
141
- const now = new Date()
142
-
143
- if (shouldDisableDate) {
144
- return shouldDisableDate(day)
145
- }
146
-
147
- if (disableFuture) {
148
- return startOfDay(day) > now
149
- }
150
-
151
- if (disablePast) {
152
- return endOfDay(day) < now
153
- }
154
-
155
- if (minDateTime || maxDateTime) {
156
- return isDayMinMaxRestricted(day, { min: minDateTime, max: maxDateTime, withTime })
157
- }
158
-
159
- return false
160
- }
161
- }
162
-
163
- export const useDayDisableCheker = (options: DisableOptions) => {
164
- const isDayDisabled = useMemo(() => {
165
- return createDayDisableChecker(options)
166
- }, [
167
- options.disableFuture,
168
- options.disablePast,
169
- options.shouldDisableDate,
170
- options.minDateTime,
171
- options.maxDateTime
172
- ])
173
-
174
- return useCallback(isDayDisabled, [isDayDisabled])
175
- }
@@ -1,137 +0,0 @@
1
- import { clamp } from '@companix/utils-browser'
2
- import { DateFormat, Option } from '..'
3
-
4
- export const getMonthMaxDay = (month: number, year: number) => {
5
- return new Date(year, month, 0).getDate()
6
- }
7
-
8
- export const getFirstDay = (month: number, year: number) => {
9
- return new Date(year, month - 1, 1).getDay()
10
- }
11
-
12
- // 0 is Monday, 6 - is Sunday
13
- export const getDayIndex = (day: number) => {
14
- return day === 0 ? 6 : day - 1
15
- }
16
-
17
- export const createVoids = (length: number) => {
18
- return new Array(length).fill(0)
19
- }
20
-
21
- export const dateToFormat = (date: Date): DateFormat => {
22
- return {
23
- day: date.getDate(),
24
- month: date.getMonth() + 1,
25
- year: date.getFullYear()
26
- }
27
- }
28
-
29
- export const createDateValidation = ({ min, max }: { min: DateFormat; max: DateFormat }) => {
30
- return (value: DateFormat) => {
31
- if (min.year === value.year) {
32
- if (value.month !== 0 && value.month < min.month) {
33
- value.month = 0
34
- value.day = 0
35
-
36
- return value
37
- }
38
-
39
- if (value.month === min.month && value.day < min.day && value.day !== 0) {
40
- value.day = 0
41
-
42
- return value
43
- }
44
- }
45
-
46
- if (max.year === value.year) {
47
- if (value.month !== 0 && value.month > max.month) {
48
- value.month = 0
49
- value.day = 0
50
-
51
- return value
52
- }
53
-
54
- if (value.month === max.month && value.day > max.day && value.day !== 0) {
55
- value.day = 0
56
-
57
- return value
58
- }
59
- }
60
- }
61
- }
62
-
63
- export const createRangeValidation = ({ min, max }: { min?: DateFormat; max?: DateFormat }) => {
64
- const minTime = min ? new Date(formatToDate(min)).getTime() : 0
65
- const maxTime = max ? new Date(formatToDate(max)).getTime() : Infinity
66
-
67
- const getCurrentTime = (value: DateFormat) => {
68
- return new Date(formatToDate(value)).getTime()
69
- }
70
-
71
- return {
72
- isDateMinValid: (value: DateFormat) => {
73
- return getCurrentTime(value) > minTime
74
- },
75
- isDateMaxValid: (value: DateFormat) => {
76
- return getCurrentTime(value) < maxTime
77
- },
78
- isDateInRange: (value: DateFormat) => {
79
- const current = getCurrentTime(value)
80
-
81
- return current > minTime && current < maxTime
82
- }
83
- }
84
- }
85
-
86
- export const formatToDate = (format: DateFormat): Date => {
87
- return new Date(format.year, format.month - 1, format.day)
88
- }
89
-
90
- export const weeks = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']
91
-
92
- export const DefaultMonths = [
93
- 'Январь',
94
- 'Февраль',
95
- 'Март',
96
- 'Апрель',
97
- 'Май',
98
- 'Июнь',
99
- 'Июль',
100
- 'Август',
101
- 'Сентябрь',
102
- 'Октябрь',
103
- 'Ноябрь',
104
- 'Декабрь'
105
- ]
106
-
107
- export const DEFAULT_MAX_YEAR = 9999
108
- export const DEFAULT_MIN_YEAR = 100
109
-
110
- export const getYears = (currentYear: number, range: number): Option<number>[] => {
111
- const years: Option<number>[] = []
112
-
113
- const minYear = clamp(currentYear - range, DEFAULT_MIN_YEAR, DEFAULT_MAX_YEAR)
114
- const maxYear = clamp(currentYear + range, DEFAULT_MIN_YEAR, DEFAULT_MAX_YEAR)
115
-
116
- for (let i = minYear; i <= maxYear; i++) {
117
- years.push({ title: String(i).padStart(4, '0'), value: i })
118
- }
119
-
120
- return years
121
- }
122
-
123
- export const getMonths = (locale?: string): Option<number>[] => {
124
- const months: Option<number>[] = []
125
- const formatter = new Intl.DateTimeFormat(locale, {
126
- month: 'long'
127
- })
128
-
129
- for (let i = 0; i < 12; i++) {
130
- months.push({
131
- title: formatter.format(new Date(2023, i, 15)),
132
- value: i
133
- })
134
- }
135
-
136
- return months
137
- }
package/src/css.scss DELETED
@@ -1,120 +0,0 @@
1
- $properties: (
2
- // Layout
3
- display,
4
- position,
5
- top,
6
- right,
7
- bottom,
8
- left,
9
- z-index,
10
- float,
11
- clear,
12
- overflow,
13
- overflow-x,
14
- overflow-y,
15
- visibility,
16
- // Box model
17
- box-sizing,
18
- width,
19
- min-width,
20
- max-width,
21
- height,
22
- min-height,
23
- max-height,
24
- margin,
25
- margin-top,
26
- margin-right,
27
- margin-bottom,
28
- margin-left,
29
- padding,
30
- padding-top,
31
- padding-right,
32
- padding-bottom,
33
- padding-left,
34
- // Flexbox
35
- flex,
36
- flex-direction,
37
- flex-wrap,
38
- flex-grow,
39
- flex-shrink,
40
- flex-basis,
41
- justify-content,
42
- align-items,
43
- align-content,
44
- align-self,
45
- gap,
46
- row-gap,
47
- column-gap,
48
- // Grid
49
- grid,
50
- grid-template-columns,
51
- grid-template-rows,
52
- grid-template-areas,
53
- grid-column,
54
- grid-row,
55
- grid-area,
56
- // Typography
57
- color,
58
- font,
59
- font-family,
60
- font-size,
61
- font-weight,
62
- font-style,
63
- font-stretch,
64
- line-height,
65
- letter-spacing,
66
- text-align,
67
- text-decoration,
68
- text-transform,
69
- text-overflow,
70
- white-space,
71
- word-break,
72
- word-wrap,
73
- // Background
74
- background,
75
- background-color,
76
- background-image,
77
- background-repeat,
78
- background-position,
79
- background-size,
80
- // Border
81
- border,
82
- border-width,
83
- border-style,
84
- border-color,
85
- border-radius,
86
- border-top,
87
- border-right,
88
- border-bottom,
89
- border-left,
90
- // Effects
91
- box-shadow,
92
- opacity,
93
- filter,
94
- // Transform & animation
95
- transform,
96
- transform-origin,
97
- transition,
98
- transition-property,
99
- transition-duration,
100
- transition-timing-function,
101
- transition-delay,
102
- animation,
103
- animation-name,
104
- animation-duration,
105
- animation-timing-function,
106
- animation-delay,
107
- animation-iteration-count,
108
- animation-direction,
109
- animation-fill-mode,
110
- // Interaction
111
- cursor,
112
- pointer-events,
113
- user-select,
114
- // Misc
115
- outline,
116
- outline-offset,
117
- resize,
118
- object-fit,
119
- object-position
120
- );
package/src/index.scss DELETED
@@ -1,22 +0,0 @@
1
- @use './Button/Button.scss';
2
- @use './Icon/icon.scss';
3
- @use './Popover/Popover.scss';
4
- @use './Tooltip/Tooltip.scss';
5
- @use './Checkbox/Checkbox.scss';
6
- @use './Radio/Radio.scss';
7
- @use './Tabs/Tabs.scss';
8
- @use './Toaster/Toaster.scss';
9
- @use './Dialog/Popup.scss';
10
- @use './Dialog/Dialog.scss';
11
- @use './DialogAlert/Alert.scss';
12
- @use './Drawer/Drawer.scss';
13
- @use './Form/Form.scss';
14
- @use './Select/Select.scss';
15
- @use './TextArea/TextArea.scss';
16
- @use './SelectTags/SelectTags.scss';
17
- @use './OptionItem/Option.scss';
18
- @use './DateInput/DateInput.scss';
19
- @use './DatePicker/DatePicker.scss';
20
- @use './DatePicker/Calendar.scss';
21
- @use './Form/Input.scss';
22
- @use './Switch/Switch.scss';
package/src/index.ts DELETED
@@ -1,36 +0,0 @@
1
- import './theme.scss'
2
-
3
- export { Button } from './Button'
4
- export { Spinner } from './Spinner'
5
- export { Scrollable } from './Scrollable'
6
- export { ImitateScroll } from './Scrollable/ImitateScroll'
7
- export { Popover } from './Popover'
8
- export { Tooltip } from './Tooltip'
9
- export { StepperInput } from './Stepper'
10
- export { Select } from './Select'
11
- export { Form } from './Form'
12
- export { OptionItem } from './OptionItem/OptionItem'
13
- export { NumberInput } from './NumberInput'
14
- export { OptionsList } from './OptionItem/OptionsList'
15
- export { ButtonGroup } from './ButtonGroup'
16
- export { Checkbox } from './Checkbox'
17
- export { Switch } from './Switch'
18
- export { Radio } from './Radio'
19
- export { Drawer } from './Drawer'
20
- export { Dialog } from './Dialog'
21
- export { AlertDialog } from './DialogAlert/Alert'
22
- export { LoadButton } from './LoadButton'
23
- export { Tabs } from './Tabs'
24
- export { Countdown } from './Countdown'
25
- export { TextArea } from './TextArea'
26
- export { SelectTags } from './SelectTags'
27
- export { DatePicker } from './DatePicker'
28
- export { FileOverlay } from './File'
29
- // hooks
30
- export * from './__hooks/use-local-storage'
31
- // agents
32
- export { createAlertAgent } from './DialogAlert'
33
- export { createToaster } from './Toaster'
34
- // types
35
- export * from './types'
36
- export type { Appearance } from './Button'