@fibery/ui-kit 1.36.2 → 1.38.0

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 (296) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.json +8 -5
  3. package/src/action-badge.tsx +5 -4
  4. package/src/actions-menu/actions-menu-confirmation.tsx +1 -12
  5. package/src/actions-menu/actions-menu-item.tsx +19 -7
  6. package/src/actions-menu/actions-menu-props.tsx +4 -0
  7. package/src/actions-menu/actions-menu-sub-command-menu.tsx +7 -4
  8. package/src/actions-menu/actions-menu-sub-menu.tsx +9 -3
  9. package/src/actions-menu/actions-menu.tsx +24 -8
  10. package/src/actions-panel.tsx +12 -2
  11. package/src/antd/ant-modal.tsx +17 -2
  12. package/src/antd/input.tsx +4 -3
  13. package/src/app-icon-with-fallback.tsx +5 -8
  14. package/src/app-icon-wrapper.tsx +4 -4
  15. package/src/appIcons.json +20 -0
  16. package/src/axis-header.tsx +136 -76
  17. package/src/badge.tsx +14 -7
  18. package/src/beta-badge.tsx +12 -8
  19. package/src/box.tsx +1 -1
  20. package/src/breadcrumb.tsx +78 -0
  21. package/src/button/actions-button-compact.tsx +5 -2
  22. package/src/button/base-button.tsx +7 -4
  23. package/src/button/button-group.tsx +1 -1
  24. package/src/button/button.tsx +120 -2
  25. package/src/button/icon-button.tsx +13 -2
  26. package/src/button/select-button.tsx +27 -8
  27. package/src/card-container.tsx +36 -69
  28. package/src/card-hidden-link.tsx +52 -0
  29. package/src/collapsible-section.tsx +13 -3
  30. package/src/color-picker/index.js +65 -60
  31. package/src/color-picker/swatch.tsx +29 -14
  32. package/src/command-menu/index.tsx +5 -5
  33. package/src/context-menu/index.tsx +10 -1
  34. package/src/count-badge.tsx +57 -0
  35. package/src/date-picker/date-range-input.tsx +1 -1
  36. package/src/date-picker/date-range-picker.tsx +6 -3
  37. package/src/date-picker/fake-date-input.tsx +1 -1
  38. package/src/date-picker/relative-date-picker.tsx +7 -3
  39. package/src/date-picker/single-date-input.tsx +1 -1
  40. package/src/date-picker/single-date-picker.tsx +8 -5
  41. package/src/date-picker/styles.ts +32 -26
  42. package/src/date-picker/types.ts +3 -1
  43. package/src/date-picker/utils.ts +9 -2
  44. package/src/day-select/day-select.tsx +21 -75
  45. package/src/day-select/iso-week-day-select.tsx +1 -1
  46. package/src/day-select/mount-day-select.tsx +2 -2
  47. package/src/day-select/week-day-select.tsx +1 -5
  48. package/src/design-system.ts +91 -51
  49. package/src/dropdown-menu/index.tsx +8 -1
  50. package/src/emoji-picker/app-icon-picker.tsx +6 -4
  51. package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -9
  52. package/src/emoji-picker/emoji-picker-preview-footer.tsx +1 -1
  53. package/src/emoji-picker/emoji-picker.tsx +3 -0
  54. package/src/emoji-picker/emoji.tsx +2 -1
  55. package/src/emoji-picker/icon-emoji-picker.tsx +83 -68
  56. package/src/emoji-picker/primitives/footer.tsx +0 -1
  57. package/src/emoji-picker/primitives/header.tsx +1 -0
  58. package/src/emoji-picker/primitives/search.tsx +12 -13
  59. package/src/emoji-picker/primitives/skin-tone.tsx +1 -0
  60. package/src/emoji-picker/use-responsive-emoji-size.ts +11 -0
  61. package/src/emoji-picker/utils/emoji-set.ts +2 -1
  62. package/src/empty-state/empty-state.tsx +6 -0
  63. package/src/error-alert/error-alert.tsx +19 -7
  64. package/src/field-app-icon.tsx +29 -0
  65. package/src/field-container.tsx +4 -2
  66. package/src/field-icon.tsx +29 -0
  67. package/src/field-type-icon.tsx +82 -0
  68. package/src/file-item.tsx +164 -47
  69. package/src/guide-link.tsx +4 -3
  70. package/src/hint.tsx +10 -1
  71. package/src/html-styles.ts +23 -13
  72. package/src/icons/ast/ActivityFilled.ts +8 -0
  73. package/src/icons/ast/AiAssistantFilled.ts +8 -0
  74. package/src/icons/ast/AiFiberyBuild.ts +8 -0
  75. package/src/icons/ast/Anthropic.ts +1 -1
  76. package/src/icons/ast/Apple.ts +8 -0
  77. package/src/icons/ast/ArrowBottom.ts +1 -1
  78. package/src/icons/ast/ArrowForward.ts +1 -1
  79. package/src/icons/ast/ArrowLeft.ts +1 -1
  80. package/src/icons/ast/ArrowRight.ts +1 -1
  81. package/src/icons/ast/ArrowTop.ts +1 -1
  82. package/src/icons/ast/CollapseAllHorizontal.ts +8 -0
  83. package/src/icons/ast/Crosshair.ts +8 -0
  84. package/src/icons/ast/DateRange.ts +1 -1
  85. package/src/icons/ast/Document.ts +8 -0
  86. package/src/icons/ast/EntityCreate.ts +8 -0
  87. package/src/icons/ast/EntityCreateFilled.ts +8 -0
  88. package/src/icons/ast/ExpandAll.ts +8 -0
  89. package/src/icons/ast/ExpandAllHorizontal.ts +8 -0
  90. package/src/icons/ast/FiberyDesktopApp.ts +8 -0
  91. package/src/icons/ast/FileDownload.ts +8 -0
  92. package/src/icons/ast/GlobeUnpublish.ts +8 -0
  93. package/src/icons/ast/GraduationCapFilled.ts +8 -0
  94. package/src/icons/ast/Home.ts +1 -1
  95. package/src/icons/ast/HomeFilled.ts +8 -0
  96. package/src/icons/ast/ImportFilled.ts +8 -0
  97. package/src/icons/ast/IntegrationsFilled.ts +8 -0
  98. package/src/icons/ast/KeyboardHideDown.ts +8 -0
  99. package/src/icons/ast/LayoutMultiple.ts +8 -0
  100. package/src/icons/ast/LocationEdit.ts +8 -0
  101. package/src/icons/ast/MessagePlus.ts +8 -0
  102. package/src/icons/ast/OpenAi.ts +1 -1
  103. package/src/icons/ast/RicheditorHistoryRedo.ts +1 -1
  104. package/src/icons/ast/RicheditorHistoryUndo.ts +1 -1
  105. package/src/icons/ast/RicheditorMarkHighlight.ts +8 -0
  106. package/src/icons/ast/RicheditorMarkStrike.ts +1 -1
  107. package/src/icons/ast/RicheditorMarkUnderline.ts +1 -1
  108. package/src/icons/ast/SearchFilled.ts +8 -0
  109. package/src/icons/ast/SettingsFilled.ts +8 -0
  110. package/src/icons/ast/SlideMenuFilled.ts +8 -0
  111. package/src/icons/ast/SpaceApp.ts +8 -0
  112. package/src/icons/ast/SpaceGenerate.ts +8 -0
  113. package/src/icons/ast/SpaceScratch.ts +8 -0
  114. package/src/icons/ast/SpaceTemplate.ts +8 -0
  115. package/src/icons/ast/TableLayout.ts +8 -0
  116. package/src/icons/ast/TemplatesFilled.ts +8 -0
  117. package/src/icons/ast/ThumbsDown.ts +8 -0
  118. package/src/icons/ast/ThumbsUp.ts +8 -0
  119. package/src/icons/ast/TypeDate.ts +1 -1
  120. package/src/icons/ast/ViewDashboard.ts +8 -0
  121. package/src/icons/ast/WarningTriangleFilled.ts +8 -0
  122. package/src/icons/ast/Windows.ts +8 -0
  123. package/src/icons/ast/index.tsx +37 -0
  124. package/src/icons/react/ActivityFilled.tsx +13 -0
  125. package/src/icons/react/AiAssistantFilled.tsx +13 -0
  126. package/src/icons/react/AiFiberyBuild.tsx +13 -0
  127. package/src/icons/react/Apple.tsx +13 -0
  128. package/src/icons/react/CollapseAllHorizontal.tsx +13 -0
  129. package/src/icons/react/Crosshair.tsx +13 -0
  130. package/src/icons/react/Document.tsx +13 -0
  131. package/src/icons/react/EntityCreate.tsx +13 -0
  132. package/src/icons/react/EntityCreateFilled.tsx +13 -0
  133. package/src/icons/react/ExpandAll.tsx +13 -0
  134. package/src/icons/react/ExpandAllHorizontal.tsx +13 -0
  135. package/src/icons/react/FiberyDesktopApp.tsx +13 -0
  136. package/src/icons/react/FileDownload.tsx +13 -0
  137. package/src/icons/react/GlobeUnpublish.tsx +13 -0
  138. package/src/icons/react/GraduationCapFilled.tsx +13 -0
  139. package/src/icons/react/HomeFilled.tsx +13 -0
  140. package/src/icons/react/ImportFilled.tsx +13 -0
  141. package/src/icons/react/IntegrationsFilled.tsx +13 -0
  142. package/src/icons/react/KeyboardHideDown.tsx +13 -0
  143. package/src/icons/react/LayoutMultiple.tsx +13 -0
  144. package/src/icons/react/LocationEdit.tsx +13 -0
  145. package/src/icons/react/MessagePlus.tsx +13 -0
  146. package/src/icons/react/RicheditorMarkHighlight.tsx +13 -0
  147. package/src/icons/react/SearchFilled.tsx +13 -0
  148. package/src/icons/react/SettingsFilled.tsx +13 -0
  149. package/src/icons/react/SlideMenuFilled.tsx +13 -0
  150. package/src/icons/react/SpaceApp.tsx +13 -0
  151. package/src/icons/react/SpaceGenerate.tsx +13 -0
  152. package/src/icons/react/SpaceScratch.tsx +13 -0
  153. package/src/icons/react/SpaceTemplate.tsx +13 -0
  154. package/src/icons/react/TableLayout.tsx +13 -0
  155. package/src/icons/react/TemplatesFilled.tsx +13 -0
  156. package/src/icons/react/ThumbsDown.tsx +13 -0
  157. package/src/icons/react/ThumbsUp.tsx +13 -0
  158. package/src/icons/react/ViewDashboard.tsx +13 -0
  159. package/src/icons/react/WarningTriangleFilled.tsx +13 -0
  160. package/src/icons/react/Windows.tsx +13 -0
  161. package/src/icons/react/index.tsx +37 -0
  162. package/src/icons/svg/activity-filled.svg +4 -0
  163. package/src/icons/svg/ai-assistant-filled.svg +3 -0
  164. package/src/icons/svg/ai-fibery-build.svg +24 -0
  165. package/src/icons/svg/anthropic.svg +2 -14
  166. package/src/icons/svg/apple.svg +4 -0
  167. package/src/icons/svg/arrow-bottom.svg +1 -1
  168. package/src/icons/svg/arrow-forward.svg +1 -1
  169. package/src/icons/svg/arrow-left.svg +1 -1
  170. package/src/icons/svg/arrow-right.svg +1 -1
  171. package/src/icons/svg/arrow-top.svg +1 -1
  172. package/src/icons/svg/collapse-all-horizontal.svg +3 -0
  173. package/src/icons/svg/crosshair.svg +4 -0
  174. package/src/icons/svg/date-range.svg +3 -3
  175. package/src/icons/svg/document.svg +4 -0
  176. package/src/icons/svg/entity-create-filled.svg +4 -0
  177. package/src/icons/svg/entity-create.svg +3 -0
  178. package/src/icons/svg/expand-all-horizontal.svg +3 -0
  179. package/src/icons/svg/expand-all.svg +3 -0
  180. package/src/icons/svg/fibery-desktop-app.svg +101 -0
  181. package/src/icons/svg/file-download.svg +4 -0
  182. package/src/icons/svg/globe-unpublish.svg +4 -0
  183. package/src/icons/svg/go-to.svg +1 -3
  184. package/src/icons/svg/graduation-cap-filled.svg +4 -0
  185. package/src/icons/svg/home-filled.svg +3 -0
  186. package/src/icons/svg/home.svg +4 -2
  187. package/src/icons/svg/import-filled.svg +4 -0
  188. package/src/icons/svg/integrations-filled.svg +4 -0
  189. package/src/icons/svg/keyboard-hide-down.svg +1 -0
  190. package/src/icons/svg/layout-multiple.svg +3 -0
  191. package/src/icons/svg/location-edit.svg +13 -0
  192. package/src/icons/svg/message-plus.svg +4 -0
  193. package/src/icons/svg/open-ai.svg +2 -7
  194. package/src/icons/svg/open-as-page.svg +2 -3
  195. package/src/icons/svg/richeditor/history/redo.svg +3 -2
  196. package/src/icons/svg/richeditor/history/undo.svg +3 -2
  197. package/src/icons/svg/richeditor/mark/code.svg +4 -5
  198. package/src/icons/svg/richeditor/mark/em.svg +3 -2
  199. package/src/icons/svg/richeditor/mark/highlight.svg +3 -0
  200. package/src/icons/svg/richeditor/mark/strike.svg +3 -2
  201. package/src/icons/svg/richeditor/mark/strong.svg +3 -2
  202. package/src/icons/svg/richeditor/mark/underline.svg +4 -2
  203. package/src/icons/svg/search-filled.svg +3 -0
  204. package/src/icons/svg/settings-filled.svg +3 -0
  205. package/src/icons/svg/slide-menu-filled.svg +1 -0
  206. package/src/icons/svg/space-app.svg +3 -0
  207. package/src/icons/svg/space-generate.svg +3 -0
  208. package/src/icons/svg/space-scratch.svg +3 -0
  209. package/src/icons/svg/space-template.svg +3 -0
  210. package/src/icons/svg/table-layout.svg +3 -0
  211. package/src/icons/svg/templates-filled.svg +6 -0
  212. package/src/icons/svg/thumbs-down.svg +3 -0
  213. package/src/icons/svg/thumbs-up.svg +3 -0
  214. package/src/icons/svg/type/date.svg +3 -2
  215. package/src/icons/svg/view-dashboard.svg +5 -0
  216. package/src/icons/svg/warning-triangle-filled.svg +3 -0
  217. package/src/icons/svg/windows.svg +15 -0
  218. package/src/images-gallery/images-gallery.tsx +254 -0
  219. package/src/images-gallery/zoom.tsx +112 -0
  220. package/src/integration-compact-info-button.tsx +3 -1
  221. package/src/is-in-popup.ts +1 -1
  222. package/src/layout-styles.ts +43 -0
  223. package/src/lists/actions-menu-row-surface.tsx +3 -1
  224. package/src/lists/list-row-surface.tsx +9 -2
  225. package/src/loaders.tsx +6 -6
  226. package/src/logo.tsx +16 -9
  227. package/src/mobile-keyboard-aware-popup.tsx +87 -0
  228. package/src/mobile-styles.ts +10 -0
  229. package/src/modal-menu/contexts/modal-menu-context.tsx +22 -0
  230. package/src/modal-menu/contexts/modal-submenu-context.tsx +16 -0
  231. package/src/modal-menu/index.tsx +14 -0
  232. package/src/modal-menu/modal-menu-content.tsx +68 -0
  233. package/src/modal-menu/modal-menu-group.tsx +10 -0
  234. package/src/modal-menu/modal-menu-item.tsx +37 -0
  235. package/src/modal-menu/modal-menu-label.tsx +24 -0
  236. package/src/modal-menu/modal-menu-root.tsx +57 -0
  237. package/src/modal-menu/modal-menu-separator.tsx +14 -0
  238. package/src/modal-menu/modal-menu-trigger.tsx +37 -0
  239. package/src/modal-menu/modal-submenu-content.tsx +49 -0
  240. package/src/modal-menu/modal-submenu-trigger.tsx +34 -0
  241. package/src/modal-menu/modal-submenu.tsx +17 -0
  242. package/src/new-badge.tsx +4 -7
  243. package/src/number-input/text-area-auto-sized.tsx +47 -0
  244. package/src/number-input/text-input-auto-sized.tsx +49 -0
  245. package/src/online-users.tsx +3 -3
  246. package/src/palette.ts +50 -50
  247. package/src/popover/index.tsx +687 -0
  248. package/src/popover/mobile-popup-context.tsx +29 -0
  249. package/src/{popup → popover}/modifiers.tsx +0 -7
  250. package/src/{popup → popover}/popup-modifiers-context.ts +3 -3
  251. package/src/reactions/reaction-button.tsx +30 -45
  252. package/src/reactions/reaction-picker.tsx +39 -45
  253. package/src/rich-text-embed-error.tsx +2 -2
  254. package/src/select/{custom-select-partials → components}/menu.tsx +13 -7
  255. package/src/select/{custom-select-partials → components}/no-option-message.tsx +0 -1
  256. package/src/select/constants.ts +1 -0
  257. package/src/select/index.tsx +143 -148
  258. package/src/select/select-in-popover.tsx +119 -138
  259. package/src/select/styles.ts +60 -24
  260. package/src/shortcut-badge.tsx +1 -0
  261. package/src/tab-nav/tab-nav.tsx +47 -28
  262. package/src/theme-provider.tsx +9 -1
  263. package/src/toast/primitives.tsx +8 -1
  264. package/src/toggle-button/round-toggle-button.tsx +23 -0
  265. package/src/toggle-button/toggle-button-group.tsx +34 -0
  266. package/src/toggle-button/toggle-button.tsx +164 -0
  267. package/src/toggle.tsx +3 -3
  268. package/src/tooltip-if-overflown.tsx +9 -3
  269. package/src/tooltip.tsx +2 -2
  270. package/src/unit/index.tsx +9 -1
  271. package/src/unit/loading-unit-value.tsx +1 -0
  272. package/src/unit/maybe-unit-value.tsx +3 -3
  273. package/src/unit/primitive.tsx +58 -42
  274. package/src/unit/styles.ts +10 -14
  275. package/src/unit/types.ts +4 -2
  276. package/src/unit/unit-button-group.tsx +6 -11
  277. package/src/unit/unit-content.tsx +13 -5
  278. package/src/unit/unit-with-title.tsx +6 -1
  279. package/src/unit/unit-with-tooltip.tsx +24 -9
  280. package/src/use-is-phone.tsx +37 -0
  281. package/src/use-is-support-hover.ts +1 -1
  282. package/src/use-on-screen-keyboard-data.tsx +66 -0
  283. package/src/workflow-progress-icon.tsx +17 -23
  284. package/src/number-input/text-area-with-autosize.tsx +0 -91
  285. package/src/number-input/text-inline-input-with-autosize.tsx +0 -60
  286. package/src/popup/index.tsx +0 -382
  287. package/src/use-is-phone.ts +0 -5
  288. /package/src/{popup → popover}/popup-stack-context.tsx +0 -0
  289. /package/src/{popup → popover}/reference.ts +0 -0
  290. /package/src/{popup → popover}/styles.ts +0 -0
  291. /package/src/{popup → popover}/use-click-outside.ts +0 -0
  292. /package/src/select/{custom-select-partials → components}/clear-indicator.tsx +0 -0
  293. /package/src/select/{custom-select-partials → components}/drop-down-indicator.tsx +0 -0
  294. /package/src/select/{custom-select-partials → components}/group-heading.tsx +0 -0
  295. /package/src/select/{custom-select-partials → components}/menu-list-virtualized.tsx +0 -0
  296. /package/src/select/{custom-select-partials → components}/option.tsx +0 -0
