@apify/ui-library 0.71.1-featcolortokens-178953.56 → 0.71.1-featcolortokens-178953.63

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 (134) hide show
  1. package/dist/src/design_system/colors/generated/{dark.d.ts → css_variables.dark.d.ts} +1 -1
  2. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +1 -0
  3. package/dist/src/design_system/colors/generated/{dark.js → css_variables.dark.js} +1 -1
  4. package/dist/src/design_system/colors/generated/css_variables.dark.js.map +1 -0
  5. package/dist/src/design_system/colors/generated/{light.d.ts → css_variables.light.d.ts} +1 -1
  6. package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +1 -0
  7. package/{src/design_system/colors/generated/light.ts → dist/src/design_system/colors/generated/css_variables.light.js} +1 -1
  8. package/dist/src/design_system/colors/generated/css_variables.light.js.map +1 -0
  9. package/dist/src/design_system/colors/generated/{palette.dark.d.ts → css_variables_palette.dark.d.ts} +1 -1
  10. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +1 -0
  11. package/dist/src/design_system/colors/generated/{palette.dark.js → css_variables_palette.dark.js} +1 -1
  12. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +1 -0
  13. package/dist/src/design_system/colors/generated/{palette.light.d.ts → css_variables_palette.light.d.ts} +1 -1
  14. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +1 -0
  15. package/{src/design_system/colors/generated/palette.light.ts → dist/src/design_system/colors/generated/css_variables_palette.light.js} +1 -1
  16. package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +1 -0
  17. package/dist/src/design_system/colors/index.d.ts +4 -4
  18. package/dist/src/design_system/colors/index.d.ts.map +1 -1
  19. package/dist/src/design_system/colors/index.js +4 -4
  20. package/dist/src/design_system/colors/index.js.map +1 -1
  21. package/dist/tsconfig.build.tsbuildinfo +1 -0
  22. package/package.json +7 -5
  23. package/.stylelintrc +0 -12
  24. package/CHANGELOG.md +0 -3334
  25. package/CODEOWNERS +0 -7
  26. package/dist/src/design_system/colors/generated/dark.d.ts.map +0 -1
  27. package/dist/src/design_system/colors/generated/dark.js.map +0 -1
  28. package/dist/src/design_system/colors/generated/light.d.ts.map +0 -1
  29. package/dist/src/design_system/colors/generated/light.js +0 -147
  30. package/dist/src/design_system/colors/generated/light.js.map +0 -1
  31. package/dist/src/design_system/colors/generated/palette.dark.d.ts.map +0 -1
  32. package/dist/src/design_system/colors/generated/palette.dark.js.map +0 -1
  33. package/dist/src/design_system/colors/generated/palette.light.d.ts.map +0 -1
  34. package/dist/src/design_system/colors/generated/palette.light.js +0 -74
  35. package/dist/src/design_system/colors/generated/palette.light.js.map +0 -1
  36. package/dist/src/design_system/colors_theme.d.ts +0 -213
  37. package/dist/src/design_system/colors_theme.d.ts.map +0 -1
  38. package/dist/src/design_system/colors_theme.js +0 -213
  39. package/dist/src/design_system/colors_theme.js.map +0 -1
  40. package/dist/src/design_system/properties_theme.d.ts +0 -175
  41. package/dist/src/design_system/properties_theme.d.ts.map +0 -1
  42. package/dist/src/design_system/properties_theme.js +0 -315
  43. package/dist/src/design_system/properties_theme.js.map +0 -1
  44. package/eslint.config.mjs +0 -44
  45. package/src/codemods/generate_typograpy_tokens_files.mjs +0 -137
  46. package/src/components/action_link.tsx +0 -60
  47. package/src/components/actor_template_card.tsx +0 -116
  48. package/src/components/badge.tsx +0 -148
  49. package/src/components/banner.tsx +0 -94
  50. package/src/components/blog_article.tsx +0 -85
  51. package/src/components/box.tsx +0 -127
  52. package/src/components/button.tsx +0 -305
  53. package/src/components/chip.tsx +0 -128
  54. package/src/components/code/action_button.tsx +0 -96
  55. package/src/components/code/code_block/code_block.styled.tsx +0 -180
  56. package/src/components/code/code_block/code_block.tsx +0 -224
  57. package/src/components/code/code_block/code_block_with_tabs.tsx +0 -257
  58. package/src/components/code/code_block/utils.tsx +0 -67
  59. package/src/components/code/index.ts +0 -5
  60. package/src/components/code/inline_code/inline_code.tsx +0 -62
  61. package/src/components/code/one_line_code/one_line_code.tsx +0 -228
  62. package/src/components/code/prism_highlighter.tsx +0 -180
  63. package/src/components/color_wheel_gradient.tsx +0 -31
  64. package/src/components/floating/index.ts +0 -3
  65. package/src/components/floating/menu.tsx +0 -189
  66. package/src/components/floating/menu_common.tsx +0 -31
  67. package/src/components/floating/menu_components.tsx +0 -99
  68. package/src/components/image.tsx +0 -24
  69. package/src/components/index.ts +0 -22
  70. package/src/components/link.tsx +0 -114
  71. package/src/components/message.tsx +0 -153
  72. package/src/components/rating.tsx +0 -106
  73. package/src/components/readme_renderer/index.ts +0 -3
  74. package/src/components/readme_renderer/pythonize_value.ts +0 -76
  75. package/src/components/readme_renderer/table_of_contents.tsx +0 -272
  76. package/src/components/readme_renderer/utils.tsx +0 -46
  77. package/src/components/simple_markdown/index.ts +0 -2
  78. package/src/components/simple_markdown/simple_markdown.tsx +0 -214
  79. package/src/components/simple_markdown/simple_markdown_components.tsx +0 -293
  80. package/src/components/tabs/index.ts +0 -2
  81. package/src/components/tabs/tab.tsx +0 -217
  82. package/src/components/tabs/tabs.tsx +0 -169
  83. package/src/components/tag.tsx +0 -196
  84. package/src/components/text/heading_content.tsx +0 -56
  85. package/src/components/text/heading_marketing.tsx +0 -55
  86. package/src/components/text/heading_shared.tsx +0 -55
  87. package/src/components/text/index.ts +0 -19
  88. package/src/components/text/text_base.tsx +0 -52
  89. package/src/components/text/text_content.tsx +0 -104
  90. package/src/components/text/text_marketing.tsx +0 -152
  91. package/src/components/text/text_shared.tsx +0 -95
  92. package/src/components/tile/horizontal_tile.tsx +0 -77
  93. package/src/components/tile/index.ts +0 -2
  94. package/src/components/tile/shared.ts +0 -27
  95. package/src/components/tile/vertical_tile.tsx +0 -59
  96. package/src/components/to_consolidate/card.tsx +0 -141
  97. package/src/components/to_consolidate/index.ts +0 -4
  98. package/src/components/to_consolidate/markdown.tsx +0 -609
  99. package/src/components/to_consolidate/pagination.tsx +0 -136
  100. package/src/components/to_consolidate/tab_number_chip.tsx +0 -31
  101. package/src/design_system/colors/build_color_tokens.js +0 -175
  102. package/src/design_system/colors/figma_color_tokens.dark.json +0 -886
  103. package/src/design_system/colors/figma_color_tokens.light.json +0 -886
  104. package/src/design_system/colors/generated/colors_theme.dark.ts +0 -110
  105. package/src/design_system/colors/generated/colors_theme.light.ts +0 -110
  106. package/src/design_system/colors/generated/dark.ts +0 -147
  107. package/src/design_system/colors/generated/palette.dark.ts +0 -74
  108. package/src/design_system/colors/generated/properties_theme.ts +0 -179
  109. package/src/design_system/colors/index.ts +0 -7
  110. package/src/design_system/colors_theme.ts +0 -213
  111. package/src/design_system/properties_theme.ts +0 -453
  112. package/src/design_system/supernova_typography_tokens.json +0 -657
  113. package/src/design_system/theme.ts +0 -25
  114. package/src/design_system/tokens/index.ts +0 -5
  115. package/src/design_system/tokens/layouts.ts +0 -29
  116. package/src/design_system/tokens/radiuses.ts +0 -22
  117. package/src/design_system/tokens/shadows.ts +0 -22
  118. package/src/design_system/tokens/spaces.ts +0 -15
  119. package/src/design_system/tokens/transitions.ts +0 -19
  120. package/src/design_system/typography_theme.ts +0 -197
  121. package/src/index.ts +0 -8
  122. package/src/type_utils.ts +0 -7
  123. package/src/ui_dependency_provider.tsx +0 -58
  124. package/src/utils/copy_to_clipboard.ts +0 -24
  125. package/src/utils/image_color.ts +0 -42
  126. package/src/utils/index.ts +0 -4
  127. package/src/utils/resize_observer.ts +0 -18
  128. package/src/utils/sanitization.ts +0 -14
  129. package/tsconfig.build.json +0 -17
  130. package/tsconfig.json +0 -10
  131. /package/{src/design_system/colors/generated → style/colors}/dark.scss +0 -0
  132. /package/{src/design_system/colors/generated → style/colors}/light.scss +0 -0
  133. /package/{src/design_system/colors/generated → style/colors}/palette.dark.scss +0 -0
  134. /package/{src/design_system/colors/generated → style/colors}/palette.light.scss +0 -0
