@helpwave/hightide 0.0.8 → 0.0.11

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 (300) hide show
  1. package/README.md +1 -1
  2. package/dist/coloring/shading.d.ts +2 -0
  3. package/dist/coloring/shading.js +40 -0
  4. package/dist/coloring/types.d.ts +11 -0
  5. package/dist/coloring/types.js +1 -0
  6. package/dist/components/Avatar.d.ts +14 -0
  7. package/dist/components/Avatar.js +35 -0
  8. package/dist/components/AvatarGroup.d.ts +10 -0
  9. package/dist/components/AvatarGroup.js +13 -0
  10. package/dist/components/BreadCrumb.d.ts +16 -0
  11. package/dist/components/BreadCrumb.js +12 -0
  12. package/dist/components/Button.d.ts +41 -0
  13. package/dist/components/Button.js +84 -0
  14. package/dist/components/ChipList.d.ts +21 -0
  15. package/dist/components/ChipList.js +38 -0
  16. package/dist/components/Circle.d.ts +6 -0
  17. package/dist/components/Circle.js +10 -0
  18. package/dist/components/ErrorComponent.d.ts +13 -0
  19. package/dist/components/ErrorComponent.js +19 -0
  20. package/dist/components/Expandable.d.ts +30 -0
  21. package/dist/components/Expandable.js +16 -0
  22. package/dist/components/HelpwaveBadge.d.ts +11 -0
  23. package/dist/components/HelpwaveBadge.js +14 -0
  24. package/dist/components/HideableContentSection.d.ts +10 -0
  25. package/dist/components/HideableContentSection.js +15 -0
  26. package/dist/components/InputGroup.d.ts +13 -0
  27. package/dist/components/InputGroup.js +33 -0
  28. package/dist/components/LoadingAndErrorComponent.d.ts +17 -0
  29. package/dist/components/LoadingAndErrorComponent.js +25 -0
  30. package/dist/components/LoadingAnimation.d.ts +13 -0
  31. package/dist/components/LoadingAnimation.js +19 -0
  32. package/dist/components/LoadingButton.d.ts +6 -0
  33. package/dist/components/LoadingButton.js +10 -0
  34. package/dist/components/MarkdownInterpreter.d.ts +25 -0
  35. package/dist/components/MarkdownInterpreter.js +190 -0
  36. package/dist/components/Pagination.d.ts +14 -0
  37. package/dist/components/Pagination.js +25 -0
  38. package/dist/components/Profile.d.ts +28 -0
  39. package/dist/components/Profile.js +45 -0
  40. package/dist/components/ProgressIndicator.d.ts +21 -0
  41. package/dist/components/ProgressIndicator.js +24 -0
  42. package/dist/components/Ring.d.ts +31 -0
  43. package/dist/components/Ring.js +113 -0
  44. package/dist/components/SearchableList.d.ts +18 -0
  45. package/dist/components/SearchableList.js +27 -0
  46. package/dist/components/SortButton.d.ts +10 -0
  47. package/dist/components/SortButton.js +9 -0
  48. package/dist/components/Span.js +1 -0
  49. package/dist/components/StepperBar.d.ts +23 -0
  50. package/dist/components/StepperBar.js +47 -0
  51. package/dist/components/Table.d.ts +87 -0
  52. package/dist/components/Table.js +187 -0
  53. package/dist/components/TechRadar.d.ts +36 -0
  54. package/dist/components/TechRadar.js +191 -0
  55. package/dist/components/TextImage.d.ts +20 -0
  56. package/dist/components/TextImage.js +31 -0
  57. package/dist/components/TimeDisplay.d.ts +30 -0
  58. package/dist/components/TimeDisplay.js +83 -0
  59. package/dist/components/Tooltip.d.ts +34 -0
  60. package/dist/components/Tooltip.js +38 -0
  61. package/dist/components/VerticalDivider.d.ts +11 -0
  62. package/dist/components/VerticalDivider.js +7 -0
  63. package/dist/components/date/DatePicker.d.ts +26 -0
  64. package/dist/components/date/DatePicker.js +58 -0
  65. package/dist/components/date/DayPicker.d.ts +16 -0
  66. package/dist/components/date/DayPicker.js +37 -0
  67. package/dist/components/date/TimePicker.d.ts +12 -0
  68. package/dist/components/date/TimePicker.js +79 -0
  69. package/dist/components/date/YearMonthPicker.d.ts +11 -0
  70. package/dist/components/date/YearMonthPicker.js +59 -0
  71. package/dist/components/examples/InputGroupExample.d.ts +6 -0
  72. package/dist/components/examples/InputGroupExample.js +21 -0
  73. package/dist/components/examples/MultiSelectExample.d.ts +7 -0
  74. package/dist/components/examples/MultiSelectExample.js +27 -0
  75. package/dist/components/examples/SearchableSelectExample.d.ts +6 -0
  76. package/dist/components/examples/SearchableSelectExample.js +17 -0
  77. package/dist/components/examples/SelectExample.d.ts +4 -0
  78. package/dist/components/examples/SelectExample.js +15 -0
  79. package/dist/components/examples/StackingModals.d.ts +4 -0
  80. package/dist/components/examples/StackingModals.js +15 -0
  81. package/dist/components/examples/TableExample.d.ts +9 -0
  82. package/dist/components/examples/TableExample.js +92 -0
  83. package/dist/components/examples/TextareaExample.d.ts +6 -0
  84. package/dist/components/examples/TextareaExample.js +10 -0
  85. package/dist/components/examples/TileExample.d.ts +9 -0
  86. package/dist/components/examples/TileExample.js +9 -0
  87. package/dist/components/examples/Title.js +1 -0
  88. package/dist/components/examples/date/DateTimePickerExample.d.ts +10 -0
  89. package/dist/components/examples/date/DateTimePickerExample.js +21 -0
  90. package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +8 -0
  91. package/dist/components/examples/properties/CheckboxPropertyExample.js +13 -0
  92. package/dist/components/examples/properties/DatePropertyExample.d.ts +8 -0
  93. package/dist/components/examples/properties/DatePropertyExample.js +23 -0
  94. package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +8 -0
  95. package/dist/components/examples/properties/MultiSelectPropertyExample.js +16 -0
  96. package/dist/components/examples/properties/NumberPropertyExample.d.ts +6 -0
  97. package/dist/components/examples/properties/NumberPropertyExample.js +13 -0
  98. package/dist/components/examples/properties/SelectPropertyExample.d.ts +6 -0
  99. package/dist/components/examples/properties/SelectPropertyExample.js +18 -0
  100. package/dist/components/examples/properties/TextPropertyExample.d.ts +8 -0
  101. package/dist/components/examples/properties/TextPropertyExample.js +13 -0
  102. package/dist/components/icons/Helpwave.d.ts +10 -0
  103. package/dist/components/icons/Helpwave.js +20 -0
  104. package/dist/components/icons/Tag.d.ts +10 -0
  105. package/dist/components/icons/Tag.js +12 -0
  106. package/dist/components/layout/Carousel.d.ts +22 -0
  107. package/dist/components/layout/Carousel.js +233 -0
  108. package/dist/components/layout/DividerInserter.d.ts +11 -0
  109. package/dist/components/layout/DividerInserter.js +20 -0
  110. package/dist/components/layout/FAQSection.d.ts +23 -0
  111. package/dist/components/layout/FAQSection.js +14 -0
  112. package/dist/components/layout/Tile.d.ts +34 -0
  113. package/dist/components/layout/Tile.js +18 -0
  114. package/dist/components/modals/ConfirmDialog.d.ts +34 -0
  115. package/dist/components/modals/ConfirmDialog.js +31 -0
  116. package/dist/components/modals/DiscardChangesDialog.d.ts +19 -0
  117. package/dist/components/modals/DiscardChangesDialog.js +24 -0
  118. package/dist/components/modals/InputModal.d.ts +9 -0
  119. package/dist/components/modals/InputModal.js +9 -0
  120. package/dist/components/modals/LanguageModal.d.ts +17 -0
  121. package/dist/components/modals/LanguageModal.js +35 -0
  122. package/dist/components/modals/Modal.d.ts +38 -0
  123. package/dist/components/modals/Modal.js +57 -0
  124. package/dist/components/modals/ModalRegister.d.ts +11 -0
  125. package/dist/components/modals/ModalRegister.js +28 -0
  126. package/dist/components/properties/CheckboxProperty.d.ts +15 -0
  127. package/dist/components/properties/CheckboxProperty.js +27 -0
  128. package/dist/components/properties/DateProperty.d.ts +11 -0
  129. package/dist/components/properties/DateProperty.js +22 -0
  130. package/dist/components/properties/MultiSelectProperty.d.ts +12 -0
  131. package/dist/components/properties/MultiSelectProperty.js +33 -0
  132. package/dist/components/properties/NumberProperty.d.ts +16 -0
  133. package/dist/components/properties/NumberProperty.js +42 -0
  134. package/dist/components/properties/PropertyBase.d.ts +23 -0
  135. package/dist/components/properties/PropertyBase.js +27 -0
  136. package/dist/components/properties/SelectProperty.d.ts +12 -0
  137. package/dist/components/properties/SelectProperty.js +22 -0
  138. package/dist/components/properties/TextProperty.d.ts +15 -0
  139. package/dist/components/properties/TextProperty.js +37 -0
  140. package/dist/components/user-input/Checkbox.d.ts +37 -0
  141. package/dist/components/user-input/Checkbox.js +63 -0
  142. package/dist/components/user-input/DateAndTimePicker.d.ts +39 -0
  143. package/dist/components/user-input/DateAndTimePicker.js +65 -0
  144. package/dist/components/user-input/Input.d.ts +61 -0
  145. package/dist/components/user-input/Input.js +61 -0
  146. package/dist/components/user-input/Label.d.ts +12 -0
  147. package/dist/components/user-input/Label.js +12 -0
  148. package/dist/components/user-input/Menu.d.ts +21 -0
  149. package/dist/components/user-input/Menu.js +26 -0
  150. package/dist/components/user-input/MultiSelect.d.ts +39 -0
  151. package/dist/components/user-input/MultiSelect.js +57 -0
  152. package/dist/components/user-input/ScrollPicker.d.ts +11 -0
  153. package/dist/components/user-input/ScrollPicker.js +151 -0
  154. package/dist/components/user-input/SearchableSelect.d.ts +8 -0
  155. package/dist/components/user-input/SearchableSelect.js +14 -0
  156. package/dist/components/user-input/Select.d.ts +32 -0
  157. package/dist/components/user-input/Select.js +48 -0
  158. package/dist/components/user-input/Textarea.d.ts +20 -0
  159. package/dist/components/user-input/Textarea.js +33 -0
  160. package/dist/components/user-input/ToggleableInput.d.ts +32 -0
  161. package/dist/components/user-input/ToggleableInput.js +40 -0
  162. package/{globals.css → dist/css/globals.css} +1 -1
  163. package/dist/hooks/useHoverState.d.ts +40 -0
  164. package/dist/hooks/useHoverState.js +46 -0
  165. package/dist/hooks/useLanguage.d.ts +17 -0
  166. package/dist/hooks/useLanguage.js +51 -0
  167. package/dist/hooks/useLocalStorage.d.ts +4 -0
  168. package/dist/hooks/useLocalStorage.js +24 -0
  169. package/dist/hooks/useOutsideClick.d.ts +2 -0
  170. package/dist/hooks/useOutsideClick.js +22 -0
  171. package/dist/hooks/useSaveDelay.d.ts +5 -0
  172. package/dist/hooks/useSaveDelay.js +41 -0
  173. package/dist/hooks/useTheme.d.ts +16 -0
  174. package/dist/hooks/useTheme.js +32 -0
  175. package/dist/hooks/useTranslation.d.ts +24 -0
  176. package/dist/hooks/useTranslation.js +11 -0
  177. package/dist/util/array.d.ts +23 -0
  178. package/dist/util/array.js +103 -0
  179. package/{util/builder.ts → dist/util/builder.d.ts} +1 -4
  180. package/dist/util/builder.js +9 -0
  181. package/dist/util/date.d.ts +28 -0
  182. package/dist/util/date.js +133 -0
  183. package/dist/util/easeFunctions.d.ts +9 -0
  184. package/dist/util/easeFunctions.js +30 -0
  185. package/dist/util/emailValidation.d.ts +1 -0
  186. package/dist/util/emailValidation.js +3 -0
  187. package/dist/util/loopingArray.d.ts +23 -0
  188. package/dist/util/loopingArray.js +67 -0
  189. package/dist/util/math.d.ts +1 -0
  190. package/dist/util/math.js +3 -0
  191. package/dist/util/news.d.ts +98 -0
  192. package/dist/util/news.js +27 -0
  193. package/dist/util/noop.d.ts +1 -0
  194. package/dist/util/noop.js +1 -0
  195. package/{util/simpleSearch.ts → dist/util/simpleSearch.d.ts} +4 -21
  196. package/dist/util/simpleSearch.js +62 -0
  197. package/dist/util/storage.d.ts +15 -0
  198. package/dist/util/storage.js +32 -0
  199. package/dist/util/types.d.ts +1 -0
  200. package/dist/util/types.js +1 -0
  201. package/package.json +7 -8
  202. package/coloring/shading.ts +0 -46
  203. package/coloring/types.ts +0 -13
  204. package/components/Avatar.tsx +0 -58
  205. package/components/AvatarGroup.tsx +0 -48
  206. package/components/BreadCrumb.tsx +0 -35
  207. package/components/Button.tsx +0 -236
  208. package/components/ChipList.tsx +0 -89
  209. package/components/Circle.tsx +0 -27
  210. package/components/ErrorComponent.tsx +0 -40
  211. package/components/Expandable.tsx +0 -61
  212. package/components/HelpwaveBadge.tsx +0 -35
  213. package/components/HideableContentSection.tsx +0 -43
  214. package/components/InputGroup.tsx +0 -72
  215. package/components/LoadingAndErrorComponent.tsx +0 -47
  216. package/components/LoadingAnimation.tsx +0 -40
  217. package/components/LoadingButton.tsx +0 -27
  218. package/components/MarkdownInterpreter.tsx +0 -278
  219. package/components/Pagination.tsx +0 -65
  220. package/components/Profile.tsx +0 -124
  221. package/components/ProgressIndicator.tsx +0 -58
  222. package/components/Ring.tsx +0 -286
  223. package/components/SearchableList.tsx +0 -69
  224. package/components/SortButton.tsx +0 -33
  225. package/components/StepperBar.tsx +0 -124
  226. package/components/Table.tsx +0 -330
  227. package/components/TechRadar.tsx +0 -247
  228. package/components/TextImage.tsx +0 -86
  229. package/components/TimeDisplay.tsx +0 -121
  230. package/components/Tooltip.tsx +0 -92
  231. package/components/VerticalDivider.tsx +0 -51
  232. package/components/date/DatePicker.tsx +0 -164
  233. package/components/date/DayPicker.tsx +0 -95
  234. package/components/date/TimePicker.tsx +0 -167
  235. package/components/date/YearMonthPicker.tsx +0 -130
  236. package/components/examples/InputGroupExample.tsx +0 -58
  237. package/components/examples/MultiSelectExample.tsx +0 -57
  238. package/components/examples/SearchableSelectExample.tsx +0 -34
  239. package/components/examples/SelectExample.tsx +0 -28
  240. package/components/examples/StackingModals.tsx +0 -54
  241. package/components/examples/TableExample.tsx +0 -159
  242. package/components/examples/TextareaExample.tsx +0 -23
  243. package/components/examples/TileExample.tsx +0 -25
  244. package/components/examples/date/DateTimePickerExample.tsx +0 -53
  245. package/components/examples/properties/CheckboxPropertyExample.tsx +0 -29
  246. package/components/examples/properties/DatePropertyExample.tsx +0 -44
  247. package/components/examples/properties/MultiSelectPropertyExample.tsx +0 -39
  248. package/components/examples/properties/NumberPropertyExample.tsx +0 -28
  249. package/components/examples/properties/SelectPropertyExample.tsx +0 -39
  250. package/components/examples/properties/TextPropertyExample.tsx +0 -30
  251. package/components/icons/Helpwave.tsx +0 -51
  252. package/components/icons/Tag.tsx +0 -29
  253. package/components/layout/Carousel.tsx +0 -396
  254. package/components/layout/DividerInserter.tsx +0 -37
  255. package/components/layout/FAQSection.tsx +0 -57
  256. package/components/layout/Tile.tsx +0 -67
  257. package/components/modals/ConfirmDialog.tsx +0 -105
  258. package/components/modals/DiscardChangesDialog.tsx +0 -71
  259. package/components/modals/InputModal.tsx +0 -26
  260. package/components/modals/LanguageModal.tsx +0 -76
  261. package/components/modals/Modal.tsx +0 -149
  262. package/components/modals/ModalRegister.tsx +0 -45
  263. package/components/properties/CheckboxProperty.tsx +0 -62
  264. package/components/properties/DateProperty.tsx +0 -58
  265. package/components/properties/MultiSelectProperty.tsx +0 -82
  266. package/components/properties/NumberProperty.tsx +0 -86
  267. package/components/properties/PropertyBase.tsx +0 -84
  268. package/components/properties/SelectProperty.tsx +0 -67
  269. package/components/properties/TextProperty.tsx +0 -81
  270. package/components/user-input/Checkbox.tsx +0 -139
  271. package/components/user-input/DateAndTimePicker.tsx +0 -156
  272. package/components/user-input/Input.tsx +0 -192
  273. package/components/user-input/Label.tsx +0 -32
  274. package/components/user-input/Menu.tsx +0 -75
  275. package/components/user-input/MultiSelect.tsx +0 -158
  276. package/components/user-input/ScrollPicker.tsx +0 -240
  277. package/components/user-input/SearchableSelect.tsx +0 -36
  278. package/components/user-input/Select.tsx +0 -132
  279. package/components/user-input/Textarea.tsx +0 -86
  280. package/components/user-input/ToggleableInput.tsx +0 -115
  281. package/hooks/useHoverState.ts +0 -88
  282. package/hooks/useLanguage.tsx +0 -78
  283. package/hooks/useLocalStorage.tsx +0 -33
  284. package/hooks/useOutsideClick.ts +0 -25
  285. package/hooks/useSaveDelay.ts +0 -46
  286. package/hooks/useTheme.tsx +0 -57
  287. package/hooks/useTranslation.ts +0 -43
  288. package/index.ts +0 -0
  289. package/util/array.ts +0 -115
  290. package/util/date.ts +0 -180
  291. package/util/easeFunctions.ts +0 -37
  292. package/util/emailValidation.ts +0 -3
  293. package/util/loopingArray.ts +0 -94
  294. package/util/math.ts +0 -3
  295. package/util/news.ts +0 -43
  296. package/util/noop.ts +0 -1
  297. package/util/storage.ts +0 -37
  298. package/util/types.ts +0 -4
  299. /package/{components/Span.tsx → dist/components/Span.d.ts} +0 -0
  300. /package/{components/examples/Title.tsx → dist/components/examples/Title.d.ts} +0 -0
