@apify/ui-library 1.127.3 → 1.127.5

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 (46) hide show
  1. package/dist/src/components/checkbox/checkbox.d.ts +18 -0
  2. package/dist/src/components/checkbox/checkbox.d.ts.map +1 -0
  3. package/dist/src/components/checkbox/checkbox.js +30 -0
  4. package/dist/src/components/checkbox/checkbox.js.map +1 -0
  5. package/dist/src/components/checkbox/checkbox.style.d.ts +2 -0
  6. package/dist/src/components/checkbox/checkbox.style.d.ts.map +1 -0
  7. package/dist/src/components/checkbox/checkbox.style.js +61 -0
  8. package/dist/src/components/checkbox/checkbox.style.js.map +1 -0
  9. package/dist/src/components/checkbox/index.d.ts +2 -0
  10. package/dist/src/components/checkbox/index.d.ts.map +1 -0
  11. package/dist/src/components/checkbox/index.js +2 -0
  12. package/dist/src/components/checkbox/index.js.map +1 -0
  13. package/dist/src/components/chip.d.ts +1 -0
  14. package/dist/src/components/chip.d.ts.map +1 -1
  15. package/dist/src/components/chip.js +1 -0
  16. package/dist/src/components/chip.js.map +1 -1
  17. package/dist/src/components/index.d.ts +1 -0
  18. package/dist/src/components/index.d.ts.map +1 -1
  19. package/dist/src/components/index.js +1 -0
  20. package/dist/src/components/index.js.map +1 -1
  21. package/dist/src/components/text/heading_content.d.ts +3 -0
  22. package/dist/src/components/text/heading_content.d.ts.map +1 -1
  23. package/dist/src/components/text/heading_content.js +3 -0
  24. package/dist/src/components/text/heading_content.js.map +1 -1
  25. package/dist/src/components/text/text_content.d.ts +3 -0
  26. package/dist/src/components/text/text_content.d.ts.map +1 -1
  27. package/dist/src/components/text/text_content.js +3 -0
  28. package/dist/src/components/text/text_content.js.map +1 -1
  29. package/dist/src/components/to_consolidate/markdown.d.ts +3 -0
  30. package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -1
  31. package/dist/src/components/to_consolidate/markdown.js +3 -0
  32. package/dist/src/components/to_consolidate/markdown.js.map +1 -1
  33. package/dist/tsconfig.build.tsbuildinfo +1 -1
  34. package/package.json +3 -2
  35. package/src/components/checkbox/checkbox.stories.tsx +57 -0
  36. package/src/components/checkbox/checkbox.style.ts +62 -0
  37. package/src/components/checkbox/checkbox.tsx +89 -0
  38. package/src/components/checkbox/index.ts +1 -0
  39. package/src/components/chip.tsx +1 -0
  40. package/src/components/index.ts +1 -0
  41. package/src/components/text/heading_content.stories.tsx +1 -0
  42. package/src/components/text/heading_content.tsx +3 -0
  43. package/src/components/text/text_content.stories.tsx +1 -0
  44. package/src/components/text/text_content.tsx +3 -0
  45. package/src/components/to_consolidate/markdown.stories.tsx +1 -0
  46. package/src/components/to_consolidate/markdown.tsx +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "1.127.3",
3
+ "version": "1.127.5",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -29,6 +29,7 @@
29
29
  "dependencies": {
30
30
  "@apify/ui-icons": "^1.29.1",
31
31
  "@floating-ui/react": "^0.26.2",
32
+ "@radix-ui/react-checkbox": "^1.3.3",
32
33
  "@react-hook/resize-observer": "^2.0.2",
33
34
  "clsx": "^2.0.0",
34
35
  "dayjs": "1.11.9",
@@ -66,5 +67,5 @@
66
67
  "src",
67
68
  "style"
68
69
  ],
69
- "gitHead": "d5192b5966509f0f334f4b0578bd964e603dfb11"
70
+ "gitHead": "ed1183fd2d33f91e7429ae07b7e2fa6197a051e4"
70
71
  }
