@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,58 +0,0 @@
1
- import { CalendarDays } from 'lucide-react'
2
- import clsx from 'clsx'
3
- import { formatDate, formatDateTime } from '../../util/date'
4
- import { noop } from '../../util/noop'
5
- import { Input } from '../user-input/Input'
6
- import type { PropertyBaseProps } from './PropertyBase'
7
- import { PropertyBase } from './PropertyBase'
8
-
9
- export type DatePropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
10
- value?: Date,
11
- onChange?: (date: Date) => void,
12
- onEditComplete?: (value: Date) => void,
13
- type?: 'dateTime' | 'date',
14
- }
15
-
16
- /**
17
- * An Input for date properties
18
- */
19
- export const DateProperty = ({
20
- value,
21
- onChange = noop,
22
- onEditComplete = noop,
23
- readOnly,
24
- type = 'dateTime',
25
- ...baseProps
26
- }: DatePropertyProps) => {
27
- const hasValue = !!value
28
-
29
- const dateText = value ? (type === 'dateTime' ? formatDateTime(value) : formatDate(value)) : ''
30
- return (
31
- <PropertyBase
32
- {...baseProps}
33
- hasValue={hasValue}
34
- icon={<CalendarDays size={16}/>}
35
- input={({ softRequired }) => (
36
- <div
37
- className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}
38
- >
39
- <Input
40
- className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !w-fit !rounded-none', { 'bg-surface-warning': softRequired && !hasValue })}
41
- value={dateText}
42
- type={type === 'dateTime' ? 'datetime-local' : 'date'}
43
- readOnly={readOnly}
44
- onChange={(value, event) => {
45
- if (!event.target.value) {
46
- event.preventDefault()
47
- return
48
- }
49
- const dueDate = new Date(value)
50
- onChange(dueDate)
51
- }}
52
- onEditCompleted={(value) => onEditComplete(new Date(value))}
53
- />
54
- </div>
55
- )}
56
- />
57
- )
58
- }
@@ -1,82 +0,0 @@
1
- import { List } from 'lucide-react'
2
- import clsx from 'clsx'
3
- import type { Languages } from '../../hooks/useLanguage'
4
- import type { PropsForTranslation } from '../../hooks/useTranslation'
5
- import { useTranslation } from '../../hooks/useTranslation'
6
- import type { MultiSelectProps } from '../user-input/MultiSelect'
7
- import { MultiSelect } from '../user-input/MultiSelect'
8
- import { ChipList } from '../ChipList'
9
- import type { PropertyBaseProps } from './PropertyBase'
10
- import { PropertyBase } from './PropertyBase'
11
-
12
- type MultiSelectPropertyTranslation = {
13
- select: string,
14
- }
15
-
16
- const defaultMultiSelectPropertyTranslation: Record<Languages, MultiSelectPropertyTranslation> = {
17
- en: {
18
- select: 'Select'
19
- },
20
- de: {
21
- select: 'Auswählen'
22
- }
23
- }
24
-
25
- export type MultiSelectPropertyProps<T> =
26
- Omit<PropertyBaseProps & MultiSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'triggerClassName'>
27
-
28
- /**
29
- * An Input for MultiSelect properties
30
- */
31
- export const MultiSelectProperty = <T, >({
32
- overwriteTranslation,
33
- options,
34
- name,
35
- readOnly = false,
36
- softRequired,
37
- onRemove,
38
- ...multiSelectProps
39
- }: PropsForTranslation<MultiSelectPropertyTranslation, MultiSelectPropertyProps<T>>) => {
40
- const translation = useTranslation(defaultMultiSelectPropertyTranslation, overwriteTranslation)
41
- const hasValue = options.some(value => value.selected)
42
- let triggerClassName: string
43
- if (softRequired && !hasValue) {
44
- triggerClassName = 'border-warning hover:brightness-90'
45
- }
46
-
47
- return (
48
- <PropertyBase
49
- name={name}
50
- onRemove={onRemove}
51
- readOnly={readOnly}
52
- softRequired={softRequired}
53
- hasValue={hasValue}
54
- icon={<List size={16}/>}
55
- input={({ softRequired }) => (
56
- <div
57
- className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}
58
- >
59
- <MultiSelect
60
- {...multiSelectProps}
61
- className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}
62
- triggerClassName={triggerClassName}
63
- selectedDisplay={({ items }) => {
64
- const selected = items.filter(value => value.selected)
65
- if (selected.length === 0) {
66
- return (<span>Select</span>)
67
- }
68
- return (
69
- <ChipList
70
- list={selected.map(value => ({ children: value.label }))}
71
- />
72
- )
73
- }}
74
- options={options}
75
- disabled={readOnly}
76
- hintText={`${translation.select}...`}
77
- />
78
- </div>
79
- )}
80
- />
81
- )
82
- }
@@ -1,86 +0,0 @@
1
- import { Binary } from 'lucide-react'
2
- import clsx from 'clsx'
3
- import { noop } from '../../util/noop'
4
- import { Input } from '../user-input/Input'
5
- import type { Languages } from '../../hooks/useLanguage'
6
- import type { PropsForTranslation } from '../../hooks/useTranslation'
7
- import { useTranslation } from '../../hooks/useTranslation'
8
- import type { PropertyBaseProps } from './PropertyBase'
9
- import { PropertyBase } from './PropertyBase'
10
-
11
- type NumberPropertyTranslation = {
12
- value: string,
13
- }
14
-
15
- const defaultNumberPropertyTranslation: Record<Languages, NumberPropertyTranslation> = {
16
- en: {
17
- value: 'Value'
18
- },
19
- de: {
20
- value: 'Wert'
21
- }
22
- }
23
-
24
- export type NumberPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
25
- value?: number,
26
- suffix?: string,
27
- onChange?: (value: number) => void,
28
- onEditComplete?: (value: number) => void,
29
- }
30
-
31
- /**
32
- * An Input for number properties
33
- */
34
- export const NumberProperty = ({
35
- overwriteTranslation,
36
- value,
37
- onChange = noop,
38
- onRemove = noop,
39
- onEditComplete = noop,
40
- readOnly,
41
- suffix,
42
- ...baseProps
43
- }: PropsForTranslation<NumberPropertyTranslation, NumberPropertyProps>) => {
44
- const translation = useTranslation(defaultNumberPropertyTranslation, overwriteTranslation)
45
- const hasValue = value !== undefined
46
-
47
- return (
48
- <PropertyBase
49
- {...baseProps}
50
- onRemove={onRemove}
51
- hasValue={hasValue}
52
- icon={<Binary size={16}/>}
53
- input={({ softRequired }) => (
54
- <div
55
- className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}
56
- >
57
- <Input
58
- expanded={false}
59
- className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !w-fit !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}
60
- value={value?.toString() ?? ''}
61
- type="number"
62
- readOnly={readOnly}
63
- placeholder={`${translation.value}...`}
64
- onChange={(value) => {
65
- const numberValue = parseFloat(value)
66
- if (isNaN(numberValue)) {
67
- onRemove()
68
- } else {
69
- onChange(numberValue)
70
- }
71
- }}
72
- onEditCompleted={(value) => {
73
- const numberValue = parseFloat(value)
74
- if (isNaN(numberValue)) {
75
- onRemove()
76
- } else {
77
- onEditComplete(numberValue)
78
- }
79
- }}
80
- />
81
- {suffix && <span className={clsx('ml-1', { 'bg-surface-warning': softRequired && !hasValue })}>{suffix}</span>}
82
- </div>
83
- )}
84
- />
85
- )
86
- }
@@ -1,84 +0,0 @@
1
- import type { ReactNode } from 'react'
2
- import { AlertTriangle } from 'lucide-react'
3
- import clsx from 'clsx'
4
- import type { Languages } from '../../hooks/useLanguage'
5
- import { TextButton } from '../Button'
6
- import type { PropsForTranslation } from '../../hooks/useTranslation'
7
- import { useTranslation } from '../../hooks/useTranslation'
8
-
9
- type PropertyBaseTranslation = {
10
- remove: string,
11
- }
12
-
13
- const defaultPropertyBaseTranslation: Record<Languages, PropertyBaseTranslation> = {
14
- en: {
15
- remove: 'Remove'
16
- },
17
- de: {
18
- remove: 'Entfernen'
19
- }
20
- }
21
-
22
- export type PropertyBaseProps = {
23
- name: string,
24
- input: (props: { softRequired: boolean, hasValue: boolean }) => ReactNode,
25
- onRemove?: () => void,
26
- hasValue: boolean,
27
- softRequired?: boolean,
28
- readOnly?: boolean,
29
- icon?: ReactNode,
30
- className?: string,
31
- }
32
-
33
- /**
34
- * A component for showing a properties with uniform styling
35
- */
36
- export const PropertyBase = ({
37
- overwriteTranslation,
38
- name,
39
- input,
40
- softRequired = false,
41
- hasValue,
42
- icon,
43
- readOnly,
44
- onRemove,
45
- className = '',
46
- }: PropsForTranslation<PropertyBaseTranslation, PropertyBaseProps>) => {
47
- const translation = useTranslation(defaultPropertyBaseTranslation, overwriteTranslation)
48
- const requiredAndNoValue = softRequired && !hasValue
49
- return (
50
- <div className={clsx('row gap-x-0 group', className)}>
51
- <div
52
- className={
53
- clsx('row gap-x-2 !w-[200px] px-4 py-2 items-center rounded-l-xl border-2 border-r-0', {
54
- 'bg-gray-100 text-black group-hover:border-primary border-gray-400': !requiredAndNoValue,
55
- 'bg-warning text-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,
56
- }, className)}
57
- >
58
- {icon}
59
- {name}
60
- </div>
61
- <div className={
62
- clsx('row grow justify-between items-center rounded-r-xl border-2 border-l-0', {
63
- 'bg-white group-hover:border-primary border-gray-400': !requiredAndNoValue,
64
- 'bg-surface-warning group-hover:border-warning border-warning/90': requiredAndNoValue,
65
- }, className)}
66
- >
67
- {input({ softRequired, hasValue })}
68
- {requiredAndNoValue && (
69
- <div className="text-warning pr-4"><AlertTriangle size={24}/></div>
70
- )}
71
- {onRemove && (
72
- <TextButton
73
- onClick={onRemove}
74
- color="negative"
75
- className={clsx('pr-4 items-center', { '!text-transparent': !hasValue || readOnly })}
76
- disabled={!hasValue || readOnly}
77
- >
78
- {translation.remove}
79
- </TextButton>
80
- )}
81
- </div>
82
- </div>
83
- )
84
- }
@@ -1,67 +0,0 @@
1
- import { List } from 'lucide-react'
2
- import clsx from 'clsx'
3
- import type { Languages } from '../../hooks/useLanguage'
4
- import type { PropsForTranslation } from '../../hooks/useTranslation'
5
- import { useTranslation } from '../../hooks/useTranslation'
6
- import type { SearchableSelectProps } from '../user-input/SearchableSelect'
7
- import { SearchableSelect } from '../user-input/SearchableSelect'
8
- import type { PropertyBaseProps } from './PropertyBase'
9
- import { PropertyBase } from './PropertyBase'
10
-
11
- type SingleSelectPropertyTranslation = {
12
- select: string,
13
- }
14
-
15
- const defaultSingleSelectPropertyTranslation: Record<Languages, SingleSelectPropertyTranslation> = {
16
- en: {
17
- select: 'Select'
18
- },
19
- de: {
20
- select: 'Auswählen'
21
- }
22
- }
23
-
24
- export type SingleSelectPropertyProps<T> =
25
- Omit<PropertyBaseProps & SearchableSelectProps<T>, 'icon' | 'input' | 'hasValue' | 'className' | 'disabled' | 'label' | 'labelClassName' | 'additionalItems'>
26
-
27
- /**
28
- * An Input for SingleSelect properties
29
- */
30
- export const SingleSelectProperty = <T, >({
31
- overwriteTranslation,
32
- value,
33
- options,
34
- name,
35
- readOnly = false,
36
- softRequired,
37
- onRemove,
38
- ...multiSelectProps
39
- }: PropsForTranslation<SingleSelectPropertyTranslation, SingleSelectPropertyProps<T>>) => {
40
- const translation = useTranslation(defaultSingleSelectPropertyTranslation, overwriteTranslation)
41
- const hasValue = value !== undefined
42
-
43
- return (
44
- <PropertyBase
45
- name={name}
46
- onRemove={onRemove}
47
- readOnly={readOnly}
48
- softRequired={softRequired}
49
- hasValue={hasValue}
50
- icon={<List size={16}/>}
51
- input={({ softRequired }) => (
52
- <div
53
- className={clsx('row grow py-2 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}
54
- >
55
- <SearchableSelect
56
- {...multiSelectProps}
57
- value={value}
58
- options={options}
59
- isDisabled={readOnly}
60
- className={clsx('w-full', { 'bg-surface-warning': softRequired && !hasValue })}
61
- hintText={`${translation.select}...`}
62
- />
63
- </div>
64
- )}
65
- />
66
- )
67
- }
@@ -1,81 +0,0 @@
1
- import { Text } from 'lucide-react'
2
- import clsx from 'clsx'
3
- import type { Languages } from '../../hooks/useLanguage'
4
- import type { PropsForTranslation } from '../../hooks/useTranslation'
5
- import { useTranslation } from '../../hooks/useTranslation'
6
- import { Textarea } from '../user-input/Textarea'
7
- import { noop } from '../../util/noop'
8
- import type { PropertyBaseProps } from './PropertyBase'
9
- import { PropertyBase } from './PropertyBase'
10
-
11
- type TextPropertyTranslation = {
12
- value: string,
13
- }
14
-
15
- const defaultTextPropertyTranslation: Record<Languages, TextPropertyTranslation> = {
16
- en: {
17
- value: 'Text'
18
- },
19
- de: {
20
- value: 'Text'
21
- }
22
- }
23
-
24
- export type TextPropertyProps = Omit<PropertyBaseProps, 'icon' | 'input' | 'hasValue'> & {
25
- value?: string,
26
- onChange?: (value: string) => void,
27
- onEditComplete?: (value: string) => void,
28
- }
29
-
30
- /**
31
- * An Input for Text properties
32
- */
33
- export const TextProperty = ({
34
- overwriteTranslation,
35
- value,
36
- readOnly,
37
- onChange = noop,
38
- onRemove = noop,
39
- onEditComplete = noop,
40
- ...baseProps
41
- }: PropsForTranslation<TextPropertyTranslation, TextPropertyProps>) => {
42
- const translation = useTranslation(defaultTextPropertyTranslation, overwriteTranslation)
43
- const hasValue = value !== undefined
44
-
45
- return (
46
- <PropertyBase
47
- {...baseProps}
48
- onRemove={onRemove}
49
- hasValue={hasValue}
50
- icon={<Text size={16} />}
51
- input={({ softRequired }) => (
52
- <div
53
- className={clsx('row grow pt-2 pb-1 px-4 cursor-pointer', { 'text-warning': softRequired && !hasValue })}
54
- >
55
- <Textarea
56
- className={clsx('!ring-0 !border-0 !outline-0 !p-0 !m-0 !shadow-none !rounded-none', { 'bg-surface-warning placeholder-warning': softRequired && !hasValue })}
57
- rows={5}
58
- defaultStyle={false}
59
- value={value ?? ''}
60
- readOnly={readOnly}
61
- placeholder={`${translation.value}...`}
62
- onChange={(value) => {
63
- if (!value) {
64
- onRemove()
65
- } else {
66
- onChange(value)
67
- }
68
- }}
69
- onEditCompleted={(value) => {
70
- if (!value) {
71
- onRemove()
72
- } else {
73
- onEditComplete(value)
74
- }
75
- }}
76
- />
77
- </div>
78
- )}
79
- />
80
- )
81
- }
@@ -1,139 +0,0 @@
1
- import { useState } from 'react'
2
- import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
3
- import type { CheckedState } from '@radix-ui/react-checkbox'
4
- import { Check, Minus } from 'lucide-react'
5
- import clsx from 'clsx'
6
- import type { LabelProps } from './Label'
7
- import { Label } from './Label'
8
-
9
- type CheckBoxSize = 'small' | 'medium' | 'large'
10
-
11
- const checkboxSizeMapping: Record<CheckBoxSize, string> = {
12
- small: 'size-4',
13
- medium: 'size-6',
14
- large: 'size-8',
15
- }
16
-
17
- const checkboxIconSizeMapping: Record<CheckBoxSize, string> = {
18
- small: 'size-3',
19
- medium: 'size-5',
20
- large: 'size-7',
21
- }
22
-
23
- type CheckboxProps = {
24
- /** used for the label's `for` attribute */
25
- id?: string,
26
- label?: Omit<LabelProps, 'id'>,
27
- /**
28
- * @default false
29
- */
30
- checked: CheckedState,
31
- disabled?: boolean,
32
- onChange?: (checked: boolean) => void,
33
- onChangeTristate?: (checked: CheckedState) => void,
34
- size?: CheckBoxSize,
35
- className?: string,
36
- containerClassName?: string,
37
- }
38
-
39
- /**
40
- * A Tristate checkbox
41
- *
42
- * The state is managed by the parent
43
- */
44
- const ControlledCheckbox = ({
45
- id,
46
- label,
47
- checked,
48
- disabled,
49
- onChange,
50
- onChangeTristate,
51
- size = 'medium',
52
- className = '',
53
- containerClassName
54
- }: CheckboxProps) => {
55
- const usedSizeClass = checkboxSizeMapping[size]
56
- const innerIconSize = checkboxIconSizeMapping[size]
57
-
58
- const propagateChange = (checked: CheckedState) => {
59
- if (onChangeTristate) {
60
- onChangeTristate(checked)
61
- }
62
- if (onChange) {
63
- onChange(checked === 'indeterminate' ? false : checked)
64
- }
65
- }
66
-
67
- const changeValue = () => {
68
- const newValue = checked === 'indeterminate' ? false : !checked
69
- propagateChange(newValue)
70
- }
71
-
72
- return (
73
- <div className={clsx('row justify-center items-center', containerClassName)}>
74
- <CheckboxPrimitive.Root
75
- onCheckedChange={propagateChange}
76
- checked={checked}
77
- disabled={disabled}
78
- id={id}
79
- className={clsx(usedSizeClass, `items-center border-2 rounded outline-none focus:border-primary`, {
80
- 'text-disabled-text border-disabled-text': disabled,
81
- 'border-on-background': !disabled,
82
- 'bg-primary/30 border-primary text-primary': checked === true || checked === 'indeterminate',
83
- 'hover:border-gray-400 focus:hover:border-primary': !checked
84
- }, className)}
85
- >
86
- <CheckboxPrimitive.Indicator>
87
- {checked === true && <Check className={innerIconSize}/>}
88
- {checked === 'indeterminate' && <Minus className={innerIconSize}/>}
89
- </CheckboxPrimitive.Indicator>
90
- </CheckboxPrimitive.Root>
91
- {label &&
92
- <Label {...label} className={clsx('cursor-pointer', label.className)} htmlFor={id} onClick={changeValue}/>}
93
- </div>
94
- )
95
- }
96
-
97
- type UncontrolledCheckboxProps = Omit<CheckboxProps, 'value' | 'checked'> & {
98
- /**
99
- * @default false
100
- */
101
- defaultValue?: CheckedState,
102
- }
103
-
104
- /**
105
- * A Tristate checkbox
106
- *
107
- * The state is managed by this component
108
- */
109
- const UncontrolledCheckbox = ({
110
- onChange,
111
- onChangeTristate,
112
- defaultValue = false,
113
- ...props
114
- }: UncontrolledCheckboxProps) => {
115
- const [checked, setChecked] = useState(defaultValue)
116
-
117
- const handleChange = (checked: CheckedState) => {
118
- if (onChangeTristate) {
119
- onChangeTristate(checked)
120
- }
121
- if (onChange) {
122
- onChange(checked === 'indeterminate' ? false : checked)
123
- }
124
- setChecked(checked)
125
- }
126
-
127
- return (
128
- <ControlledCheckbox
129
- {...props}
130
- checked={checked}
131
- onChangeTristate={handleChange}
132
- />
133
- )
134
- }
135
-
136
- export {
137
- UncontrolledCheckbox,
138
- ControlledCheckbox as Checkbox
139
- }