tinywidgets 1.3.6 → 1.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinywidgets",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinywidgets",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import {useCallback, useState, type ComponentType} from 'react';
1
+ import {useCallback, useEffect, useState, type ComponentType} from 'react';
2
2
  import {classNames} from '../../common/functions.tsx';
3
3
  import {iconSize} from '../../css/dimensions.css.ts';
4
4
  import {icon, input, inputWithIcon, wrapper} from './index.css.ts';
@@ -62,13 +62,22 @@ export const TextInput = ({
62
62
  ref?: React.RefObject<HTMLInputElement | null>;
63
63
  }) => {
64
64
  const [text, setText] = useState(initialText ?? '');
65
- const handleChange = useCallback(
66
- ({target: {value}}: React.ChangeEvent<HTMLInputElement>) => {
65
+
66
+ const change = useCallback(
67
+ (value: string) => {
67
68
  setText(value);
68
69
  onChange?.(value);
69
70
  },
70
71
  [onChange],
71
72
  );
73
+
74
+ const handleChange = useCallback(
75
+ ({target: {value}}: React.ChangeEvent<HTMLInputElement>) => change(value),
76
+ [change],
77
+ );
78
+
79
+ useEffect(() => change(initialText ?? ''), [change, initialText]);
80
+
72
81
  return (
73
82
  <div className={wrapper}>
74
83
  {Icon ? <Icon className={classNames(iconSize, icon)} /> : null}
@@ -16,6 +16,7 @@ import {
16
16
  * - `accentLight`
17
17
  * - `accentHover`
18
18
  * - `accentContrast`
19
+ * - `accentBright`
19
20
  * - `background`
20
21
  * - `background2`
21
22
  * - `backgroundHaze`
@@ -71,6 +72,7 @@ export const colors = createThemeContract({
71
72
  accentLight: null,
72
73
  accentHover: null,
73
74
  accentContrast: null,
75
+ accentBright: null,
74
76
  background: null,
75
77
  background2: null,
76
78
  backgroundHaze: null,
@@ -95,6 +97,7 @@ const common = {
95
97
  accent: `oklch(50% .11 ${colors.accentHue})`,
96
98
  accentLight: `oklch(71% .16 ${colors.accentHue})`,
97
99
  accentHover: `oklch(45% .1 ${colors.accentHue})`,
100
+ accentBright: `oklch(57.37% 0.2178 ${colors.accentHue})`,
98
101
  accentContrast: '#fff',
99
102
  };
100
103