@@ -0,0 +1,57 @@
1
+ import { type ComponentProps, useState } from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { CheckboxPrimitive, IndeterminateCheckbox } from './checkbox.js';
5
+
6
+ export default {
7
+ title: 'Components/Inputs/CheckboxPrimitive',
8
+ };
9
+
10
+ const Grid = styled.div`
11
+ margin: 5rem 3rem;
12
+ display: grid;
13
+ grid-template-columns: repeat(1, auto);
14
+ gap: 1.4rem;
15
+ `;
16
+
17
+ const Row = styled.div`
18
+ display: flex;
19
+ align-items: center;
20
+ gap: 0.8rem;
21
+ `;
22
+
23
+ type ControlledCheckboxProps = { initialValue?: boolean } & Omit<ComponentProps<typeof CheckboxPrimitive>, 'value' | 'setValue'>;
24
+
25
+ const ControlledCheckbox = ({ initialValue = false, ...props }: ControlledCheckboxProps) => {
26
+ const [value, setValue] = useState(initialValue);
27
+ return <CheckboxPrimitive value={value} setValue={setValue} {...props} />;
28
+ };
29
+
30
+ export const States = () => (
31
+ <Grid>
32
+ <Row><ControlledCheckbox /> Unchecked</Row>
33
+ <Row><ControlledCheckbox initialValue /> Checked</Row>
34
+ <Row><ControlledCheckbox disabled /> Disabled</Row>
35
+ <Row><ControlledCheckbox initialValue disabled /> Checked & disabled</Row>
36
+ <Row><ControlledCheckbox readOnly initialValue /> Checked & readonly</Row>
37
+ <Row><ControlledCheckbox error="Some error" /> Error</Row>
38
+ <Row><ControlledCheckbox initialValue error="Some error" /> Checked + error</Row>
39
+ </Grid>
40
+ );
41
+
42
+ const getIndeterminateLabel = (value: boolean | null) => {
43
+ if (value === null) return 'Indeterminate';
44
+ return value ? 'Checked' : 'Unchecked';
45
+ };
46
+
47
+ export const Indeterminate = () => {
48
+ const [value, setValue] = useState<boolean | null>(null);
49
+ return (
50
+ <Grid>
51
+ <Row>
52
+ <IndeterminateCheckbox value={value} setValue={setValue} />
53
+ {getIndeterminateLabel(value)} (click to toggle)
54
+ </Row>
55
+ </Grid>
56
+ );
57
+ };
@@ -0,0 +1,62 @@
1
+ import { css } from 'styled-components';
2
+
3
+ import { theme } from '../../design_system/theme.js';
4
+
5
+ export const checkboxStyle = css`
6
+ overflow: hidden;
7
+ border: 1px solid ${theme.color.neutral.border};
8
+ border-radius: ${theme.radius.radius4};
9
+ background-color: ${theme.color.neutral.background};
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ width: 16px;
14
+ height: 16px;
15
+ position: relative;
16
+ box-sizing: border-box;
17
+ transition: border-color 120ms ease-out, background-color 120ms ease-out !important;
18
+
19
+ &:hover, &:focus {
20
+ border-color: ${theme.color.primary.action};
21
+ cursor: pointer;
22
+ }
23
+
24
+ &.disabled {
25
+ background-color: ${theme.color.neutral.textDisabled};
26
+ border-color: ${theme.color.neutral.border};
27
+ }
28
+
29
+ &.error {
30
+ border-color: ${theme.color.danger.text};
31
+ }
32
+
33
+ &.indeterminate {
34
+ background-color: ${theme.color.primary.action};
35
+ border-color: ${theme.color.primary.action};
36
+ }
37
+
38
+ &[data-state="checked"] {
39
+ background-color: ${theme.color.primary.action};
40
+ border-color: ${theme.color.primary.action};
41
+
42
+ &:hover {
43
+ background-color: ${theme.color.primary.actionHover};
44
+ border-color: ${theme.color.primary.actionHover};
45
+ }
46
+
47
+ &.error {
48
+ background-color: ${theme.color.danger.action};
49
+ border-color: ${theme.color.danger.action};
50
+
51
+ &:hover {
52
+ background-color: ${theme.color.danger.actionHover};
53
+ border-color: ${theme.color.danger.actionHover};
54
+ }
55
+ }
56
+
57
+ &.disabled {
58
+ background-color: ${theme.color.neutral.textDisabled};
59
+ border-color: ${theme.color.neutral.border};
60
+ }
61
+ }
62
+ `;
@@ -0,0 +1,89 @@
1
+ import * as CheckboxPrimitiveReact from '@radix-ui/react-checkbox';
2
+ import clsx from 'clsx';
3
+ import { type ComponentPropsWithoutRef, type FC } from 'react';
4
+ import styled from 'styled-components';
5
+
6
+ import {
7
+ CheckIcon, MinusIcon,
8
+ } from '@apify/ui-icons';
9
+
10
+ import { theme } from '../../design_system/theme.js';
11
+ import { checkboxStyle } from './checkbox.style.js';
12
+
13
+ const StyledCheckbox = styled(CheckboxPrimitiveReact.Root)`
14
+ all: unset;
15
+ ${checkboxStyle};
16
+ `;
17
+
18
+ const StyledIndicator = styled(CheckboxPrimitiveReact.Indicator)`
19
+ color: ${theme.color.neutral.textOnPrimary};
20
+ position: absolute;
21
+ display: flex;
22
+ justify-content: center;
23
+ align-items: center;
24
+
25
+ .disabled & {
26
+ color: ${theme.color.neutral.textMuted};
27
+ }
28
+ `;
29
+
30
+ const IndeterminateIndicator = styled(StyledIndicator)`
31
+ color: ${theme.color.neutral.textOnPrimary};
32
+ `;
33
+
34
+ type CheckboxBaseProps = Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitiveReact.Root>, 'checked' | 'onCheckedChange' | 'value'> & {
35
+ setValue: (checked: boolean) => void;
36
+ error?: string;
37
+ disabled?: boolean;
38
+ readOnly?: boolean;
39
+ };
40
+
41
+ export type CheckboxPrimitiveProps = CheckboxBaseProps & { value: boolean };
42
+ export type IndeterminateCheckboxProps = CheckboxBaseProps & { value: boolean | null };
43
+
44
+ const InternalCheckbox: FC<IndeterminateCheckboxProps> = ({
45
+ children,
46
+ value,
47
+ setValue,
48
+ error,
49
+ disabled,
50
+ readOnly,
51
+ className,
52
+ ...rest
53
+ }) => (
54
+ <StyledCheckbox
55
+ {...rest}
56
+ checked={value == null ? 'indeterminate' : value}
57
+ onCheckedChange={setValue}
58
+ disabled={disabled || readOnly}
59
+ className={clsx(
60
+ className,
61
+ error && 'error',
62
+ (disabled || readOnly) && 'disabled',
63
+ )}
64
+ >
65
+ {children}
66
+ </StyledCheckbox>
67
+ );
68
+
69
+ export const CheckboxPrimitive: FC<CheckboxPrimitiveProps> = (props) => (
70
+ <InternalCheckbox {...props}>
71
+ <StyledIndicator>
72
+ <CheckIcon size="12" />
73
+ </StyledIndicator>
74
+ </InternalCheckbox>
75
+ );
76
+
77
+ export const IndeterminateCheckbox: FC<IndeterminateCheckboxProps> = (props) => (
78
+ <InternalCheckbox {...props} className="indeterminate">
79
+ {props.value == null ? (
80
+ <IndeterminateIndicator>
81
+ <MinusIcon size="12" />
82
+ </IndeterminateIndicator>
83
+ ) : (
84
+ <StyledIndicator>
85
+ <CheckIcon size="12" />
86
+ </StyledIndicator>
87
+ )}
88
+ </InternalCheckbox>
89
+ );
@@ -0,0 +1 @@
1
+ export * from './checkbox.js';
@@ -104,6 +104,7 @@ export type ChipProps = RegularBoxProps & {
104
104
 
105
105
  /**
106
106
  * Component for displaying status and for labelling other components.
107
+ * @deprecated Use Tag or Badge
107
108
  */
108
109
  export const Chip = forwardRef(({
109
110
  type = CHIP_TYPES.DEFAULT,
@@ -26,3 +26,4 @@ export * from './shortcut.js';
26
26
  export * from './icon_button.js';
27
27
  export * from './spinner.js';
28
28
  export * from './store/index.js';
29
+ export * from './checkbox/index.js';
@@ -6,6 +6,7 @@ import { HeadingContent, type HeadingContentProps } from './heading_content.js';
6
6
  export default {
7
7
  title: 'Design Tokens/Typography/HeadingContent',
8
8
  component: HeadingContent,
9
+ tags: ['deprecated'],
9
10
  parameters: {
10
11
  docs: {
11
12
  description: {
@@ -40,6 +40,9 @@ const StyledHeadingContent = styled(TextBaseComponent)<StyledHeadingContentProps
40
40
  ${(props) => getContentHeadingStyles(props.$type || 'heading1')}
41
41
  `;
42
42
 
43
+ /**
44
+ * @deprecated Use Heading or HeadingMarketing from ui-library
45
+ */
43
46
  export const HeadingContent: React.FC<HeadingContentProps> = ({
44
47
  type,
45
48
  as,
@@ -6,6 +6,7 @@ import { type ContentTextProps, TextContent } from './text_content.js';
6
6
  export default {
7
7
  title: 'Design Tokens/Typography/TextContent',
8
8
  component: TextContent,
9
+ tags: ['deprecated'],
9
10
  parameters: {
10
11
  docs: {
11
12
  description: {
@@ -79,6 +79,9 @@ const StyledTextContent = styled(TextBaseComponent)<StyledContentTextProps>`
79
79
  ${(props) => TEXT_SHARED_VARIANTS_CSS[props.$type || 'paragraph'][props.$weight || 'normal']}
80
80
  `;
81
81
 
82
+ /**
83
+ * @deprecated Use Text or TextMarketing from ui-library
84
+ */
82
85
  export const TextContent = forwardRef<HTMLElement | undefined, ContentTextProps>(({
83
86
  type,
84
87
  weight,
@@ -5,6 +5,7 @@ import { Markdown, type MarkdownProps } from './markdown.js';
5
5
  export default {
6
6
  title: 'UI-Library/Markdown/Markdown',
7
7
  component: Markdown,
8
+ tags: ['deprecated'],
8
9
  argTypes: {
9
10
  markdown: {
10
11
  control: 'text',
@@ -642,4 +642,7 @@ const Markdown = ({
642
642
  };
643
643
 
644
644
  const MemoizedMarkdown = React.memo(Markdown, (prevProps, nextProps) => _.isEqual(prevProps, nextProps));
645
+ /**
646
+ * @deprecated Use SimpleMarkdown from ui-library
647
+ */
645
648
  export { MemoizedMarkdown as Markdown };