@protonradio/proton-ui 0.6.0 → 0.6.1

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/README.md CHANGED
@@ -1,50 +1,50 @@
1
- # Proton UI
2
-
3
- ![](./.readme.gif)
4
-
5
- ```
6
- npm run storybook
7
- ```
8
-
9
- ### Publishing Updates to NPM
10
-
11
- ```
12
- npm run build
13
- npm version <new_version> // increment version in package.json accordingly using semver
14
- npm publish
15
- ```
16
-
17
- ### Themes
18
-
19
- This library supports themes for the various applications that use it. Ideally, we would unify our app designs, but until then themes is a way to support different design patterns using the same api.
20
-
21
- #### Adding a Theme
22
-
23
- The current supported themes can be found in the `src/themes/config.ts`. To add a new theme, create a new attribute on the `THEMES` object following the pattern `[themeName]: [themeClassName]`.
24
-
25
- When applying to a project, you can import available themes using `THEMES` from this library and apply the theme an outer div on the application. See below for an example.
26
-
27
- ```jsx
28
- function MyApp({ Component, pageProps }) {
29
- return (
30
- <ThemeProvider theme={THEMES.DARK}>
31
- <Component {...pageProps} />
32
- </ThemeProvider>
33
- );
34
- }
35
- ```
36
-
37
- #### Styling for a theme
38
-
39
- To apply theme specific styles in a component, we set theme specific css variables in the `src/themes/config.ts` file, in `generateThemeCssVariables` function. If you need more control, you can add either use the `useTheme` hook to manipulate the DOM, or you can use css selectors that reference the wrapping theme class.
40
-
41
- For example, to apply a style to the dark theme, you can use the following css.
42
- ```css
43
- .proton-ui__theme--dark .myComponent {
44
- background-color: red;
45
- }
46
- ```
47
-
48
- ### Recommended Reading
49
-
50
- - https://www.gabe.pizza/notes-on-component-libraries/
1
+ # Proton UI
2
+
3
+ ![](./.readme.gif)
4
+
5
+ ```
6
+ npm run storybook
7
+ ```
8
+
9
+ ### Publishing Updates to NPM
10
+
11
+ ```
12
+ npm run build
13
+ npm version <new_version> // increment version in package.json accordingly using semver
14
+ npm publish
15
+ ```
16
+
17
+ ### Themes
18
+
19
+ This library supports themes for the various applications that use it. Ideally, we would unify our app designs, but until then themes is a way to support different design patterns using the same api.
20
+
21
+ #### Adding a Theme
22
+
23
+ The current supported themes can be found in the `src/themes/config.ts`. To add a new theme, create a new attribute on the `THEMES` object following the pattern `[themeName]: [themeClassName]`.
24
+
25
+ When applying to a project, you can import available themes using `THEMES` from this library and apply the theme an outer div on the application. See below for an example.
26
+
27
+ ```jsx
28
+ function MyApp({ Component, pageProps }) {
29
+ return (
30
+ <ThemeProvider theme={THEMES.DARK}>
31
+ <Component {...pageProps} />
32
+ </ThemeProvider>
33
+ );
34
+ }
35
+ ```
36
+
37
+ #### Styling for a theme
38
+
39
+ To apply theme specific styles in a component, we set theme specific css variables in the `src/themes/config.ts` file, in `generateThemeCssVariables` function. If you need more control, you can add either use the `useTheme` hook to manipulate the DOM, or you can use css selectors that reference the wrapping theme class.
40
+
41
+ For example, to apply a style to the dark theme, you can use the following css.
42
+ ```css
43
+ .proton-ui__theme--dark .myComponent {
44
+ background-color: red;
45
+ }
46
+ ```
47
+
48
+ ### Recommended Reading
49
+
50
+ - https://www.gabe.pizza/notes-on-component-libraries/
package/dist/icons.svg CHANGED
@@ -1,11 +1,11 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
- <defs>
3
- <symbol id="external-link" viewBox="0 0 512 512">
4
- <path d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
5
- </symbol>
6
-
7
- <symbol id="caret-down" viewBox="0 0 512 512">
8
- <path fill="currentColor" d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7L86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"/>
9
- </symbol>
10
- </defs>
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
+ <defs>
3
+ <symbol id="external-link" viewBox="0 0 512 512">
4
+ <path d="M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
5
+ </symbol>
6
+
7
+ <symbol id="caret-down" viewBox="0 0 512 512">
8
+ <path fill="currentColor" d="M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7L86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"/>
9
+ </symbol>
10
+ </defs>
11
11
  </svg>
@@ -113,6 +113,109 @@ declare interface BannerProps extends BannerIconProps, default_2.HTMLAttributes<
113
113
 
114
114
  export declare type BannerVariant = "default" | "success" | "warning" | "danger";
115
115
 
