@helpwave/hightide 0.0.17 → 0.0.18

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/dist/index.mjs CHANGED
@@ -5242,29 +5242,35 @@ var ScrollPicker = ({
5242
5242
  };
5243
5243
 
5244
5244
  // src/components/user-input/ToggleableInput.tsx
5245
- import { useState as useState25 } from "react";
5245
+ import { useEffect as useEffect19, useRef as useRef7, useState as useState25 } from "react";
5246
5246
  import { Pencil } from "lucide-react";
5247
5247
  import clsx45 from "clsx";
5248
5248
  import { jsx as jsx63, jsxs as jsxs44 } from "react/jsx-runtime";
5249
5249
  var ToggleableInput = ({
5250
- id,
5251
5250
  type = "text",
5252
5251
  value,
5253
5252
  onChange = noop,
5253
+ onChangeText = noop,
5254
+ onEditCompleted = noop,
5254
5255
  labelClassName = "",
5255
5256
  initialState = "display",
5256
5257
  size = 20,
5257
5258
  disclaimer,
5258
5259
  onBlur,
5259
- onEditCompleted = noop,
5260
5260
  ...restProps
5261
5261
  }) => {
5262
5262
  const [isEditing, setIsEditing] = useState25(initialState !== "display");
5263
5263
  const { restartTimer, clearUpdateTimer } = useSaveDelay(() => void 0, 3e3);
5264
+ const ref = useRef7(null);
5264
5265
  const onEditCompletedWrapper = (text) => {
5265
5266
  onEditCompleted(text);
5266
5267
  clearUpdateTimer();
5267
5268
  };
5269
+ useEffect19(() => {
5270
+ if (isEditing) {
5271
+ ref.current?.focus();
5272
+ }
5273
+ }, [isEditing]);
5268
5274
  return /* @__PURE__ */ jsxs44("div", { children: [
5269
5275
  /* @__PURE__ */ jsxs44(
5270
5276
  "div",
@@ -5275,17 +5281,17 @@ var ToggleableInput = ({
5275
5281
  /* @__PURE__ */ jsx63("div", { className: clsx45("row overflow-hidden", { "flex-1": isEditing }), children: isEditing ? /* @__PURE__ */ jsx63(
5276
5282
  "input",
5277
5283
  {
5278
- autoFocus: true,
5284
+ ref,
5279
5285
  ...restProps,
5280
5286
  value,
5281
5287
  type,
5282
- id,
5283
5288
  onChange: (event) => {
5284
5289
  const value2 = event.target.value;
5285
5290
  restartTimer(() => {
5286
5291
  onEditCompletedWrapper(value2);
5287
5292
  });
5288
- onChange(value2);
5293
+ onChangeText(value2);
5294
+ onChange(event);
5289
5295
  },
5290
5296
  onBlur: (event) => {
5291
5297
  if (onBlur) {
@@ -5300,7 +5306,7 @@ var ToggleableInput = ({
5300
5306
  onEditCompletedWrapper(value);
5301
5307
  }
5302
5308
  },
5303
- className: clsx45(labelClassName, `w-full border-none rounded-none focus:ring-0 shadow-transparent decoration-primary p-0 underline-offset-4`, {
5309
+ className: clsx45(labelClassName, `w-full border-none rounded-none ring-0 outline-0 shadow-transparent decoration-primary p-0 underline-offset-4`, {
5304
5310
  underline: isEditing
5305
5311
  }),
5306
5312
  onFocus: (event) => event.target.select()
@@ -5312,17 +5318,45 @@ var ToggleableInput = ({
5312
5318
  children: value
5313
5319
  }
5314
5320
  ) }),
5315
- /* @__PURE__ */ jsx63(Pencil, { className: clsx45(`min-w-[${size}px] cursor-pointer`, { "text-transparent": isEditing }), size })
5321
+ /* @__PURE__ */ jsx63(
5322
+ Pencil,
5323
+ {
5324
+ className: clsx45(`cursor-pointer`, { "text-transparent": isEditing }),
5325
+ size,
5326
+ style: { minWidth: `${size}px` }
5327
+ }
5328
+ )
5316
5329
  ]
5317
5330
  }
5318
5331
  ),
5319
5332
  isEditing && disclaimer && /* @__PURE__ */ jsx63("label", { className: "text-negative", children: disclaimer })
5320
5333
  ] });
5321
5334
  };
5335
+ var ToggleableInputUncontrolled = ({
5336
+ value: initialValue,
5337
+ onChangeText = noop,
5338
+ ...restProps
5339
+ }) => {
5340
+ const [value, setValue] = useState25(initialValue);
5341
+ useEffect19(() => {
5342
+ setValue(initialValue);
5343
+ }, [initialValue]);
5344
+ return /* @__PURE__ */ jsx63(
5345
+ ToggleableInput,
5346
+ {
5347
+ value,
5348
+ onChangeText: (text) => {
5349
+ setValue(text);
5350
+ onChangeText(text);
5351
+ },
5352
+ ...restProps
5353
+ }
5354
+ );
5355
+ };
5322
5356
 
5323
5357
  // src/hooks/useTheme.tsx
5324
5358
  import { useContext as useContext3 } from "react";
5325
- import { createContext as createContext3, useState as useState26, useEffect as useEffect19 } from "react";
5359
+ import { createContext as createContext3, useState as useState26, useEffect as useEffect20 } from "react";
5326
5360
  import { jsx as jsx64 } from "react/jsx-runtime";
5327
5361
  var defaultThemeTypeTranslation = {
5328
5362
  en: {
@@ -5341,13 +5375,13 @@ var ThemeContext = createContext3({
5341
5375
  });
5342
5376
  var ThemeProvider = ({ children, initialTheme = "light" }) => {
5343
5377
  const [theme, setTheme] = useState26(initialTheme);
5344
- useEffect19(() => {
5378
+ useEffect20(() => {
5345
5379
  if (theme !== initialTheme) {
5346
5380
  console.warn("ThemeProvider initial state changed: Prefer using useTheme's setTheme instead");
5347
5381
  setTheme(initialTheme);
5348
5382
  }
5349
5383
  }, [initialTheme]);
5350
- useEffect19(() => {
5384
+ useEffect20(() => {
5351
5385
  document.documentElement.setAttribute("data-theme", theme);
5352
5386
  }, [theme]);
5353
5387
  return /* @__PURE__ */ jsx64(ThemeContext.Provider, { value: { theme, setTheme }, children });
@@ -5483,6 +5517,7 @@ export {
5483
5517
  TimeDisplay,
5484
5518
  TimePicker,
5485
5519
  ToggleableInput,
5520
+ ToggleableInputUncontrolled,
5486
5521
  Tooltip,
5487
5522
  UncontrolledCheckbox,
5488
5523
  UncontrolledInput,