@fibery/ui-kit 1.36.2 → 1.37.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/action-badge.tsx +5 -4
- package/src/actions-menu/actions-menu-confirmation.tsx +1 -12
- package/src/actions-menu/actions-menu-item.tsx +1 -1
- package/src/antd/ant-modal.tsx +17 -2
- package/src/antd/input.tsx +4 -3
- package/src/app-icon-with-fallback.tsx +5 -8
- package/src/app-icon-wrapper.tsx +4 -4
- package/src/appIcons.json +20 -0
- package/src/badge.tsx +14 -7
- package/src/beta-badge.tsx +12 -8
- package/src/button/actions-button-compact.tsx +1 -1
- package/src/button/base-button.tsx +2 -1
- package/src/button/button.tsx +89 -2
- package/src/button/icon-button.tsx +4 -2
- package/src/button/select-button.tsx +23 -8
- package/src/card-container.tsx +29 -65
- package/src/card-hidden-link.tsx +52 -0
- package/src/collapsible-section.tsx +13 -3
- package/src/color-picker/index.js +65 -60
- package/src/color-picker/swatch.tsx +28 -14
- package/src/command-menu/index.tsx +2 -2
- package/src/count-badge.tsx +57 -0
- package/src/date-picker/date-range-input.tsx +1 -1
- package/src/date-picker/fake-date-input.tsx +1 -1
- package/src/date-picker/relative-date-picker.tsx +1 -1
- package/src/date-picker/single-date-input.tsx +1 -1
- package/src/date-picker/utils.ts +9 -2
- package/src/design-system.ts +72 -41
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -9
- package/src/emoji-picker/icon-emoji-picker.tsx +75 -69
- package/src/emoji-picker/primitives/header.tsx +1 -0
- package/src/emoji-picker/primitives/search.tsx +12 -13
- package/src/error-alert/error-alert.tsx +19 -7
- package/src/field-app-icon.tsx +29 -0
- package/src/field-container.tsx +4 -2
- package/src/field-icon.tsx +26 -0
- package/src/field-type-icon.tsx +82 -0
- package/src/guide-link.tsx +4 -3
- package/src/hint.tsx +10 -1
- package/src/html-styles.ts +15 -13
- package/src/icons/ast/AiFiberyBuild.ts +8 -0
- package/src/icons/ast/Anthropic.ts +1 -1
- package/src/icons/ast/Apple.ts +8 -0
- package/src/icons/ast/ArrowBottom.ts +1 -1
- package/src/icons/ast/ArrowForward.ts +1 -1
- package/src/icons/ast/ArrowLeft.ts +1 -1
- package/src/icons/ast/ArrowRight.ts +1 -1
- package/src/icons/ast/ArrowTop.ts +1 -1
- package/src/icons/ast/Crosshair.ts +8 -0
- package/src/icons/ast/Document.ts +8 -0
- package/src/icons/ast/EntityCreate.ts +8 -0
- package/src/icons/ast/ExpandAll.ts +8 -0
- package/src/icons/ast/FiberyDesktopApp.ts +8 -0
- package/src/icons/ast/FileDownload.ts +8 -0
- package/src/icons/ast/GraduationCapFilled.ts +8 -0
- package/src/icons/ast/Home.ts +1 -1
- package/src/icons/ast/ImportFilled.ts +8 -0
- package/src/icons/ast/IntegrationsFilled.ts +8 -0
- package/src/icons/ast/LocationEdit.ts +8 -0
- package/src/icons/ast/MessagePlus.ts +8 -0
- package/src/icons/ast/OpenAi.ts +1 -1
- package/src/icons/ast/RicheditorMarkHighlight.ts +8 -0
- package/src/icons/ast/RicheditorMarkStrike.ts +1 -1
- package/src/icons/ast/RicheditorMarkUnderline.ts +1 -1
- package/src/icons/ast/SpaceApp.ts +8 -0
- package/src/icons/ast/SpaceGenerate.ts +8 -0
- package/src/icons/ast/SpaceScratch.ts +8 -0
- package/src/icons/ast/SpaceTemplate.ts +8 -0
- package/src/icons/ast/TableLayout.ts +8 -0
- package/src/icons/ast/TemplatesFilled.ts +8 -0
- package/src/icons/ast/ThumbsDown.ts +8 -0
- package/src/icons/ast/ThumbsUp.ts +8 -0
- package/src/icons/ast/ViewDashboard.ts +8 -0
- package/src/icons/ast/WarningTriangleFilled.ts +8 -0
- package/src/icons/ast/Windows.ts +8 -0
- package/src/icons/ast/index.tsx +25 -0
- package/src/icons/react/AiFiberyBuild.tsx +13 -0
- package/src/icons/react/Apple.tsx +13 -0
- package/src/icons/react/Crosshair.tsx +13 -0
- package/src/icons/react/Document.tsx +13 -0
- package/src/icons/react/EntityCreate.tsx +13 -0
- package/src/icons/react/ExpandAll.tsx +13 -0
- package/src/icons/react/FiberyDesktopApp.tsx +13 -0
- package/src/icons/react/FileDownload.tsx +13 -0
- package/src/icons/react/GraduationCapFilled.tsx +13 -0
- package/src/icons/react/ImportFilled.tsx +13 -0
- package/src/icons/react/IntegrationsFilled.tsx +13 -0
- package/src/icons/react/LocationEdit.tsx +13 -0
- package/src/icons/react/MessagePlus.tsx +13 -0
- package/src/icons/react/RicheditorMarkHighlight.tsx +13 -0
- package/src/icons/react/SpaceApp.tsx +13 -0
- package/src/icons/react/SpaceGenerate.tsx +13 -0
- package/src/icons/react/SpaceScratch.tsx +13 -0
- package/src/icons/react/SpaceTemplate.tsx +13 -0
- package/src/icons/react/TableLayout.tsx +13 -0
- package/src/icons/react/TemplatesFilled.tsx +13 -0
- package/src/icons/react/ThumbsDown.tsx +13 -0
- package/src/icons/react/ThumbsUp.tsx +13 -0
- package/src/icons/react/ViewDashboard.tsx +13 -0
- package/src/icons/react/WarningTriangleFilled.tsx +13 -0
- package/src/icons/react/Windows.tsx +13 -0
- package/src/icons/react/index.tsx +25 -0
- package/src/icons/svg/ai-fibery-build.svg +24 -0
- package/src/icons/svg/anthropic.svg +2 -14
- package/src/icons/svg/apple.svg +4 -0
- package/src/icons/svg/arrow-bottom.svg +1 -1
- package/src/icons/svg/arrow-forward.svg +1 -1
- package/src/icons/svg/arrow-left.svg +1 -1
- package/src/icons/svg/arrow-right.svg +1 -1
- package/src/icons/svg/arrow-top.svg +1 -1
- package/src/icons/svg/crosshair.svg +4 -0
- package/src/icons/svg/document.svg +4 -0
- package/src/icons/svg/entity-create.svg +3 -0
- package/src/icons/svg/expand-all.svg +3 -0
- package/src/icons/svg/fibery-desktop-app.svg +101 -0
- package/src/icons/svg/file-download.svg +4 -0
- package/src/icons/svg/go-to.svg +1 -3
- package/src/icons/svg/graduation-cap-filled.svg +4 -0
- package/src/icons/svg/home.svg +4 -2
- package/src/icons/svg/import-filled.svg +4 -0
- package/src/icons/svg/integrations-filled.svg +4 -0
- package/src/icons/svg/location-edit.svg +13 -0
- package/src/icons/svg/message-plus.svg +4 -0
- package/src/icons/svg/open-ai.svg +2 -7
- package/src/icons/svg/open-as-page.svg +2 -3
- package/src/icons/svg/richeditor/mark/code.svg +4 -5
- package/src/icons/svg/richeditor/mark/em.svg +3 -2
- package/src/icons/svg/richeditor/mark/highlight.svg +3 -0
- package/src/icons/svg/richeditor/mark/strike.svg +3 -2
- package/src/icons/svg/richeditor/mark/strong.svg +3 -2
- package/src/icons/svg/richeditor/mark/underline.svg +4 -2
- package/src/icons/svg/space-app.svg +3 -0
- package/src/icons/svg/space-generate.svg +3 -0
- package/src/icons/svg/space-scratch.svg +3 -0
- package/src/icons/svg/space-template.svg +3 -0
- package/src/icons/svg/table-layout.svg +3 -0
- package/src/icons/svg/templates-filled.svg +6 -0
- package/src/icons/svg/thumbs-down.svg +3 -0
- package/src/icons/svg/thumbs-up.svg +3 -0
- package/src/icons/svg/view-dashboard.svg +5 -0
- package/src/icons/svg/warning-triangle-filled.svg +3 -0
- package/src/icons/svg/windows.svg +15 -0
- package/src/integration-compact-info-button.tsx +3 -1
- package/src/layout-styles.ts +23 -0
- package/src/lists/list-row-surface.tsx +2 -1
- package/src/loaders.tsx +6 -6
- package/src/logo.tsx +16 -9
- package/src/mobile-styles.ts +2 -0
- package/src/new-badge.tsx +4 -7
- package/src/number-input/text-area-auto-sized.tsx +47 -0
- package/src/number-input/text-input-auto-sized.tsx +49 -0
- package/src/palette.ts +50 -50
- package/src/popup/index.tsx +1 -0
- package/src/rich-text-embed-error.tsx +2 -2
- package/src/select/{custom-select-partials → components}/menu.tsx +13 -7
- package/src/select/{custom-select-partials → components}/no-option-message.tsx +0 -1
- package/src/select/constants.ts +1 -0
- package/src/select/index.tsx +136 -145
- package/src/select/select-in-popover.tsx +101 -108
- package/src/select/styles.ts +60 -24
- package/src/shortcut-badge.tsx +1 -0
- package/src/tab-nav/tab-nav.tsx +12 -19
- package/src/theme-provider.tsx +9 -1
- package/src/tooltip-if-overflown.tsx +9 -3
- package/src/unit/index.tsx +9 -1
- package/src/unit/loading-unit-value.tsx +1 -0
- package/src/unit/maybe-unit-value.tsx +3 -3
- package/src/unit/primitive.tsx +58 -42
- package/src/unit/styles.ts +8 -12
- package/src/unit/types.ts +4 -2
- package/src/unit/unit-button-group.tsx +6 -11
- package/src/unit/unit-content.tsx +13 -5
- package/src/unit/unit-with-title.tsx +6 -1
- package/src/unit/unit-with-tooltip.tsx +24 -9
- package/src/use-is-phone.tsx +12 -0
- package/src/workflow-progress-icon.tsx +1 -1
- package/src/number-input/text-area-with-autosize.tsx +0 -91
- package/src/number-input/text-inline-input-with-autosize.tsx +0 -60
- package/src/use-is-phone.ts +0 -5
- /package/src/select/{custom-select-partials → components}/clear-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/drop-down-indicator.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/group-heading.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/menu-list-virtualized.tsx +0 -0
- /package/src/select/{custom-select-partials → components}/option.tsx +0 -0
package/src/card-container.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {preventDefault} from "@fibery/react/src/prevent-default";
|
|
2
1
|
import {stopPropagation} from "@fibery/react/src/stop-propagation";
|
|
3
2
|
import {css} from "@linaria/core";
|
|
4
3
|
import {styled} from "@linaria/react";
|
|
5
4
|
import cx from "classnames";
|
|
6
5
|
import {CSSProperties, ReactNode} from "react";
|
|
7
6
|
import {getBg} from "./box";
|
|
7
|
+
import {CardHiddenLink} from "./card-hidden-link";
|
|
8
8
|
import {border, space, themeVars} from "./design-system";
|
|
9
9
|
import {visuallyHidden} from "./styles-utils";
|
|
10
10
|
|
|
@@ -273,59 +273,6 @@ const ColorCoding = styled.div<{backgroundColors: string[]}>`
|
|
|
273
273
|
background: ${({backgroundColors}) => getBg(backgroundColors)};
|
|
274
274
|
`;
|
|
275
275
|
|
|
276
|
-
type LinkWrapperProps = {
|
|
277
|
-
href?: string;
|
|
278
|
-
coverArea: boolean;
|
|
279
|
-
children: ReactNode;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const LinkWrapper = ({href, coverArea, children}: LinkWrapperProps) => {
|
|
283
|
-
if (href) {
|
|
284
|
-
return (
|
|
285
|
-
<a
|
|
286
|
-
href={href}
|
|
287
|
-
draggable="false"
|
|
288
|
-
onClick={preventDefault}
|
|
289
|
-
// To avoid tab on hidden link. but with this we can't open card via keyboard navigation.
|
|
290
|
-
tabIndex={-1}
|
|
291
|
-
data-is-card-hidden-link={true}
|
|
292
|
-
className={
|
|
293
|
-
coverArea
|
|
294
|
-
? cx(
|
|
295
|
-
css`
|
|
296
|
-
&::after {
|
|
297
|
-
content: "";
|
|
298
|
-
position: absolute;
|
|
299
|
-
left: 0;
|
|
300
|
-
top: 0;
|
|
301
|
-
right: 0;
|
|
302
|
-
bottom: 0;
|
|
303
|
-
}
|
|
304
|
-
`
|
|
305
|
-
)
|
|
306
|
-
: cx(
|
|
307
|
-
css`
|
|
308
|
-
color: inherit;
|
|
309
|
-
|
|
310
|
-
&:hover {
|
|
311
|
-
color: inherit;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
&:visited {
|
|
315
|
-
color: inherit;
|
|
316
|
-
}
|
|
317
|
-
`
|
|
318
|
-
)
|
|
319
|
-
}
|
|
320
|
-
>
|
|
321
|
-
{children}
|
|
322
|
-
</a>
|
|
323
|
-
);
|
|
324
|
-
} else {
|
|
325
|
-
return <>{children}</>;
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
|
|
329
276
|
type Props = {
|
|
330
277
|
before: ReactNode;
|
|
331
278
|
title: ReactNode;
|
|
@@ -338,8 +285,13 @@ type Props = {
|
|
|
338
285
|
input?: boolean;
|
|
339
286
|
linkHref?: string;
|
|
340
287
|
titleClassName?: string;
|
|
288
|
+
titleString?: string;
|
|
341
289
|
};
|
|
342
290
|
|
|
291
|
+
const cardContent = css`
|
|
292
|
+
position: relative;
|
|
293
|
+
`;
|
|
294
|
+
|
|
343
295
|
export const CardContainer = ({
|
|
344
296
|
cover,
|
|
345
297
|
before,
|
|
@@ -352,6 +304,7 @@ export const CardContainer = ({
|
|
|
352
304
|
input,
|
|
353
305
|
linkHref,
|
|
354
306
|
titleClassName,
|
|
307
|
+
titleString,
|
|
355
308
|
}: Props) => {
|
|
356
309
|
const showCover = Boolean(cover && coverHeightBySize[size]);
|
|
357
310
|
const hasContent = Boolean(before || title || after);
|
|
@@ -381,14 +334,12 @@ export const CardContainer = ({
|
|
|
381
334
|
{cover}
|
|
382
335
|
</div>
|
|
383
336
|
)}
|
|
384
|
-
<div
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
<div className={visuallyHidden}>{title}</div>
|
|
391
|
-
</LinkWrapper>
|
|
337
|
+
<div className={cardContent}>
|
|
338
|
+
{linkHref ? (
|
|
339
|
+
<CardHiddenLink href={linkHref} coverArea={true}>
|
|
340
|
+
<div className={visuallyHidden}>{title}</div>
|
|
341
|
+
</CardHiddenLink>
|
|
342
|
+
) : null}
|
|
392
343
|
|
|
393
344
|
{backgroundColors && <ColorCoding className={colorCodingClassName} backgroundColors={backgroundColors} />}
|
|
394
345
|
|
|
@@ -406,12 +357,25 @@ export const CardContainer = ({
|
|
|
406
357
|
titleClassName
|
|
407
358
|
)}
|
|
408
359
|
>
|
|
409
|
-
|
|
410
|
-
{title}
|
|
411
|
-
</LinkWrapper>
|
|
360
|
+
{title}
|
|
412
361
|
</div>
|
|
413
362
|
)}
|
|
414
363
|
{after && <div className={afterStyles[size]}>{after}</div>}
|
|
364
|
+
<div
|
|
365
|
+
data-entity-title={titleString || ""}
|
|
366
|
+
className={cx(
|
|
367
|
+
`extension-entity-card-spot`,
|
|
368
|
+
css`
|
|
369
|
+
display: none;
|
|
370
|
+
.${cardContent}:hover &:not(:empty) {
|
|
371
|
+
display: block;
|
|
372
|
+
position: absolute;
|
|
373
|
+
top: ${space.s6}px;
|
|
374
|
+
right: ${space.s6}px;
|
|
375
|
+
}
|
|
376
|
+
`
|
|
377
|
+
)}
|
|
378
|
+
/>
|
|
415
379
|
</div>
|
|
416
380
|
)}
|
|
417
381
|
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {preventDefault} from "@fibery/react/src/prevent-default";
|
|
2
|
+
import {css, cx} from "@linaria/core";
|
|
3
|
+
import {ReactNode} from "react";
|
|
4
|
+
|
|
5
|
+
type CardHiddenLinkProps = {
|
|
6
|
+
href: string;
|
|
7
|
+
coverArea: boolean;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const CardHiddenLink = ({href, coverArea, children}: CardHiddenLinkProps) => {
|
|
12
|
+
return (
|
|
13
|
+
<a
|
|
14
|
+
href={href}
|
|
15
|
+
draggable="false"
|
|
16
|
+
onClick={preventDefault}
|
|
17
|
+
// To avoid tab on hidden link. but with this we can't open card via keyboard navigation.
|
|
18
|
+
tabIndex={-1}
|
|
19
|
+
data-is-card-hidden-link={true}
|
|
20
|
+
className={
|
|
21
|
+
coverArea
|
|
22
|
+
? cx(
|
|
23
|
+
css`
|
|
24
|
+
&::after {
|
|
25
|
+
content: "";
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
bottom: 0;
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
)
|
|
34
|
+
: cx(
|
|
35
|
+
css`
|
|
36
|
+
color: inherit;
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
color: inherit;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:visited {
|
|
43
|
+
color: inherit;
|
|
44
|
+
}
|
|
45
|
+
`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</a>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -3,11 +3,17 @@ import ArrowBottom from "./icons/react/ArrowBottom";
|
|
|
3
3
|
import ArrowTop from "./icons/react/ArrowTop";
|
|
4
4
|
import {ReactNode, useCallback} from "react";
|
|
5
5
|
import {useControllableState} from "@fibery/react/src/use-controllable-state";
|
|
6
|
+
import {space} from "./design-system";
|
|
6
7
|
|
|
7
8
|
const headerCss = css`
|
|
8
9
|
display: flex;
|
|
9
10
|
align-items: center;
|
|
10
|
-
|
|
11
|
+
gap: ${space.s8}px;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const arrowCss = css`
|
|
15
|
+
margin-left: auto;
|
|
16
|
+
margin-right: 0;
|
|
11
17
|
`;
|
|
12
18
|
|
|
13
19
|
type Props = {
|
|
@@ -17,6 +23,8 @@ type Props = {
|
|
|
17
23
|
collapsedDefault?: boolean;
|
|
18
24
|
onCollapsedChange?: (collapsed: boolean) => void;
|
|
19
25
|
children: ReactNode;
|
|
26
|
+
badge?: ReactNode;
|
|
27
|
+
keepChildren?: boolean;
|
|
20
28
|
};
|
|
21
29
|
|
|
22
30
|
export const CollapsibleSection = ({
|
|
@@ -26,6 +34,7 @@ export const CollapsibleSection = ({
|
|
|
26
34
|
collapsedDefault = false,
|
|
27
35
|
onCollapsedChange,
|
|
28
36
|
children,
|
|
37
|
+
badge,
|
|
29
38
|
}: Props) => {
|
|
30
39
|
const [isCollapsed, setIsCollapsed] = useControllableState({
|
|
31
40
|
value: collapsed,
|
|
@@ -33,7 +42,7 @@ export const CollapsibleSection = ({
|
|
|
33
42
|
onChange: onCollapsedChange,
|
|
34
43
|
});
|
|
35
44
|
|
|
36
|
-
const arrow = isCollapsed ? <ArrowBottom /> : <ArrowTop />;
|
|
45
|
+
const arrow = isCollapsed ? <ArrowBottom className={arrowCss} /> : <ArrowTop className={arrowCss} />;
|
|
37
46
|
|
|
38
47
|
const onToggle = useCallback(() => setIsCollapsed(!isCollapsed), [isCollapsed, setIsCollapsed]);
|
|
39
48
|
|
|
@@ -54,6 +63,7 @@ export const CollapsibleSection = ({
|
|
|
54
63
|
}}
|
|
55
64
|
>
|
|
56
65
|
{label}
|
|
66
|
+
{badge}
|
|
57
67
|
{arrow}
|
|
58
68
|
</div>
|
|
59
69
|
);
|
|
@@ -63,7 +73,7 @@ export const CollapsibleSection = ({
|
|
|
63
73
|
return (
|
|
64
74
|
<div>
|
|
65
75
|
{collapsible ? collapsibleHeader : regularHeader}
|
|
66
|
-
{collapsible && isCollapsed ?
|
|
76
|
+
<div style={{display: collapsible && isCollapsed ? "none" : "block"}}>{children}</div>
|
|
67
77
|
</div>
|
|
68
78
|
);
|
|
69
79
|
};
|
|
@@ -29,76 +29,80 @@ const hexInpuWrapperCss = css`
|
|
|
29
29
|
margin-top: ${space.s12}px;
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
|
-
const SliderPicker = ColorWrap(
|
|
33
|
-
|
|
32
|
+
const SliderPicker = ColorWrap(
|
|
33
|
+
({containerClassName, colors, getSwatchHoverColor, getColorOverrideFn = undefined, ...rest}) => {
|
|
34
|
+
const hasSelectedColor = Boolean(rest.color);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
const idxSelectedColor = colors?.findIndex((color) => color.toLowerCase() === rest.hex.toLowerCase());
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
const isCustomSwatchSelected = (idxSelectedColor === -1 && hasSelectedColor) || isExpanded;
|
|
41
|
+
const getColorOverride = getColorOverrideFn || ((color) => color);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
return (
|
|
44
|
+
<CollapsibleRoot open={isCustomSwatchSelected} onOpenChange={setIsExpanded} className={pickerWrapperCss}>
|
|
45
|
+
{colors && (
|
|
46
|
+
<div className={containerClassName}>
|
|
47
|
+
{colors.map((color, idx) => (
|
|
48
|
+
<Swatch
|
|
49
|
+
key={color}
|
|
50
|
+
getHoverColor={getSwatchHoverColor}
|
|
51
|
+
onClick={() => {
|
|
52
|
+
setIsExpanded(false);
|
|
53
|
+
rest.onChange(color);
|
|
54
|
+
}}
|
|
55
|
+
color={getColorOverride(color)}
|
|
56
|
+
selected={!isCustomSwatchSelected && idxSelectedColor === idx}
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
<CollapsibleTrigger asChild>
|
|
60
|
+
<Swatch
|
|
61
|
+
custom
|
|
62
|
+
getHoverColor={getSwatchHoverColor}
|
|
63
|
+
onClick={() => setIsExpanded(!isExpanded)}
|
|
64
|
+
selected={isCustomSwatchSelected}
|
|
65
|
+
color={isCustomSwatchSelected ? rest.hex : undefined}
|
|
66
|
+
/>
|
|
67
|
+
</CollapsibleTrigger>
|
|
68
|
+
</div>
|
|
69
|
+
)}
|
|
70
|
+
|
|
71
|
+
<CollapsibleContent>
|
|
72
|
+
<div className={saturationWrapperCss}>
|
|
73
|
+
<Saturation {...rest} pointer={SliderPointer} />
|
|
74
|
+
</div>
|
|
75
|
+
<div className={hueWrapperCss}>
|
|
76
|
+
<Hue {...rest} pointer={SliderPointer} />
|
|
77
|
+
</div>
|
|
78
|
+
<div className={hexInpuWrapperCss}>
|
|
79
|
+
<EditableInput
|
|
80
|
+
style={{
|
|
81
|
+
input: {
|
|
82
|
+
padding: `${space.s6}px ${space.s12}px`,
|
|
83
|
+
width: "100%",
|
|
84
|
+
border: "none",
|
|
85
|
+
borderRadius: border.radius6,
|
|
86
|
+
backgroundColor: themeVars.actionMenuBg,
|
|
87
|
+
boxShadow: themeVars.inputBorderColor,
|
|
88
|
+
outline: "none",
|
|
89
|
+
...textStyles.regular,
|
|
90
|
+
},
|
|
52
91
|
}}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/>
|
|
56
|
-
))}
|
|
57
|
-
<CollapsibleTrigger asChild>
|
|
58
|
-
<Swatch
|
|
59
|
-
custom
|
|
60
|
-
getHoverColor={getSwatchHoverColor}
|
|
61
|
-
onClick={() => setIsExpanded(!isExpanded)}
|
|
62
|
-
selected={isCustomSwatchSelected}
|
|
63
|
-
color={isCustomSwatchSelected ? rest.hex : undefined}
|
|
92
|
+
value={rest.hex}
|
|
93
|
+
onChange={rest.onChange}
|
|
64
94
|
/>
|
|
65
|
-
</
|
|
66
|
-
</
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<Saturation {...rest} pointer={SliderPointer} />
|
|
72
|
-
</div>
|
|
73
|
-
<div className={hueWrapperCss}>
|
|
74
|
-
<Hue {...rest} pointer={SliderPointer} />
|
|
75
|
-
</div>
|
|
76
|
-
<div className={hexInpuWrapperCss}>
|
|
77
|
-
<EditableInput
|
|
78
|
-
style={{
|
|
79
|
-
input: {
|
|
80
|
-
padding: `${space.s6}px ${space.s12}px`,
|
|
81
|
-
width: "100%",
|
|
82
|
-
border: "none",
|
|
83
|
-
borderRadius: border.radius6,
|
|
84
|
-
backgroundColor: themeVars.actionMenuBg,
|
|
85
|
-
boxShadow: themeVars.inputBorderColor,
|
|
86
|
-
outline: "none",
|
|
87
|
-
...textStyles.regular,
|
|
88
|
-
},
|
|
89
|
-
}}
|
|
90
|
-
value={rest.hex}
|
|
91
|
-
onChange={rest.onChange}
|
|
92
|
-
/>
|
|
93
|
-
</div>
|
|
94
|
-
</CollapsibleContent>
|
|
95
|
-
</CollapsibleRoot>
|
|
96
|
-
);
|
|
97
|
-
});
|
|
95
|
+
</div>
|
|
96
|
+
</CollapsibleContent>
|
|
97
|
+
</CollapsibleRoot>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
);
|
|
98
101
|
|
|
99
102
|
export const ColorPicker = ({
|
|
100
103
|
color,
|
|
101
104
|
getSwatchHoverColor,
|
|
105
|
+
getColorOverrideFn = undefined,
|
|
102
106
|
colors,
|
|
103
107
|
onChangeComplete,
|
|
104
108
|
containerClassName = colorSwatchContainerCss,
|
|
@@ -110,6 +114,7 @@ export const ColorPicker = ({
|
|
|
110
114
|
containerClassName={containerClassName}
|
|
111
115
|
color={optimisticColor}
|
|
112
116
|
getSwatchHoverColor={getSwatchHoverColor}
|
|
117
|
+
getColorOverrideFn={getColorOverrideFn}
|
|
113
118
|
colors={colors}
|
|
114
119
|
onChange={setOptimisticColor}
|
|
115
120
|
onChangeComplete={onChangeComplete}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {css, CSSProperties, cx} from "@linaria/core";
|
|
2
2
|
import {forwardRef} from "react";
|
|
3
3
|
import {IconButton, IconButtonProps} from "../button/icon-button";
|
|
4
4
|
import {themeVars} from "../design-system";
|
|
5
5
|
|
|
6
|
+
const swatchColorVar = "--fibery-swatch-color";
|
|
7
|
+
const swatchHoverColorVar = "--fibery-swatch-hover-color";
|
|
8
|
+
const swatchIconSizeVar = "--fibery-swatch-icon-size";
|
|
9
|
+
|
|
6
10
|
const swatchContainerCss = css`
|
|
7
11
|
&:hover:not(:disabled),
|
|
8
12
|
&:focus-visible {
|
|
9
|
-
background-color: var(
|
|
13
|
+
background-color: var(${swatchHoverColorVar}, ${themeVars.badgeBgColor});
|
|
10
14
|
}
|
|
11
15
|
`;
|
|
12
16
|
|
|
13
17
|
const swatchCss = css`
|
|
14
18
|
position: relative;
|
|
15
19
|
border-radius: 100%;
|
|
16
|
-
width:
|
|
17
|
-
height:
|
|
20
|
+
width: var(${swatchIconSizeVar});
|
|
21
|
+
height: var(${swatchIconSizeVar});
|
|
18
22
|
border: 1px solid ${themeVars.colorPickerSwatchBorder};
|
|
19
|
-
background-color: var(
|
|
23
|
+
background-color: var(${swatchColorVar});
|
|
20
24
|
`;
|
|
21
25
|
|
|
22
26
|
const selectedCss = css`
|
|
@@ -24,8 +28,8 @@ const selectedCss = css`
|
|
|
24
28
|
content: "";
|
|
25
29
|
position: absolute;
|
|
26
30
|
display: block;
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
31
|
+
width: calc(var(${swatchIconSizeVar}) - 4px);
|
|
32
|
+
height: calc(var(${swatchIconSizeVar}) - 4px);
|
|
29
33
|
border-radius: 100%;
|
|
30
34
|
top: 1px;
|
|
31
35
|
left: 1px;
|
|
@@ -51,28 +55,38 @@ const customCss = css`
|
|
|
51
55
|
|
|
52
56
|
&.${selectedCss} {
|
|
53
57
|
&::after {
|
|
54
|
-
background-color: var(
|
|
58
|
+
background-color: var(${swatchColorVar});
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
`;
|
|
58
62
|
|
|
63
|
+
const iconSizes = {
|
|
64
|
+
tiny: 16,
|
|
65
|
+
small: 16,
|
|
66
|
+
medium: 18,
|
|
67
|
+
large: 20,
|
|
68
|
+
huge: 22,
|
|
69
|
+
};
|
|
70
|
+
|
|
59
71
|
type SwatchProps = {
|
|
60
72
|
color: string;
|
|
61
73
|
getHoverColor?: (color: string) => string | undefined;
|
|
62
|
-
selected
|
|
74
|
+
selected?: boolean;
|
|
63
75
|
custom?: boolean;
|
|
64
|
-
} & Omit<IconButtonProps, "
|
|
76
|
+
} & Omit<IconButtonProps, "color">;
|
|
77
|
+
|
|
65
78
|
export const Swatch = forwardRef<HTMLButtonElement, SwatchProps>(
|
|
66
|
-
({color, getHoverColor, selected, custom, className, ...rest}, ref) => {
|
|
79
|
+
({size = "large", color, getHoverColor, selected, custom, className, ...rest}, ref) => {
|
|
67
80
|
return (
|
|
68
81
|
<IconButton
|
|
69
82
|
ref={ref}
|
|
70
|
-
size=
|
|
83
|
+
size={size}
|
|
71
84
|
title={color}
|
|
72
85
|
style={
|
|
73
86
|
{
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
[swatchColorVar]: color,
|
|
88
|
+
[swatchHoverColorVar]: color ? getHoverColor?.(color) : undefined,
|
|
89
|
+
[swatchIconSizeVar]: `${iconSizes[size]}px`,
|
|
76
90
|
} as CSSProperties
|
|
77
91
|
}
|
|
78
92
|
className={cx(swatchContainerCss, className)}
|
|
@@ -20,9 +20,10 @@ export const CommandMenuRoot = styled(CommandRoot)`
|
|
|
20
20
|
|
|
21
21
|
const inputContainerCss = css`
|
|
22
22
|
display: flex;
|
|
23
|
-
padding: ${space.
|
|
23
|
+
padding: ${space.s4}px ${space.s12}px ${space.s8}px;
|
|
24
24
|
align-items: center;
|
|
25
25
|
border-bottom: 1px solid ${themeVars.separatorColor};
|
|
26
|
+
margin-bottom: ${space.s4}px;
|
|
26
27
|
|
|
27
28
|
& input {
|
|
28
29
|
min-width: 120px;
|
|
@@ -84,7 +85,6 @@ export const CommandMenuList = styled(CommandList)`
|
|
|
84
85
|
height: var(--cmdk-list-height);
|
|
85
86
|
max-height: 450px;
|
|
86
87
|
transition: height 100ms ease;
|
|
87
|
-
margin-top: ${space.s4}px;
|
|
88
88
|
`;
|
|
89
89
|
|
|
90
90
|
export const CommandMenuEmpty = styled(CommandEmpty)`
|
|
@@ -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) {
|
|
@@ -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,7 +1,7 @@
|
|
|
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/
|
|
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";
|
|
@@ -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);
|
package/src/date-picker/utils.ts
CHANGED
|
@@ -7,9 +7,16 @@ import {
|
|
|
7
7
|
dateTimeFormat as defaultDateTimeFormat,
|
|
8
8
|
} from "../design-system";
|
|
9
9
|
|
|
10
|
-
|
|
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 (
|
|
19
|
+
if (weirdFormat) {
|
|
13
20
|
return chrono.en;
|
|
14
21
|
}
|
|
15
22
|
// Otherwise, use european-style d/m/y
|