@@ -1,228 +0,0 @@
1
- import { useMemo, useState } from 'react';
2
- import styled, { css } from 'styled-components';
3
-
4
- import { EyeIcon, EyeOffIcon } from '@apify/ui-icons';
5
-
6
- import { theme } from '../../../design_system/theme.js';
7
- import type { BoxProps } from '../../box.js';
8
- import { Text } from '../../text/index.js';
9
- import type { SharedTextSize } from '../../text/text_shared.js';
10
- import { ActionButton, CopyButton } from '../action_button.js';
11
- import type { SyntaxHighlighterBaseStylesWrapperProps } from '../code_block/code_block.styled.js';
12
- import { SyntaxHighlighterBaseStylesWrapper } from '../code_block/code_block.styled.js';
13
- import { getBashLinePrefixes } from '../code_block/utils.js';
14
- import { PrismSyntaxHighlighter } from '../prism_highlighter.js';
15
-
16
- export const oneLineCodeClassNames = {
17
- gradientWrapper: 'OneLineCode-GradientWrapper',
18
- scrollableWrapper: 'OneLineCode-ScrollableWrapper',
19
- methodChip: 'OneLineCode-MethodChip',
20
- gradient: 'OneLineCode-Gradient',
21
- buttons: 'OneLineCode-Buttons',
22
- };
23
-
24
- type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH';
25
- type ThemeType = keyof Pick<
26
- (typeof theme)['color'],
27
- 'primary' | 'success' | 'warning' | 'danger' | 'neutral'
28
- >;
29
-
30
- const HTML_METHOD_CHIP_STYLES: Record<HttpMethod, ThemeType> = {
31
- GET: 'primary',
32
- POST: 'success',
33
- PUT: 'warning',
34
- DELETE: 'danger',
35
- HEAD: 'neutral',
36
- PATCH: 'neutral',
37
- };
38
-
39
- function getChipStyles(httpMethod: HttpMethod) {
40
- const styles = theme.color[HTML_METHOD_CHIP_STYLES[httpMethod]];
41
- return css`
42
- background-color: ${styles.chipBackground};
43
- color: ${'chipText' in styles ? styles.chipText : styles.text};
44
- `;
45
- }
46
-
47
- type OneLineCodeWrapperProps = SyntaxHighlighterBaseStylesWrapperProps & {
48
- $httpMethod?: HttpMethod;
49
- $fitContent?: boolean;
50
- $showBashPrefixes?: boolean;
51
- $disabled?: boolean;
52
- }
53
-
54
- const OneLineCodeWrapper = styled(SyntaxHighlighterBaseStylesWrapper)<OneLineCodeWrapperProps>`
55
- display: flex;
56
- padding-right: ${theme.space.space16} !important;
57
- ${({ $fitContent }) => $fitContent && css`
58
- width: fit-content;
59
- `}
60
-
61
- ${({ $disabled }) => $disabled && css`
62
- opacity: 0.5;
63
- cursor: not-allowed;
64
- `}
65
-
66
- height: 4.6rem;
67
-
68
- .${oneLineCodeClassNames.buttons} {
69
- display: flex;
70
- align-items: center;
71
- gap: ${theme.space.space8};
72
- }
73
-
74
- .${oneLineCodeClassNames.methodChip} {
75
- padding: 0 ${theme.space.space4};
76
- border-radius: ${theme.radius.radius6};
77
- height: 2.4rem;
78
- ${({ $httpMethod }) => $httpMethod && getChipStyles($httpMethod)}
79
- display: flex;
80
- align-items: center;
81
- }
82
-
83
- .${oneLineCodeClassNames.gradientWrapper} {
84
- position: relative;
85
- flex: 1;
86
- min-width: 0;
87
- display: flex;
88
-
89
- .${oneLineCodeClassNames.gradient} {
90
- position: absolute;
91
- right: 0;
92
- top: 0;
93
- bottom: 0;
94
- width: 4rem;
95
- z-index: 5;
96
- background: linear-gradient(
97
- to right,
98
- transparent,
99
- ${theme.color.neutral.backgroundMuted} 3rem
100
- );
101
- }
102
- }
103
-
104
- .${oneLineCodeClassNames.scrollableWrapper} {
105
- flex: 1;
106
- overflow-x: auto;
107
- overflow-y: hidden;
108
- display: flex;
109
- align-items: center;
110
- gap: ${theme.space.space16};
111
- padding: 0 ${theme.space.space8} !important;
112
- margin-left: ${theme.space.space8} !important;
113
- height: 100%;
114
-
115
- scrollbar-width: thin;
116
- scrollbar-color: ${theme.color.neutral.border} transparent;
117
-
118
-
119
- pre {
120
- display: flex;
121
- flex: 1;
122
- align-items: center;
123
- height: 100%;
124
-
125
- code {
126
- height: 100%;
127
- display: flex;
128
- align-items: center;
129
-
130
- & > div {
131
- padding-right: ${theme.space.space16};
132
- }
133
- }
134
- }
135
- }
136
- `;
137
-
138
- export type OneLineCodeProps = BoxProps & {
139
- children: string;
140
- language?: string;
141
- size?: SharedTextSize;
142
- httpMethod?: HttpMethod;
143
- actionButtonLabel?: string;
144
- onActionButtonClick?: () => Promise<void> | void;
145
- fullWidth?: boolean;
146
- secretPlaceholder?: string;
147
- secret?: string;
148
- disabled?: boolean;
149
- hideCopyButton?: boolean;
150
- }
151
-
152
- export function OneLineCode({
153
- children,
154
- language,
155
- size,
156
- httpMethod,
157
- actionButtonLabel,
158
- onActionButtonClick,
159
- fullWidth,
160
- secretPlaceholder = '***',
161
- secret,
162
- disabled,
163
- hideCopyButton,
164
- ...rest
165
- }: OneLineCodeProps) {
166
- const hasSecret = secret !== undefined;
167
- const [showSecret, setShowSecret] = useState(false);
168
- const codeWithSecret = useMemo(() => {
169
- if (!hasSecret) return children;
170
- return children.replace(secretPlaceholder, secret);
171
- }, [children, secret, hasSecret, secretPlaceholder]);
172
- const code = showSecret ? codeWithSecret : children;
173
-
174
- const showBashPrefixes = language === 'bash';
175
-
176
- const linePrefixes = useMemo(
177
- () => (showBashPrefixes ? getBashLinePrefixes(code, [1], true) : {}),
178
- [showBashPrefixes, code],
179
- );
180
-
181
- return (
182
- <OneLineCodeWrapper
183
- $httpMethod={httpMethod}
184
- $fullWidth={fullWidth}
185
- $showBashPrefixes={showBashPrefixes}
186
- $disabled={disabled}
187
- {...rest}
188
- >
189
- <div className={oneLineCodeClassNames.gradientWrapper}>
190
- <div className={oneLineCodeClassNames.scrollableWrapper}>
191
- {httpMethod && (
192
- <Text className={oneLineCodeClassNames.methodChip} as='div'>
193
- {httpMethod}
194
- </Text>
195
- )}
196
- <PrismSyntaxHighlighter
197
- language={language}
198
- size={size}
199
- linePrefixes={linePrefixes}
200
- code={code}
201
- isSingleLine={true}
202
- />
203
- </div>
204
- <div className={oneLineCodeClassNames.gradient} />
205
- </div>
206
- <div className={oneLineCodeClassNames.buttons}>
207
- {hasSecret && (
208
- <ActionButton
209
- onClick={() => setShowSecret((prev) => !prev)}
210
- data-test='toggle-visibility-button'
211
- >
212
- {showSecret ? (
213
- <EyeOffIcon size="16" />
214
- ) : (
215
- <EyeIcon size="16" />
216
- )}
217
- </ActionButton>
218
- )}
219
- {!hideCopyButton && <CopyButton code={codeWithSecret} />}
220
- {!!onActionButtonClick && (
221
- <ActionButton onClick={onActionButtonClick}>
222
- {actionButtonLabel}
223
- </ActionButton>
224
- )}
225
- </div>
226
- </OneLineCodeWrapper >
227
- );
228
- }
@@ -1,180 +0,0 @@
1
- import clsx from 'clsx';
2
- import _ from 'lodash';
3
- import type { HighlightProps } from 'prism-react-renderer';
4
- import { Highlight, Prism, themes } from 'prism-react-renderer';
5
- import type { ReactNode } from 'react';
6
- import { forwardRef, useRef } from 'react';
7
- import styled, { css } from 'styled-components';
8
-
9
- import { theme } from '../../design_system/theme.js';
10
- import { useSharedUiDependencies } from '../../ui_dependency_provider.js';
11
- import { Text } from '../text/index.js';
12
- import type { SharedTextSize } from '../text/text_shared.js';
13
-
14
- (typeof global !== 'undefined' ? global : window).Prism = Prism;
15
-
16
- const HIGHLIGHT_BACKGROUND_COLOR = 'rgba(22, 114, 235, 0.05)';
17
-
18
- const loadLanguages = async () => {
19
- await Promise.all([
20
- // @ts-expect-error The library is badly typed and does not export the type
21
- import('prismjs/components/prism-bash.js'),
22
- // @ts-expect-error The library is badly typed and does not export the type
23
- import('prismjs/components/prism-rust.js'),
24
- // @ts-expect-error The library is badly typed and does not export the type
25
- import('prismjs/components/prism-bash.js'),
26
- // @ts-expect-error The library is badly typed and does not export the type
27
- import('prismjs/components/prism-docker.js'),
28
- // @ts-expect-error The library is badly typed and does not export the type
29
- import('prismjs/components/prism-http.js'),
30
- // @ts-expect-error The library is badly typed and does not export the type
31
- import('prismjs/components/prism-javascript.js'),
32
- // @ts-expect-error The library is badly typed and does not export the type
33
- import('prismjs/components/prism-json.js'),
34
- // @ts-expect-error The library is badly typed and does not export the type
35
- import('prismjs/components/prism-markup.js'),
36
- // @ts-expect-error The library is badly typed and does not export the type
37
- import('prismjs/components/prism-python.js'),
38
- // @ts-expect-error The library is badly typed and does not export the type
39
- import('prismjs/components/prism-typescript.js'),
40
- // @ts-expect-error The library is badly typed and does not export the type
41
- import('prismjs/components/prism-xml-doc.js'),
42
- // @ts-expect-error The library is badly typed and does not export the type
43
- import('prismjs/components/prism-yaml.js'),
44
- ]);
45
- };
46
-
47
- void loadLanguages();
48
-
49
- type StyledPreProps = {
50
- $hasLinePrefixes: boolean,
51
- $isSingleLine: boolean
52
- };
53
-
54
- const StyledPre = styled.pre<StyledPreProps>`
55
- width: 100%;
56
- position: relative;
57
- overflow: auto;
58
- z-index: 2;
59
- padding: ${({ $isSingleLine }) => ($isSingleLine ? 0 : `${theme.space.space16} 0`)};
60
- margin: 0;
61
-
62
- code {
63
- min-width: 100%;
64
- display: inline-block;
65
- vertical-align: middle;
66
-
67
- *,
68
- *::before,
69
- *::after {
70
- text-shadow: none !important;
71
- font-style: normal !important;
72
- font-family: inherit !important;
73
- font-size: inherit !important;
74
- font-weight: inherit !important;
75
- line-height: inherit !important;
76
- background-color: transparent !important;
77
- }
78
-
79
- & > div {
80
- display: block;
81
-
82
- &.highlighted {
83
- background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
84
- border-left: 6px solid ${theme.color.neutral.border} !important;
85
- padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
86
- }
87
-
88
- ${({ $isSingleLine }) => !$isSingleLine && css<{$hasLinePrefixes: boolean}>`
89
- &:hover {
90
- background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
91
- border-left: 6px solid ${theme.color.neutral.border} !important;
92
- padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
93
- }
94
- `}
95
-
96
- ${({ $isSingleLine }) => ($isSingleLine ? css<StyledPreProps>`
97
- white-space: nowrap;
98
- vertical-align: text-top;
99
- ` : css<StyledPreProps>`
100
- padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? theme.space.space8 : theme.space.space16)};
101
- padding-right: ${theme.space.space16};
102
-
103
- &:hover {
104
- background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
105
- border-left: 6px solid ${theme.color.neutral.border} !important;
106
- padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
107
- }
108
- `)}
109
- }
110
- }
111
- `;
112
-
113
- export const CodeHighlighterLinePrefix = styled(Text).attrs({ as: 'span' })`
114
- display: inline-block;
115
- margin-right: ${theme.space.space16};
116
- text-align: right;
117
- min-width: ${theme.space.space24};
118
- color: ${({ color }) => color || theme.color.neutral.textSubtle};
119
- user-select: none;
120
- -webkit-user-select: none;
121
- `;
122
-
123
- export const CodeHighlighterLineBashPrefix = styled(CodeHighlighterLinePrefix)<{ $isOneLine?: boolean }>`
124
- min-width: ${({ $isOneLine }) => ($isOneLine ? 'unset' : theme.space.space16)} !important;
125
- `;
126
-
127
- type SyntaxHighlighterProps = Omit<HighlightProps, 'children' | 'language'> & {
128
- size?: SharedTextSize,
129
- linePrefixes?: Record<string, ReactNode>,
130
- highlightLines?: number[],
131
- language?: string,
132
- className?: string,
133
- isSingleLine: boolean,
134
- };
135
-
136
- export const PrismSyntaxHighlighter = forwardRef<HTMLPreElement, SyntaxHighlighterProps>(({
137
- size = 'regular',
138
- linePrefixes = {},
139
- highlightLines = [],
140
- language = 'javascript',
141
- className,
142
- isSingleLine,
143
- ...rest
144
- }, ref) => {
145
- const { uiTheme } = useSharedUiDependencies();
146
- const hasLinePrefixes = !_.isEmpty(linePrefixes);
147
- const highlightedLinesObject = useRef<Record<number, boolean>>(Object.fromEntries(highlightLines.map((e) => [e, true])));
148
-
149
- return (
150
- <Highlight
151
- theme={uiTheme === 'DARK' ? themes.nightOwl : themes.oneLight}
152
- language={language}
153
- {...rest}
154
- >
155
- {({ className: prismClassName, tokens, getLineProps, getTokenProps }) => (
156
- <StyledPre
157
- className={clsx(className, prismClassName)}
158
- $hasLinePrefixes={hasLinePrefixes}
159
- $isSingleLine={isSingleLine}
160
- ref={ref}
161
- >
162
- <Text
163
- size={size}
164
- type='code'
165
- as='code'
166
- >
167
- {tokens.map((line, i) => (
168
- <div key={i} {...getLineProps({ line, className: highlightedLinesObject.current[i + 1] ? 'highlighted' : '' })}>
169
- {hasLinePrefixes && (linePrefixes[i + 1] || <CodeHighlighterLinePrefix />)}
170
- {line.map((token, key) => (
171
- <span key={key} {...getTokenProps({ token })} />
172
- ))}
173
- </div>
174
- ))}
175
- </Text>
176
- </StyledPre>
177
- )}
178
- </Highlight>
179
- );
180
- });
@@ -1,31 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- export interface ColorWheelGradientProps {
4
- translateX?: number,
5
- translateY?: number,
6
- rotation?: number,
7
- radius?: number,
8
- blurSize?: number,
9
- }
10
-
11
- export const ColorWheelGradient = styled.div<ColorWheelGradientProps>`${({ radius, rotation = 0, blurSize = 40, translateX = 0, translateY = 0 }) => `
12
- z-index: 1;
13
- position: absolute;
14
- width: ${radius ? `${radius}px` : 'auto'};
15
- height: ${radius ? `${radius}px` : 'auto'};
16
- transform-origin: center;
17
- transform: translate(${translateX}px, ${translateY}px) rotate(${rotation}deg);
18
-
19
- opacity: 0.30;
20
- background: conic-gradient(
21
- rgba(93, 133, 225, 0.99) 0deg,
22
- rgba(106, 20, 222, 0.99) 69deg,
23
- rgba(228, 68, 103, 0.99) 150deg,
24
- rgba(250, 129, 54, 0.99) 221deg,
25
- rgba(240, 178, 27, 0.99) 287deg,
26
- rgba(18, 150, 111, 0.99) 360deg
27
- );
28
-
29
- border-radius: 50%;
30
- filter: blur(${blurSize}px)
31
- `}`;
@@ -1,3 +0,0 @@
1
- export * from './menu.js';
2
- export * from './menu_components.js';
3
- export * from './menu_common.js';
@@ -1,189 +0,0 @@
1
- import {
2
- FloatingFocusManager,
3
- FloatingPortal,
4
- useClick,
5
- useDismiss,
6
- useInteractions,
7
- useListNavigation,
8
- useRole,
9
- useTypeahead,
10
- } from '@floating-ui/react';
11
- import clsx from 'clsx';
12
- import React, {
13
- useMemo,
14
- useRef,
15
- useState,
16
- } from 'react';
17
-
18
- import {
19
- Box,
20
- type BoxProps,
21
- } from '../box.js';
22
- import { Text } from '../text/index.js';
23
- import { useFloatingMenu } from './menu_common.js';
24
- import {
25
- DropdownMenuBaseComponent,
26
- ListMenuComponent,
27
- ListMenuItemComponent,
28
- } from './menu_components.js';
29
-
30
- export const menuClassNames = {
31
- WRAPPER: 'menu-wrapper',
32
- BASE: 'menu-base',
33
- LIST: 'menu-list',
34
- ITEM: 'menu-item',
35
- };
36
-
37
- type SelectActionType = 'click' | 'enter' | 'space' | 'type';
38
-
39
- // It might be tempting to define label as ReactNode, but we need to have the string value for keyboard navigation
40
- // More difficult cases can be handled using renderOption prop
41
- export interface MenuOption {
42
- label: string,
43
- value: string,
44
- }
45
-
46
- export interface MenuProps<T = MenuOption> {
47
- options: T[],
48
- value?: string,
49
- onSelect: (newValue: string, selectedBy: SelectActionType) => void,
50
- defaultLabel?: React.ReactNode,
51
- closeOnSelect?: boolean,
52
- renderOption?: (option: T) => React.ReactNode,
53
- components?: {
54
- MenuBase?: React.ElementType,
55
- Menu?: React.ElementType,
56
- MenuItem?: React.ElementType,
57
- },
58
- }
59
-
60
- const defaultRenderOption = ({ label }: MenuOption) => (<Text as='span'>{label}</Text>);
61
-
62
- /**
63
- * This example is a Select taken from https://floating-ui.com/docs/react-examples
64
- * It tries to mimic API of react-select as closely as possible
65
- */
66
- export const Menu = <T extends MenuOption>({
67
- options,
68
- value,
69
- onSelect,
70
- closeOnSelect = true,
71
- defaultLabel,
72
- components,
73
- renderOption,
74
- className,
75
- ...rest
76
- }: MenuProps<T> & BoxProps) => {
77
- const [isOpen, setIsOpen] = useState(false);
78
- const { refs, floatingStyles, context } = useFloatingMenu({
79
- isOpen,
80
- setIsOpen,
81
- });
82
-
83
- const selectedIndex = useMemo(() => {
84
- const foundIndex = options.findIndex((option) => option.value === value);
85
- return foundIndex < 0 ? null : foundIndex;
86
- }, [options, value]);
87
-
88
- const [activeIndex, setActiveIndex] = useState<number | null>(null);
89
- const handleSelect = (newIndex: number, selectedBy: SelectActionType) => {
90
- onSelect(options[newIndex].value, selectedBy);
91
- if (closeOnSelect) setIsOpen(false);
92
- };
93
-
94
- const listRef = useRef<(HTMLElement | null)[]>([]);
95
- const isTypingRef = useRef(false);
96
- const listContentRef = useRef(options.map((option) => option.label));
97
-
98
- const click = useClick(context, { event: 'mousedown' });
99
- const dismiss = useDismiss(context);
100
- const typeahead = useTypeahead(context, {
101
- listRef: listContentRef,
102
- activeIndex,
103
- selectedIndex,
104
- onMatch: isOpen ? setActiveIndex : (newIndex) => onSelect(options[newIndex].value, 'type'),
105
- onTypingChange(isTyping) {
106
- isTypingRef.current = isTyping;
107
- },
108
- });
109
- const role = useRole(context, { role: 'listbox' });
110
- const listNav = useListNavigation(context, {
111
- listRef,
112
- activeIndex,
113
- selectedIndex,
114
- onNavigate: setActiveIndex,
115
- loop: true,
116
- });
117
-
118
- const { getFloatingProps, getItemProps, getReferenceProps } = useInteractions([click, dismiss, role, listNav, typeahead]);
119
-
120
- const MenuBaseComponent = components?.MenuBase || DropdownMenuBaseComponent;
121
- const MenuComponent = components?.Menu || ListMenuComponent;
122
- const MenuItemComponent = components?.MenuItem || ListMenuItemComponent;
123
-
124
- const effectiveRenderOption = renderOption || defaultRenderOption;
125
-
126
- return (
127
- <Box
128
- className={clsx(className, menuClassNames.WRAPPER)}
129
- {...rest}
130
- >
131
- <MenuBaseComponent
132
- aria-labelledby="select-label"
133
- aria-autocomplete="none"
134
- ref={refs.setReference}
135
- {...getReferenceProps()}
136
- className={menuClassNames.BASE}
137
- tabindex="0"
138
- >
139
- {selectedIndex !== null ? options[selectedIndex].label : defaultLabel}
140
- </MenuBaseComponent>
141
- {isOpen && (
142
- <FloatingPortal>
143
- <FloatingFocusManager
144
- context={context}
145
- modal={false}
146
- >
147
- <MenuComponent
148
- ref={refs.setFloating}
149
- style={floatingStyles}
150
- {...getFloatingProps()}
151
- className={menuClassNames.LIST}
152
- >
153
- {options.map((option, i) => (
154
- <MenuItemComponent
155
- key={option.value}
156
- $isSelected={i === selectedIndex}
157
- $isActive={i === activeIndex}
158
- ref={(node: HTMLElement | null) => {
159
- listRef.current[i] = node;
160
- }}
161
- role="option"
162
- tabIndex={i === activeIndex ? 0 : -1}
163
- className={menuClassNames.ITEM}
164
- aria-selected={i === selectedIndex && i === activeIndex}
165
- {...getItemProps({
166
- onClick: () => handleSelect(i, 'click'), // Handles mouse click
167
- onKeyDown: (event) => {
168
- if (event.key === 'Enter') {
169
- event.preventDefault();
170
- handleSelect(i, 'enter'); // Handles enter press
171
- }
172
-
173
- if (event.key === ' ' && !isTypingRef.current) {
174
- event.preventDefault();
175
- handleSelect(i, 'space');
176
- }
177
- },
178
- })}
179
- >
180
- {effectiveRenderOption(option)}
181
- </MenuItemComponent>
182
- ))}
183
- </MenuComponent>
184
- </FloatingFocusManager>
185
- </FloatingPortal>
186
- )}
187
- </Box>
188
- );
189
- };
@@ -1,31 +0,0 @@
1
- import {
2
- autoUpdate,
3
- offset,
4
- size,
5
- useFloating,
6
- } from '@floating-ui/react';
7
-
8
- export const useFloatingMenu = ({
9
- isOpen,
10
- setIsOpen,
11
- }: {
12
- isOpen: boolean,
13
- setIsOpen: (newIsOpen: boolean) => void
14
- }) => useFloating<Element>({
15
- placement: 'bottom-start',
16
- open: isOpen,
17
- onOpenChange: setIsOpen,
18
- whileElementsMounted: autoUpdate,
19
- middleware: [
20
- offset(5),
21
- size({
22
- apply({ elements, availableHeight }) {
23
- Object.assign(elements.floating.style, {
24
- maxHeight: `${availableHeight}px`,
25
- minHeight: '50px',
26
- });
27
- },
28
- padding: 10,
29
- }),
30
- ],
31
- });