@@ -1,130 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react'
2
- import { Scrollbars } from 'react-custom-scrollbars-2'
3
- import { noop } from '../../util/noop'
4
- import { equalSizeGroups, range } from '../../util/array'
5
- import clsx from 'clsx'
6
- import { Expandable } from '../Expandable'
7
- import { addDuration, monthsList, subtractDuration } from '../../util/date'
8
- import { useLocale } from '../../hooks/useLanguage'
9
-
10
- export type YearMonthPickerProps = {
11
- displayedYearMonth?: Date,
12
- start?: Date,
13
- end?: Date,
14
- onChange?: (date: Date) => void,
15
- className?: string,
16
- maxHeight?: number,
17
- showValueOpen?: boolean,
18
- }
19
-
20
- // TODO use a dynamically loading infinite list here
21
- export const YearMonthPicker = ({
22
- displayedYearMonth = new Date(),
23
- start = subtractDuration(new Date(), { years: 50 }),
24
- end = addDuration(new Date(), { years: 50 }),
25
- onChange = noop,
26
- className = '',
27
- maxHeight = 300,
28
- showValueOpen = true
29
- }: YearMonthPickerProps) => {
30
- const locale = useLocale()
31
- const ref = useRef<HTMLDivElement>(null)
32
-
33
- useEffect(() => {
34
- const scrollToItem = () => {
35
- if (ref.current) {
36
- ref.current.scrollIntoView({
37
- behavior: 'instant',
38
- block: 'center',
39
- })
40
- }
41
- }
42
-
43
- scrollToItem()
44
- }, [ref])
45
-
46
- if (end < start) {
47
- console.error(`startYear: (${start}) less than endYear: (${end})`)
48
- return null
49
- }
50
-
51
- const years = range(start.getFullYear(), end.getFullYear())
52
-
53
- return (
54
- <div className={clsx('col select-none', className)}>
55
- <Scrollbars autoHeight autoHeightMax={maxHeight} style={{ height: '100%' }}>
56
- <div className="col gap-y-1 mr-3">
57
- {years.map(year => {
58
- const selectedYear = displayedYearMonth.getFullYear() === year
59
- return (
60
- <Expandable
61
- key={year}
62
- ref={(displayedYearMonth.getFullYear() ?? new Date().getFullYear()) === year ? ref : undefined}
63
- label={<span className={clsx({ 'text-primary font-bold': selectedYear })}>{year}</span>}
64
- initialExpansion={showValueOpen && selectedYear}
65
- >
66
- <div className="col gap-y-1 px-2 pb-2">
67
- {equalSizeGroups([...monthsList], 3).map((monthList, index) => (
68
- <div key={index} className="row">
69
- {monthList.map(month => {
70
- const monthIndex = monthsList.indexOf(month)
71
- const newDate = new Date(year, monthIndex)
72
-
73
- const selectedMonth = selectedYear && monthIndex === displayedYearMonth.getMonth()
74
- const firstOfMonth = new Date(year, monthIndex, 1)
75
- const lastOfMonth = new Date(year, monthIndex, 1)
76
- const isAfterStart = start === undefined || start <= addDuration(subtractDuration(lastOfMonth, { days: 1 }), { months: 1 })
77
- const isBeforeEnd = end === undefined || firstOfMonth <= end
78
- const isValid = isAfterStart && isBeforeEnd
79
- return (
80
- <button
81
- key={month}
82
- disabled={!isValid}
83
- className={clsx(
84
- 'chip hover:brightness-95 flex-1',
85
- {
86
- 'bg-gray-50 text-black': !selectedMonth && isValid,
87
- 'bg-primary text-on-primary': selectedMonth && isValid,
88
- 'bg-disabled-background text-disabled-text': !isValid
89
- }
90
- )}
91
- onClick={() => {
92
- onChange(newDate)
93
- }}
94
- >
95
- {new Intl.DateTimeFormat(locale, { month: 'short' }).format(newDate)}
96
- </button>
97
- )
98
- })}
99
- </div>
100
- ))}
101
- </div>
102
- </Expandable>
103
- )
104
- })}
105
- </div>
106
- </Scrollbars>
107
- </div>
108
- )
109
- }
110
-
111
- export const ControlledYearMonthPicker = ({
112
- displayedYearMonth = new Date(),
113
- onChange = noop,
114
- ...props
115
- }: YearMonthPickerProps) => {
116
- const [yearMonth, setYearMonth] = useState<Date>(displayedYearMonth)
117
-
118
- useEffect(() => setYearMonth(displayedYearMonth), [displayedYearMonth])
119
-
120
- return (
121
- <YearMonthPicker
122
- displayedYearMonth={yearMonth}
123
- onChange={date => {
124
- setYearMonth(date)
125
- onChange(date)
126
- }}
127
- {...props}
128
- />
129
- )
130
- }
@@ -1,58 +0,0 @@
1
- import { useState } from 'react'
2
- import type { InputGroupProps } from '../InputGroup'
3
- import { InputGroup } from '../InputGroup'
4
- import { Select } from '../user-input/Select'
5
- import { Input } from '../user-input/Input'
6
- import { Textarea } from '../user-input/Textarea'
7
-
8
- export type InputGroupExampleProps = Omit<InputGroupProps, 'inputs' | 'onChange'>
9
-
10
- type InputType = {
11
- subject?: string,
12
- propertyName: string,
13
- description: string,
14
- }
15
-
16
- /**
17
- * Example for an Input Group
18
- */
19
- export const InputGroupExample = ({
20
- ...props
21
- }: InputGroupExampleProps) => {
22
- const [state, setState] = useState<InputType>({
23
- propertyName: '',
24
- description: ''
25
- })
26
-
27
- return (
28
- <InputGroup
29
- {...props}
30
- onChange={console.log}
31
- >
32
- <Select
33
- key="item1"
34
- label={{ name: 'Subject Type', labelType: 'labelSmall' }}
35
- value={state.subject}
36
- options={[
37
- { value: 'organization', label: 'Organization' },
38
- { value: 'ward', label: 'Ward' },
39
- { value: 'bed', label: 'Bed' },
40
- { value: 'patient', label: 'Patient' },
41
- ]}
42
- onChange={subject => setState({ ...state, subject })}
43
- />
44
- <Input
45
- key="item2"
46
- label={{ name: 'Property Name' }}
47
- value={state.propertyName}
48
- onChange={propertyName => setState({ ...state, propertyName })}
49
- />
50
- <Textarea
51
- key="item3"
52
- label={{ name: 'Description' }}
53
- value={state.description}
54
- onChange={description => setState({ ...state, description })}
55
- />
56
- </InputGroup>
57
- )
58
- }
@@ -1,57 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import type { MultiSelectProps } from '../user-input/MultiSelect'
3
- import { MultiSelect } from '../user-input/MultiSelect'
4
- import { ChipList } from '../ChipList'
5
-
6
- type MultiSelectExampleProps = Omit<MultiSelectProps<string>, 'search' | 'selectedDisplay'> & {
7
- enableSearch: boolean,
8
- useChipDisplay: boolean,
9
- }
10
-
11
- export const MultiSelectExample = ({
12
- options,
13
- hintText,
14
- enableSearch,
15
- onChange,
16
- useChipDisplay = false,
17
- ...props
18
- }: MultiSelectExampleProps) => {
19
- const [usedOptions, setUsedOptions] = useState(options)
20
-
21
- useEffect(() => {
22
- setUsedOptions(options)
23
- }, [options])
24
-
25
- useEffect(() => {
26
- setUsedOptions(options)
27
- }, [options])
28
-
29
- useEffect(() => {
30
- setUsedOptions(options.map(value => ({ ...value, selected: false })))
31
- }, [hintText, options])
32
-
33
- return (
34
- <MultiSelect
35
- options={usedOptions}
36
- onChange={value => {
37
- onChange(value)
38
- setUsedOptions(value)
39
- }}
40
- hintText={hintText}
41
- search={enableSearch ? { initialSearch: '', searchMapping: value => [value.label] } : undefined}
42
- selectedDisplay={useChipDisplay ?
43
- ({ items }) => {
44
- const selected = items.filter(value => value.selected)
45
- if (selected.length === 0) {
46
- return (<span>Select</span>)
47
- }
48
- return (
49
- <ChipList
50
- list={selected.map(value => ({ children: value.label }))}
51
- />
52
- )
53
- } : undefined}
54
- {...props}
55
- />
56
- )
57
- }
@@ -1,34 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import type { SearchableSelectProps } from '../user-input/SearchableSelect'
3
- import { SearchableSelect } from '../user-input/SearchableSelect'
4
-
5
- export type SearchableSelectExampleProps = Omit<SearchableSelectProps<string>, 'searchMapping'|'additionalItems'>
6
-
7
- /**
8
- * Example for a Searchable select
9
- */
10
- export const SearchableSelectExample = ({
11
- value,
12
- options,
13
- onChange,
14
- ...props
15
- }: SearchableSelectExampleProps) => {
16
- const [selected, setSelected] = useState<string | undefined>(value)
17
-
18
- useEffect(() => {
19
- setSelected(options.find(value1 => value1.value === value)?.value)
20
- }, [options, value])
21
-
22
- return (
23
- <SearchableSelect
24
- {...props}
25
- value={selected}
26
- options={options}
27
- onChange={value => {
28
- setSelected(value)
29
- onChange(value)
30
- }}
31
- searchMapping={value1 => [value1.value]}
32
- />
33
- )
34
- }
@@ -1,28 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { Select, type SelectProps } from '../user-input/Select'
3
-
4
- type SelectExampleProps<T> = Omit<SelectProps<T>, 'onChange' | 'additionalItems' | 'selectedDisplayOverwrite'>
5
-
6
- export const SelectExample = <T, >({ options, value, hintText, ...props }: SelectExampleProps<T>) => {
7
- const [selected, setSelected] = useState(value)
8
-
9
- useEffect(() => {
10
- if (options.find(options => options.value === value)) {
11
- setSelected(value)
12
- }
13
- }, [options, value])
14
-
15
- useEffect(() => {
16
- setSelected(undefined)
17
- }, [hintText])
18
-
19
- return (
20
- <Select
21
- value={selected}
22
- options={options}
23
- onChange={value => setSelected(value)}
24
- hintText={hintText}
25
- {...props}
26
- />
27
- )
28
- }
@@ -1,54 +0,0 @@
1
- import { useState } from 'react'
2
- import { ModalRegister } from '../modals/ModalRegister'
3
- import { ConfirmDialog } from '../modals/ConfirmDialog'
4
- import { SolidButton } from '../Button'
5
- import { modalRootName } from '../modals/Modal'
6
-
7
- /**
8
- * An Example Component for Stacking Modals
9
- */
10
- export const StackingModals = () => {
11
- const [modal1, setModal1] = useState(false)
12
- const [modal2, setModal2] = useState(false)
13
- const [modal3, setModal3] = useState(false)
14
-
15
- return (
16
- <ModalRegister>
17
- <ConfirmDialog
18
- id="1"
19
- isOpen={modal1}
20
- onConfirm={() => setModal1(false)}
21
- onBackgroundClick={() => setModal1(false)}
22
- onCloseClick={() => setModal1(false)}
23
- modalClassName="!bg-yellow-200 min-h-[300px]"
24
- >
25
- {'I\'m Modal 1'}
26
- <SolidButton onClick={() => setModal2(true)}>Open Modal 2</SolidButton>
27
- </ConfirmDialog>
28
- <ConfirmDialog
29
- id="2"
30
- isOpen={modal2}
31
- onConfirm={() => setModal2(false)}
32
- onBackgroundClick={() => setModal2(false)}
33
- onCloseClick={() => setModal2(false)}
34
- modalClassName="!bg-green-200 min-w-[300px]"
35
- >
36
- {'The next layer of Modals!'}
37
- {'This is Modal 2'}
38
- <SolidButton onClick={() => setModal3(true)}>Open Modal 3</SolidButton>
39
- </ConfirmDialog>
40
- <ConfirmDialog
41
- id="3"
42
- isOpen={modal3}
43
- onConfirm={() => setModal3(false)}
44
- onBackgroundClick={() => setModal3(false)}
45
- onCloseClick={() => setModal3(false)}
46
- >
47
- This is Modal 3!
48
- </ConfirmDialog>
49
- <div className="row items-center justify-center min-h-[400px]" id={modalRootName}>
50
- <SolidButton onClick={() => setModal1(true)}>Open Modal 1</SolidButton>
51
- </div>
52
- </ModalRegister>
53
- )
54
- }
@@ -1,159 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import type { TableProps, TableSortingFunctionType, TableSortingType, TableState } from '../Table'
3
- import {
4
- addElementToTable,
5
- defaultTableStatePagination,
6
- defaultTableStateSelection,
7
- removeFromTableSelection,
8
- Table
9
- } from '../Table'
10
- import { Input } from '../user-input/Input'
11
- import { SolidButton, TextButton } from '../Button'
12
- import { SortButton } from '../SortButton'
13
-
14
- export type DataType = {
15
- id: string,
16
- name: string,
17
- age: number,
18
- }
19
-
20
- export const exampleData: DataType[] = [
21
- { id: 'data1', name: 'Name 1', age: 23 },
22
- { id: 'data2', name: 'Name 2', age: 21 },
23
- { id: 'data3', name: 'Name 3', age: 32 },
24
- { id: 'data4', name: 'Name 4', age: 42 },
25
- { id: 'data5', name: 'Name 5', age: 17 },
26
- { id: 'data6', name: 'Name 6', age: 26 },
27
- { id: 'data7', name: 'Name 7', age: 19 },
28
- { id: 'data8', name: 'Name 8', age: 31 }
29
- ]
30
-
31
- type SortingKeys = 'id'|'name'|'age'
32
-
33
- const TableExample = ({ data: initialData }: Pick<TableProps<DataType>, 'data'>) => {
34
- const [data, setData] = useState<DataType[]>(initialData)
35
- const [tableState, setTableState] = useState<TableState>({
36
- pagination: defaultTableStatePagination,
37
- selection: defaultTableStateSelection
38
- })
39
-
40
- useEffect(() => {
41
- setData(initialData)
42
- }, [initialData])
43
-
44
- const [sorting, setSorting] = useState<[SortingKeys, TableSortingType]>()
45
- const [sortingKey, ascending] = sorting ?? ['', 'ascending']
46
- const idMapping = (data: DataType) => data.id
47
-
48
- const sortingFunctions: Record<SortingKeys, Record<TableSortingType, TableSortingFunctionType<DataType>>> = {
49
- id: {
50
- ascending: (t1, t2) => t1.id.localeCompare(t2.id),
51
- descending: (t1, t2) => t1.id.localeCompare(t2.id) * -1,
52
- },
53
- name: {
54
- ascending: (t1, t2) => t1.name.localeCompare(t2.name),
55
- descending: (t1, t2) => t1.name.localeCompare(t2.name) * -1,
56
- },
57
- age: {
58
- ascending: (t1, t2) => t1.age - t2.age,
59
- descending: (t1, t2) => (t1.age - t2.age) * -1,
60
- }
61
- }
62
-
63
- return (
64
- <div className="col gap-y-12 items-center">
65
- <Table
66
- stateManagement={[tableState, (newTableState) => {
67
- setTableState(newTableState)
68
- setData(data)
69
- }]}
70
- data={data}
71
- identifierMapping={idMapping}
72
- rowMappingToCells={dataObject => [
73
- <span key="id" className="textstyle-title-md w-[100px] text-ellipsis overflow-hidden block">{dataObject.id}</span>,
74
- <Input key="name" value={dataObject.name} onChange={text => {
75
- setData(data.map(value => value.id === dataObject.id ? { ...dataObject, name: text } : value))
76
- setSorting(undefined)
77
- }} />,
78
- <Input key="age" type="number" value={dataObject.age.toString()} onChange={text => {
79
- setData(data.map(value => value.id === dataObject.id ? { ...dataObject, age: parseInt(text) } : value))
80
- setSorting(undefined)
81
- }} />,
82
- <TextButton
83
- key="delete"
84
- color="negative"
85
- onClick={() => {
86
- const newData = data.filter(value => value.id !== dataObject.id)
87
- setData(newData)
88
- setTableState(removeFromTableSelection(tableState, [dataObject], data.length, idMapping))
89
- }}
90
- >Delete</TextButton>
91
- ]}
92
- header={[
93
- <SortButton
94
- key="headerId"
95
- ascending={sortingKey === 'id' ? ascending : undefined}
96
- onClick={newTableSorting => {
97
- setSorting(['id', newTableSorting])
98
- setData(data.sort(sortingFunctions.id[newTableSorting]))
99
- }}
100
- >
101
- <span className="textstyle-table-header">Id</span>
102
- </SortButton>,
103
- <SortButton
104
- key="name"
105
- ascending={sortingKey === 'name' ? ascending : undefined}
106
- onClick={newTableSorting => {
107
- setSorting(['name', newTableSorting])
108
- setData(data.sort(sortingFunctions.name[newTableSorting]))
109
- }}
110
- >
111
- <span className="textstyle-table-header">Name</span>
112
- </SortButton>,
113
- <SortButton
114
- key="name"
115
- ascending={sortingKey === 'age' ? ascending : undefined}
116
- onClick={newTableSorting => {
117
- setSorting(['age', newTableSorting])
118
- setData(data.sort(sortingFunctions.age[newTableSorting]))
119
- }}
120
- >
121
- <span key="age" className="textstyle-table-header">age</span>
122
- </SortButton>,
123
- <></>
124
- ]}
125
- />
126
- <div className="row gap-x-2">
127
- <SolidButton
128
- className="w-auto"
129
- onClick={() => {
130
- const newData = {
131
- id: Math.random().toString(),
132
- name: 'Name ' + data.length,
133
- age: Math.ceil(Math.random() * 100)
134
- }
135
- const withNewData = [...data, newData]
136
- const sorted = sortingKey ? withNewData.sort(sortingFunctions[sortingKey][ascending]) : withNewData
137
- setData(sorted)
138
- setTableState(addElementToTable(tableState, sorted, newData, idMapping))
139
- }}
140
- >
141
- {'Add Data'}
142
- </SolidButton>
143
- <TextButton
144
- className="w-auto"
145
- onClick={() => {
146
- const selectedData = data.filter((d) => tableState.selection?.currentSelection.includes(idMapping(d)))
147
- const unselectedData = data.filter((d) => !tableState.selection?.currentSelection.includes(idMapping(d)))
148
- setData(unselectedData)
149
- setTableState(removeFromTableSelection(tableState, selectedData, data.length, idMapping))
150
- }}
151
- >
152
- {'Remove all selected'}
153
- </TextButton>
154
- </div>
155
- </div>
156
- )
157
- }
158
-
159
- export default TableExample
@@ -1,23 +0,0 @@
1
- import { useState } from 'react'
2
- import type { TextareaProps } from '../user-input/Textarea'
3
- import { Textarea } from '../user-input/Textarea'
4
-
5
- export type TextareaExampleProps = Omit<TextareaProps, 'onChange'|'onEditCompleted'>
6
-
7
- /**
8
- * Example for the Textarea component
9
- */
10
- export const TextareaExample = ({
11
- value,
12
- ...props
13
- }: TextareaExampleProps) => {
14
- const [text, setText] = useState<string>(value as string)
15
- return (
16
- <Textarea
17
- {...props}
18
- value={text}
19
- onChange={setText}
20
- onEditCompleted={setText}
21
- />
22
- )
23
- }
@@ -1,25 +0,0 @@
1
- import { Info, X } from 'lucide-react'
2
- import type { TileProps } from '../layout/Tile'
3
- import { Tile } from '../layout/Tile'
4
-
5
- export type TileExampleProps = Omit<TileProps, 'prefix' | 'suffix'> & {
6
- prefix: boolean,
7
- suffix: boolean,
8
- }
9
-
10
- /**
11
- * An Example for using the tile
12
- */
13
- export const TileExample = ({
14
- prefix,
15
- suffix,
16
- ...restProps
17
- }: TileExampleProps) => {
18
- return (
19
- <Tile
20
- {...restProps}
21
- prefix={prefix ? <Info size={20}/> : undefined}
22
- suffix={suffix ? <X size={20}/> : undefined}
23
- />
24
- )
25
- }
@@ -1,53 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import type { DateTimePickerProps } from '../../user-input/DateAndTimePicker'
3
- import { DateTimePicker } from '../../user-input/DateAndTimePicker'
4
- import { noop } from '../../../util/noop'
5
- import type { DatePickerProps } from '../../date/DatePicker'
6
- import type { TimePickerProps } from '../../date/TimePicker'
7
- import type { YearMonthPickerProps } from '../../date/YearMonthPicker'
8
- import type { DayPickerProps } from '../../date/DayPicker'
9
-
10
- export type DateTimePickerExampleProps = Omit<DateTimePickerProps, 'datePickerProps' | 'timePickerProps'> &
11
- Pick<DatePickerProps, 'initialDisplay'> & Pick<TimePickerProps, 'is24HourFormat' | 'minuteIncrement'> &
12
- Pick<YearMonthPickerProps, 'showValueOpen'> & Pick<DayPickerProps, 'markToday' | 'weekStart'>
13
-
14
- /**
15
- * Example for the DateTimePicker
16
- */
17
- export const DateTimePickerExample = ({
18
- value,
19
- onChange = noop,
20
- onRemove = noop,
21
- onFinish = noop,
22
- initialDisplay,
23
- is24HourFormat,
24
- minuteIncrement,
25
- showValueOpen,
26
- markToday,
27
- weekStart,
28
- ...props
29
- }: DateTimePickerExampleProps) => {
30
- const [time, setTime] = useState(value)
31
-
32
- useEffect(() => setTime(value), [value])
33
- return (
34
- <DateTimePicker
35
- {...props}
36
- value={time}
37
- onChange={date => {
38
- onChange(date)
39
- setTime(date)
40
- }}
41
- onRemove={() => {
42
- onRemove()
43
- setTime(new Date())
44
- }}
45
- onFinish={date => {
46
- onFinish(date)
47
- setTime(date)
48
- }}
49
- timePickerProps={{ is24HourFormat, minuteIncrement }}
50
- datePickerProps={{ initialDisplay, dayPickerProps: { markToday, weekStart }, yearMonthPickerProps: { showValueOpen } }}
51
- />
52
- )
53
- }
@@ -1,29 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import type { CheckboxPropertyProps } from '../../properties/CheckboxProperty'
3
- import { CheckboxProperty } from '../../properties/CheckboxProperty'
4
-
5
- export type CheckboxPropertyExampleProps = Omit<CheckboxPropertyProps, 'onChange' | 'onRemove'> & {
6
- readOnly: boolean,
7
- }
8
-
9
- /**
10
- * Example for using the CheckboxProperty
11
- */
12
- export const CheckboxPropertyExample = ({
13
- value = false,
14
- ...restProps
15
- }: CheckboxPropertyExampleProps) => {
16
- const [usedValue, setUsedValue] = useState<boolean>(value)
17
-
18
- useEffect(() => {
19
- setUsedValue(value)
20
- }, [value])
21
-
22
- return (
23
- <CheckboxProperty
24
- {...restProps}
25
- onChange={setUsedValue}
26
- value={usedValue}
27
- />
28
- )
29
- }