@@ -0,0 +1,57 @@
1
+ import {fontWeight, space, themeVars} from "./design-system";
2
+ import {css} from "@linaria/core";
3
+ import cx from "classnames";
4
+ import {ReactNode} from "react";
5
+
6
+ type Props = {
7
+ className?: string;
8
+ count: number;
9
+ };
10
+
11
+ const countStyle = css`
12
+ display: inline-block;
13
+ padding: 0 ${space.s6}px 0 ${space.s6}px;
14
+ border-radius: ${space.s8}px;
15
+ font-size: 11px;
16
+ line-height: 16px;
17
+ font-weight: ${fontWeight.regular};
18
+ `;
19
+
20
+ const countMinWidth = css`
21
+ min-width: 1.5ch;
22
+ text-align: center;
23
+ box-sizing: content-box;
24
+ `;
25
+
26
+ const countBadgeStyle = css`
27
+ background: ${themeVars.badgeBgColor};
28
+ color: ${themeVars.textColor};
29
+ `;
30
+
31
+ const warningStyle = css`
32
+ background: ${themeVars.warning};
33
+ color: ${themeVars.textColor};
34
+ `;
35
+
36
+ export function CountBadge({className, count}: Props) {
37
+ return <span className={cx(countStyle, countBadgeStyle, className)}>{count <= 99 ? count : "99+"}</span>;
38
+ }
39
+
40
+ export function CountBadgeWithNoLimits({count, warning}: {count: number | string; warning?: boolean}) {
41
+ return <span className={cx(countStyle, countBadgeStyle, countMinWidth, warning && warningStyle)}>{count}</span>;
42
+ }
43
+
44
+ export const ContentWithBadge = ({badge, children}: {badge: ReactNode; children: ReactNode}) => {
45
+ return (
46
+ <div
47
+ className={css`
48
+ display: flex;
49
+ align-items: center;
50
+ gap: ${space.s6}px;
51
+ `}
52
+ >
53
+ {children}
54
+ {badge}
55
+ </div>
56
+ );
57
+ };
@@ -219,7 +219,7 @@ export const DateRangeInput = forwardRef<
219
219
  }