116
+ declare interface BaseInputProps {
117
+ /**
118
+ * onChange handler for the input
119
+ * @param {React.ChangeEvent<HTMLInputElement>} event
120
+ */
121
+ onChange?: (value: string) => void;
122
+ /**
123
+ * onKeyDown handler for the input
124
+ * @param {React.KeyboardEvent<HTMLInputElement>} event
125
+ */
126
+ onKeyDown?: (event: default_2.KeyboardEvent<HTMLInputElement>) => void;
127
+ /**
128
+ * Whether the input is disabled.
129
+ * @param {boolean} isDisabled
130
+ */
131
+ isDisabled?: boolean;
132
+ /**
133
+ * Should the input be rounded?
134
+ * @param {boolean} isRounded
135
+ */
136
+ isRounded?: boolean;
137
+ /**
138
+ * Description text shown above the input.
139
+ * @param {React.ReactNode | string} description
140
+ */
141
+ description?: default_2.ReactNode | string;
142
+ /**
143
+ * Error state that changes the input's visual style and displays an error message.
144
+ * @param {React.ReactNode | string} error
145
+ */
146
+ error?: default_2.ReactNode | string;
147
+ /**
148
+ * Label for the input element.
149
+ * @note When a label is provided, the input will have extra padding, and the label will float above the text input when focused or filled.
150
+ * @param {string} label
151
+ */
152
+ label?: string;
153
+ /**
154
+ * Test ID for the component.
155
+ * @param {string} data-testid
156
+ */
157
+ "data-testid"?: string;
158
+ /**
159
+ * Content to display before the input. Typically used for icons.
160
+ * @param {React.ReactNode} prefix
161
+ */
162
+ prefix?: default_2.ReactNode;
163
+ /**
164
+ * Content to display after the input. Typically used for icons.
165
+ * @param {React.ReactNode} suffix
166
+ */
167
+ suffix?: default_2.ReactNode;
168
+ /**
169
+ * Should the browser's autocomplete be enabled?
170
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
171
+ * @param {boolean} autoComplete
172
+ */
173
+ autoComplete?: boolean;
174
+ /**
175
+ * Should the input be autofocused?
176
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autofocus
177
+ * @param {boolean} autoFocus
178
+ */
179
+ autoFocus?: boolean;
180
+ /**
181
+ * The name attribute of the input element.
182
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/name
183
+ * @param {string} name
184
+ */
185
+ name?: string;
186
+ /**
187
+ * The placeholder text to display when the input is empty.
188
+ * @note Placeholder takes precedence over label, if both are provided.
189
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder
190
+ * @param {string} placeholder
191
+ */
192
+ placeholder?: string;
193
+ /**
194
+ * The pattern attribute of the input element.
195
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
196
+ * @param {string} pattern
197
+ */
198
+ pattern?: string;
199
+ /**
200
+ * The tab index of the input element.
201
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
202
+ * @param {number} tabIndex
203
+ */
204
+ tabIndex?: number;
205
+ /**
206
+ * The type attribute of the input element.
207
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/type
208
+ * @param {string} type
209
+ */
210
+ type?: string;
211
+ /**
212
+ * The value of the input.
213
+ * @external https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
214
+ * @param {string} value
215
+ */
216
+ value?: string;
217
+ }
218
+
116
219
  export declare const BRAND: {
117
220
  PRIMARY: string;
118
221
  PRIMARY_LIGHT: string;
@@ -268,6 +371,11 @@ declare interface IconProps {
268
371
  color?: string;
269
372
  }
270
373
 
374
+ /**
375
+ * A controlled and customizable input component with support for labels, prefixes, suffixes, and error states.
376
+ */
377
+ export declare const Input: default_2.ForwardRefExoticComponent<BaseInputProps & default_2.RefAttributes<HTMLInputElement>>;
378
+
271
379
  /**
272
380
  * [isUrlExternal] - determine if passed absolute url is external to the current domain.
273
381
  */
@@ -317,6 +425,40 @@ export declare type RGBArray = [number, number, number];
317
425
 
318
426
  export { Row }
319
427
 
428
+ /**
429
+ * A search input component with optional clear functionality and URL parameter sync.
430
+ */
431
+ export declare const SearchInput: ({ name, placeholder, autoComplete, isClearable, isRounded, error, urlSearchParam, defaultValue, "data-testid": testId, onChange, onClear, }: SearchInputProps) => JSX_2.Element;
432
+
433
+ declare interface SearchInputProps extends Omit<BaseInputProps, "prefix" | "suffix" | "value" | "onChange"> {
434
+ /**
435
+ * Should the clear button be shown when there is text?
436
+ * @param {boolean} isClearable
437
+ */
438
+ isClearable?: boolean;
439
+ /**
440
+ * Called when the input value changes.
441
+ * @note Required when using the input as a controlled component.
442
+ * @param {(value: string) => void} onChange
443
+ */
444
+ onChange?: (value: string) => void;
445
+ /**
446
+ * Called when the clear button is clicked.
447
+ * @param {() => void} onClear
448
+ */
449
+ onClear?: () => void;
450
+ /**
451
+ * URL search parameter key to sync the input value with.
452
+ * @param {string} urlSearchParam
453
+ */
454
+ urlSearchParam?: string;
455
+ /**
456
+ * The initial value of the input.
457
+ * @param {string} defaultValue
458
+ */
459
+ defaultValue?: string;
460
+ }
461
+
320
462
  export { Section }
321
463
 
322
464
  export declare const Select: {