@jirawatpyk/aura-react 4.4.2 → 4.5.0

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.
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { useStrings, useAuraLocale } from "./locale.js";
3
+ import { useStrings } from "./locale.js";
4
4
  import { cx, useMaybeControlled, uid } from "./internal.js";
5
5
  import { Icon } from "./Icon.js";
6
6
  const h = React.createElement;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import * as React from "react";
3
- import { useStrings, useAuraLocale } from "./locale.js";
3
+ import { useStrings } from "./locale.js";
4
4
  import { cx } from "./internal.js";
5
5
  import { IconButton } from "./IconButton.js";
6
6
  import { Drawer } from "./Dialog.js";
@@ -28,16 +28,17 @@ function subscribe(cb) {
28
28
  function useResponsive(value) {
29
29
  var bp = useBreakpoint();
30
30
  if (value == null || typeof value !== "object") return value;
31
- for (var i = ORDER.indexOf(bp); i >= 0; i--) if (value[ORDER[i]] !== void 0) return value[ORDER[i]];
31
+ var map = value;
32
+ for (var i = ORDER.indexOf(bp); i >= 0; i--) if (map[ORDER[i]] !== void 0) return map[ORDER[i]];
32
33
  return void 0;
33
34
  }
34
35
  function respVars(prefix, value, map) {
35
36
  var style = {};
36
37
  if (value == null) return style;
37
38
  if (typeof value !== "object") value = { base: value };
38
- var cur;
39
+ var byBp = value, cur;
39
40
  ORDER.forEach(function(k) {
40
- if (value[k] !== void 0) cur = map ? map(value[k]) : value[k];
41
+ if (byBp[k] !== void 0) cur = map ? map(byBp[k]) : byBp[k];
41
42
  if (cur !== void 0) style["--" + prefix + "-" + k] = cur;
42
43
  });
43
44
  return style;
@@ -77,10 +78,11 @@ const AppShell = React.forwardRef(function AppShell2(props, ref) {
77
78
  React.useEffect(function() {
78
79
  if (!compact) setOpen(false);
79
80
  }, [compact]);
80
- var nav = props.nav && React.isValidElement(props.nav) && compact ? React.cloneElement(props.nav, { onChange: function(id) {
81
- if (props.nav.props.onChange) props.nav.props.onChange(id);
81
+ var navEl = props.nav;
82
+ var nav = props.nav && React.isValidElement(props.nav) && compact ? React.cloneElement(navEl, { onChange: function(id) {
83
+ if (navEl.props.onChange) navEl.props.onChange(id);
82
84
  setOpen(false);
83
- }, className: cx(props.nav.props.className, "is-in-drawer") }) : props.nav;
85
+ }, className: cx(navEl.props.className, "is-in-drawer") }) : props.nav;
84
86
  return h(
85
87
  "div",
86
88
  { ref, className: cx("aura-shell", compact && "is-compact", props.className) },
@@ -185,8 +185,8 @@ var STRINGS = {
185
185
  var LocaleContext = React.createContext(null);
186
186
  function AuraProvider(props) {
187
187
  var value = React.useMemo(function() {
188
- var base = STRINGS[props.locale] || STRINGS.en;
189
- return { locale: props.locale || "en", calendar: props.calendar, strings: props.strings ? Object.assign({}, base, props.strings) : base };
188
+ var base = props.locale && STRINGS[props.locale] || STRINGS.en;
189
+ return { locale: props.locale || "en", calendar: props.calendar || null, strings: props.strings ? Object.assign({}, base, props.strings) : base };
190
190
  }, [props.locale, props.calendar, props.strings]);
191
191
  return h(LocaleContext.Provider, { value }, props.children);
192
192
  }
@@ -39,7 +39,7 @@ function useModal(open, ref, opts) {
39
39
  first.focus();
40
40
  }
41
41
  }
42
- return { ready: open && mounted, onKeyDown };
42
+ return { ready: !!open && mounted, onKeyDown };
43
43
  }
44
44
  export {
45
45
  useModal