220
220
  }
221
221
 
222
- const [result] = getLocaleSpecificChrono().parse(inputValue.replace(datesSeparator, " - "));
222
+ const [result] = getLocaleSpecificChrono(dateFormat).parse(inputValue.replace(datesSeparator, " - "));
223
223
  let start;
224
224
  let end;
225
225
  if (result && result.start && result.end) {
@@ -1,5 +1,5 @@
1
1
  import {ControlledDatePickerProps, DatePickerCommonProps, MomentDateRangeProps} from "./types";
2
- import {Popup} from "../popup";
2
+ import {PopoverOld} from "../popover";
3
3
  import {space} from "../design-system";
4
4
  import {withPopupControl} from "./with-popup-control";
5
5
  import {DateRangePickerPopupContent} from "./date-range-picker-popup-content";
@@ -19,6 +19,7 @@ export const DateRangePicker = forwardRef<
19
19
  DatePickerCommonProps & ControlledDatePickerProps & MomentDateRangeProps
20
20
  >((props, ref) => {
21
21
  const {
22
+ title,
22
23
  open,
23
24
  onOpen,
24
25
  onClose,
@@ -90,13 +91,15 @@ export const DateRangePicker = forwardRef<
90
91
 
91
92
  return (
92
93
  <div ref={bypassedRef}>
93
- <Popup
94
+ <PopoverOld
95
+ title={title}
94
96
  offset={[0, space.s6]}
95
97
  trigger={
96
98
  <div ref={fakeWrapperRef} onClick={stopPropagation}>
97
99
  {pickerValue}
98
100
  </div>
99
101
  }
102
+ supportMobile
100
103
  placement="bottom-start"
101
104
  open={open}
102
105
  onOpen={onOpen}
@@ -116,7 +119,7 @@ export const DateRangePicker = forwardRef<
116
119
  value={dateValue}
117
120
  onKeyDown={onDatePickerKeyDown}
118
121
  />
119
- </Popup>
122
+ </PopoverOld>
120
123
  </div>
121
124
  );
122
125
  });
@@ -33,7 +33,7 @@ export const FakeDateInputWrapper = forwardRef<HTMLDivElement, Props>(function F
33
33
  >
34
34
  <div>{children}</div>
35
35
  <div className={cn(expanderStyle, isPickerOpen && expanderExpandedStyle)}>
36
- <ArrowCollapseVertical color={themeVars.disabledTextColor} />
36
+ {disabled ? null : <ArrowCollapseVertical color={themeVars.disabledTextColor} />}
37
37
  </div>
38
38
  </div>
39
39
  );
@@ -1,11 +1,12 @@
1
1
  import {css} from "@linaria/core";
2
2
  import {space, textStyles, themeVars} from "../design-system";
3
3
  import {SingleRowSelect as SingleRowReactSelect, SingleValue} from "../select";
4
- import {AlwaysVisibleDropdownIndicator} from "../select/custom-select-partials/drop-down-indicator";
4
+ import {AlwaysVisibleDropdownIndicator} from "../select/components/drop-down-indicator";
5
5
  import {RelativeDateValue} from "./types";
6
6
  import {useCallback, useMemo, useState} from "react";
7
7
  import {$TSFixMe} from "../tsfixme";
8
8
  import {AntInputNumber} from "../antd/input-number";
9
+ import {unitOfTime} from "moment";
9
10
 
10
11
  type RelativeDatePickerProps = {
11
12
  value: RelativeDateValue | null;
@@ -29,11 +30,14 @@ const isBeforeNowOptions = [
29
30
  export const RelativeDatePicker = (props: RelativeDatePickerProps) => {
30
31
  const {value, onChange, relativeDateToExactDate} = props;
31
32
 
32
- const valueWithDefault = useMemo(() => value ?? {unit: "day", isBeforeNow: true, amount: 0}, [value]);
33
+ const valueWithDefault = useMemo(
34
+ () => value ?? {unit: "day" as unitOfTime.DurationConstructor, isBeforeNow: true, amount: 0},
35
+ [value]
36
+ );
33
37
 
34
38
  const onUnitChange = useCallback(
35
39
  (newUnit: SingleValue<{value: string}>) => {
36
- onChange({...valueWithDefault, unit: newUnit!.value});
40
+ onChange({...valueWithDefault, unit: newUnit!.value as unitOfTime.DurationConstructor});
37
41
  },
38
42
  [valueWithDefault, onChange]
39
43
  );
@@ -143,7 +143,7 @@ export const SingleDateInput = forwardRef<
143
143
  }
144
144
  }
145
145
 
146
- const [result] = getLocaleSpecificChrono().parse(inputValue);
146
+ const [result] = getLocaleSpecificChrono(dateFormat).parse(inputValue);
147
147
  if (result && result.start) {
148
148
  const newValue = result.start.date();
149
149
  onChange(newValue);
@@ -11,7 +11,7 @@ import moment, {Moment} from "moment";
11
11
  import _ from "lodash";
12
12
  import {EmptyValue} from "../empty-value";
13
13
  import {formatDateInputValue} from "./utils";
14
- import {Popup} from "../popup";
14
+ import {PopoverOld} from "../popover";
15
15
  import {focusable} from "tabbable";
16
16
  import {TabNavLink, TabNavList, TabNavRoot} from "../tab-nav/tab-nav";
17
17
  import {RelativeDatePicker} from "./relative-date-picker";
@@ -29,7 +29,7 @@ const tabNavLinkClassName = css`
29
29
  justify-content: center;
30
30
  `;
31
31
 
32
- const isRelativeDatePlaceholder = (value: $TSFixMe) => {
32
+ export const isRelativeDatePlaceholder = (value: $TSFixMe) => {
33
33
  return (
34
34
  value !== null &&
35
35
  Object.hasOwn(value, "isBeforeNow") &&
@@ -38,7 +38,7 @@ const isRelativeDatePlaceholder = (value: $TSFixMe) => {
38
38
  );
39
39
  };
40
40
 
41
- const formatRelativeDate = (value: RelativeDateValue) => {
41
+ export const formatRelativeDate = (value: RelativeDateValue) => {
42
42
  if (value.amount === 0) {
43
43
  return "today";
44
44
  } else if (value.amount === 1 && value.unit === "day" && !value.isBeforeNow) {
@@ -76,6 +76,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
76
76
  SingleDatePickerProps<boolean>
77
77
  >((props, ref) => {
78
78
  const {
79
+ title,
79
80
  open,
80
81
  onOpen,
81
82
  onClose,
@@ -156,7 +157,8 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
156
157
 
157
158
  return (
158
159
  <div ref={bypassedRef}>
159
- <Popup
160
+ <PopoverOld
161
+ title={title}
160
162
  offset={[0, space.s6]}
161
163
  trigger={
162
164
  <div ref={fakeWrapperRef} onClick={stopPropagation}>
@@ -167,6 +169,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
167
169
  open={open}
168
170
  onOpen={onOpen}
169
171
  onClose={onClose}
172
+ supportMobile
170
173
  popupContainerClassName={css`
171
174
  z-index: 10001;
172
175
  `}
@@ -234,7 +237,7 @@ export const SingleDatePicker: SingleDatePickerWithForwardRefType = forwardRef<
234
237
  />
235
238
  )}
236
239
  </div>
237
- </Popup>
240
+ </PopoverOld>
238
241
  </div>
239
242
  );
240
243
  });
@@ -1,6 +1,7 @@
1
1
  import {css} from "@linaria/core";
2
2
  import {inputOverrides} from "../antd/styles";
3
3
  import {border, fontWeight, space, textStyles, themeVars} from "../design-system";
4
+ import {mobileRootSelector} from "../mobile-styles";
4
5
 
5
6
  export const selectedStyle = css`
6
7
  ${inputOverrides.focus}
@@ -113,6 +114,32 @@ export const endButtonClassName = css`
113
114
  background: linear-gradient(90deg, ${focusGradient}) !important;
114
115
  }
115
116
  `;
117
+ export const dayWrapper = css`
118
+ display: flex;
119
+ height: 100%;
120
+ position: relative;
121
+ `;
122
+ export const dayContentClassName = css`
123
+ pointer-events: none;
124
+ position: absolute;
125
+ top: 0;
126
+ bottom: 0;
127
+ left: 0;
128
+ right: 0;
129
+ display: flex;
130
+ align-items: center;
131
+ justify-content: center;
132
+ `;
133
+ export const dayButtonsContainerClassName = css`
134
+ position: absolute;
135
+ top: 0;
136
+ left: 0;
137
+ bottom: 0;
138
+ right: 0;
139
+ display: flex;
140
+ align-items: stretch;
141
+ justify-content: stretch;
142
+ `;
116
143
  export const datePickerStylesOverrideClassName = css`
117
144
  .rdp {
118
145
  --rdp-cell-size: 36px;
@@ -150,6 +177,11 @@ export const datePickerStylesOverrideClassName = css`
150
177
  border: none !important;
151
178
  }
152
179
 
180
+ ${mobileRootSelector} & .${dayContentClassName} {
181
+ width: auto;
182
+ max-width: unset;
183
+ }
184
+
153
185
  .rdp-day.${startRangeClassName}.${endRangeClassName} {
154
186
  border-radius: ${border.radius12}px !important;
155
187
  }
@@ -234,29 +266,3 @@ export const datePickerStylesOverrideClassName = css`
234
266
  }
235
267
  }
236
268
  `;
237
- export const dayWrapper = css`
238
- display: flex;
239
- height: 100%;
240
- position: relative;
241
- `;
242
- export const dayContentClassName = css`
243
- pointer-events: none;
244
- position: absolute;
245
- top: 0;
246
- bottom: 0;
247
- left: 0;
248
- right: 0;
249
- display: flex;
250
- align-items: center;
251
- justify-content: center;
252
- `;
253
- export const dayButtonsContainerClassName = css`
254
- position: absolute;
255
- top: 0;
256
- left: 0;
257
- bottom: 0;
258
- right: 0;
259
- display: flex;
260
- align-items: stretch;
261
- justify-content: stretch;
262
- `;
@@ -1,8 +1,9 @@
1
1
  import {Moment} from "moment";
2
2
  import {$TSFixMe} from "../tsfixme";
3
3
  import {ReactNode} from "react";
4
+ import {unitOfTime} from "moment";
4
5
 
5
- export type RelativeDateValue = {isBeforeNow: boolean; unit: string; amount: number};
6
+ export type RelativeDateValue = {isBeforeNow: boolean; unit: unitOfTime.DurationConstructor; amount: number};
6
7
 
7
8
  export type MomentSingleDateProps<AllowRelativeDate extends boolean = false> = {
8
9
  value: AllowRelativeDate extends true ? Moment | RelativeDateValue | null : Moment | null;
@@ -17,6 +18,7 @@ export type NativeSingleDatePickerProps = {
17
18
  };
18
19
 
19
20
  export type DatePickerCommonProps = {
21
+ title?: string;
20
22
  showTime?: boolean;
21
23
  showToday?: boolean;
22
24
  showInput?: boolean;
@@ -7,9 +7,16 @@ import {
7
7
  dateTimeFormat as defaultDateTimeFormat,
8
8
  } from "../design-system";
9
9
 
10
- export const getLocaleSpecificChrono = () => {
10
+ const isMonthBeforeDay = (format: string) => {
11
+ // Hacky way to get rid of ddd specifier, which does not matter for us here
12
+ const sanitizedFormat = format.replace("ddd", "").toLowerCase();
13
+ return sanitizedFormat.indexOf("m") < sanitizedFormat.indexOf("d");
14
+ };
15
+
16
+ export const getLocaleSpecificChrono = (dateFormat: string | undefined) => {
17
+ const weirdFormat = dateFormat && isMonthBeforeDay(dateFormat);
11
18
  // We use a single exception here - to support US date order, like m/d/y
12
- if (navigator.language.toLowerCase().endsWith("-us")) {
19
+ if (weirdFormat) {
13
20
  return chrono.en;
14
21
  }
15
22
  // Otherwise, use european-style d/m/y
@@ -1,71 +1,27 @@
1
- import {ChangeEvent} from "react";
2
1
  import {css} from "@linaria/core";
3
- import {colors, themeVars} from "../design-system";
4
- import {inputOverrides} from "../antd/styles";
2
+ import {RoundToggleButton} from "../toggle-button/round-toggle-button";
3
+ import {ToggleButtonGroup, ToggleButtonGroupItem} from "../toggle-button/toggle-button-group";
5
4
 
6
- export type Props<T extends number> = {
7
- value: Array<T>;
8
- onChange: (v: Array<T>) => void;
9
- days: Array<{key: string; title: string; value: T}>;
5
+ export type Props = {
6
+ value: Array<number>;
7
+ onChange: (v: Array<number>) => void;
8
+ days: Array<{key: string; title: string; value: number}>;
10
9
  allowEmpty?: boolean;
11
10
  };
12
11
 
13
- const daySize = "28px";
12
+ export function DaySelect({value = [], onChange, days, allowEmpty = false}: Props): JSX.Element {
13
+ const stringifiedValue = value.map((v) => v.toString());
14
14
 
15
- const checkboxInput = css`
16
- position: absolute;
17
- appearance: none;
18
- `;
19
-
20
- const checkbox = css`
21
- position: absolute;
22
- border-radius: 50%;
23
- font-size: 14px;
24
- width: ${daySize};
25
- height: ${daySize};
26
- display: flex;
27
- align-items: center;
28
- justify-content: center;
29
- color: ${themeVars.accentTextColor};
30
- background-color: ${themeVars.unitBg};
31
- .${checkboxInput}:checked + & {
32
- color: ${colors.inversedTextColor};
33
- background-color: ${themeVars.primary};
34
- }
35
- .${checkboxInput}:focus-visible + & {
36
- ${inputOverrides.focus}
37
- }
38
- `;
39
-
40
- function Day<T extends number>({
41
- value,
42
- onChange,
43
- checked,
44
- title,
45
- }: {
46
- value: T;
47
- onChange: (e: ChangeEvent<HTMLInputElement>) => void;
48
- checked: boolean;
49
- title: string;
50
- }): JSX.Element {
51
- return (
52
- <label
53
- className={css`
54
- cursor: pointer;
55
- position: relative;
56
- width: ${daySize};
57
- height: ${daySize};
58
- `}
59
- >
60
- <input className={checkboxInput} onChange={onChange} checked={checked} type="checkbox" value={value} />
61
- <div className={checkbox}>{title}</div>
62
- </label>
63
- );
64
- }
65
-
66
- export function DaySelect<T extends number>({value = [], onChange, days, allowEmpty = false}: Props<T>): JSX.Element {
67
15
  return (
68
- <div
16
+ <ToggleButtonGroup
17
+ type="multiple"
18
+ value={stringifiedValue}
19
+ onValueChange={(v) => {
20
+ if (v.length === 0 && !allowEmpty) {
21
+ return;
22
+ }
23
+ onChange(v.map(Number));
24
+ }}
69
25
  className={css`
70
26
  grid-template-columns: repeat(7, min-content);
71
27
  gap: 4px;
@@ -74,21 +30,11 @@ export function DaySelect<T extends number>({value = [], onChange, days, allowEm
74
30
  >
75
31
  {days.map(({key, value: v, title}) => {
76
32
  return (
77
- <Day
78
- checked={value.includes(v)}
79
- onChange={({currentTarget: {checked}}) => {
80
- if (checked) {
81
- onChange(value.concat(v));
82
- } else if (allowEmpty || value.length > 1) {
83
- onChange(value.filter((val) => val !== v));
84
- }
85
- }}
86
- key={key}
87
- title={title}
88
- value={v}
89
- />
33
+ <ToggleButtonGroupItem key={key} asChild value={v.toString()}>
34
+ <RoundToggleButton>{title}</RoundToggleButton>
35
+ </ToggleButtonGroupItem>
90
36
  );
91
37
  })}
92
- </div>
38
+ </ToggleButtonGroup>
93
39
  );
94
40
  }
@@ -10,6 +10,6 @@ const isoWeekDays = _.range(1, 8).map((day) => {
10
10
  };
11
11
  });
12
12
 
13
- export function IsoWeekdaySelect({value, onChange, allowEmpty}: Omit<Props<number>, "days">): JSX.Element {
13
+ export function IsoWeekdaySelect({value, onChange, allowEmpty}: Omit<Props, "days">): JSX.Element {
14
14
  return <DaySelect value={value} onChange={onChange} days={isoWeekDays} allowEmpty={allowEmpty} />;
15
15
  }
@@ -3,9 +3,9 @@ import {DaySelect, Props} from "./day-select";
3
3
  const days = Array.from({length: 28}).map((_, index) => {
4
4
  const value = index + 1;
5
5
  const key = String(value);
6
- return {key: String(value), title: key, value};
6
+ return {key: String(value), title: key, value: value};
7
7
  });
8
8
 
9
- export function MonthdaySelect({value = [], onChange}: Omit<Props<number>, "days">): JSX.Element {
9
+ export function MonthdaySelect({value = [], onChange}: Omit<Props, "days">): JSX.Element {
10
10
  return <DaySelect value={value} onChange={onChange} days={days} />;
11
11
  }
@@ -32,11 +32,7 @@ export const getDays = _.memoize((firstDay) => {
32
32
  });
33
33
  });
34
34
 
35
- export function WeekdaySelect({
36
- value = [],
37
- onChange,
38
- firstDay,
39
- }: Omit<Props<Days>, "days"> & {firstDay: number}): JSX.Element {
35
+ export function WeekdaySelect({value = [], onChange, firstDay}: Omit<Props, "days"> & {firstDay: number}): JSX.Element {
40
36
  const days = getDays(firstDay);
41
37
  return <DaySelect value={value} onChange={onChange} days={days} />;
42
38
  }