achery-ui 0.5.3 → 0.5.5

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.cjs CHANGED
@@ -37,6 +37,12 @@ var RadixDialog__namespace = /*#__PURE__*/_interopNamespace(RadixDialog);
37
37
  var RadixCheckbox__namespace = /*#__PURE__*/_interopNamespace(RadixCheckbox);
38
38
  var RadixDropdownMenu__namespace = /*#__PURE__*/_interopNamespace(RadixDropdownMenu);
39
39
 
40
+ var AppBarSearchContext = react.createContext(null);
41
+ var AppBarSearchProvider = ({ children }) => {
42
+ const [searchConfig, setSearchConfig] = react.useState(null);
43
+ return /* @__PURE__ */ jsxRuntime.jsx(AppBarSearchContext.Provider, { value: { searchConfig, setSearchConfig }, children });
44
+ };
45
+ var useAppBarSearch = () => react.useContext(AppBarSearchContext);
40
46
  var STORAGE_KEY = "achery-theme-mode";
41
47
  var ThemeContext = react.createContext(null);
42
48
  function getSystemTheme() {
@@ -97,7 +103,7 @@ function AcheryProvider({
97
103
  delete html.dataset["acheryRoot"];
98
104
  };
99
105
  }, [resolvedTheme, accent]);
100
- return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { mode, theme: resolvedTheme, setTheme, toggleTheme, accent, setAccent }, children: /* @__PURE__ */ jsxRuntime.jsx(
106
+ return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { mode, theme: resolvedTheme, setTheme, toggleTheme, accent, setAccent }, children: /* @__PURE__ */ jsxRuntime.jsx(AppBarSearchProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
101
107
  "div",
102
108
  {
103
109
  "data-achery-root": "",
@@ -107,7 +113,7 @@ function AcheryProvider({
107
113
  style,
108
114
  children
109
115
  }
110
- ) });
116
+ ) }) });
111
117
  }
112
118
  function useTheme() {
113
119
  const ctx = react.useContext(ThemeContext);
@@ -708,10 +714,12 @@ function Tooltip({
708
714
  // src/components/Sidebar/Sidebar.css.ts
709
715
  var backdrop = "Sidebar_backdrop__1n0xxfc2";
710
716
  var collapseToggle = "Sidebar_collapseToggle__1n0xxfc3";
711
- var countAccent = "Sidebar_countAccent__1n0xxfc9";
717
+ var countAccent = "Sidebar_countAccent__1n0xxfcb";
712
718
  var footer = "Sidebar_footer__1n0xxfc8";
713
719
  var group = "Sidebar_group__1n0xxfc4";
714
720
  var groupLabel = "Sidebar_groupLabel__1n0xxfc5";
721
+ var mobileSearch = "Sidebar_mobileSearch__1n0xxfc9";
722
+ var mobileSearchInput = "Sidebar_mobileSearchInput__1n0xxfca";
715
723
  var navItem = "Sidebar_navItem__1n0xxfc6";
716
724
  var navItemCount = "Sidebar_navItemCount__1n0xxfc7";
717
725
  var sidebar = "Sidebar_sidebar__1n0xxfc0";
@@ -729,6 +737,8 @@ function Sidebar({
729
737
  className
730
738
  }) {
731
739
  const isMobileMode = mobileOpen !== void 0;
740
+ const searchCtx = useAppBarSearch();
741
+ const searchConfig = searchCtx?.searchConfig ?? null;
732
742
  const nav = /* @__PURE__ */ jsxRuntime.jsxs(
733
743
  "nav",
734
744
  {
@@ -762,6 +772,23 @@ function Sidebar({
762
772
  },
763
773
  i
764
774
  )),
775
+ searchConfig && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: mobileSearch, children: [
776
+ /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
777
+ /* @__PURE__ */ jsxRuntime.jsx(
778
+ "input",
779
+ {
780
+ type: "search",
781
+ placeholder: searchConfig.placeholder,
782
+ className: mobileSearchInput,
783
+ "aria-label": "Search",
784
+ onFocus: () => searchConfig.onSearchFocus?.(),
785
+ onKeyDown: (e) => {
786
+ if (e.key === "Enter") searchConfig.onSearch?.(e.target.value);
787
+ }
788
+ }
789
+ ),
790
+ searchConfig.kbd && /* @__PURE__ */ jsxRuntime.jsx("span", { children: searchConfig.kbd })
791
+ ] }),
765
792
  footer3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: footer, children: footer3 })
766
793
  ]
767
794
  }
@@ -871,17 +898,19 @@ function Avatar({ initials: initials2, size = "md", tone = "neutral", className
871
898
  }
872
899
 
873
900
  // src/components/AppBar/AppBar.css.ts
874
- var accentPicker = "AppBar_accentPicker__uqki999";
875
- var accentSwatch = "AppBar_accentSwatch__uqki99a";
876
- var actions = "AppBar_actions__uqki998";
901
+ var accentPicker = "AppBar_accentPicker__uqki99b";
902
+ var accentSwatch = "AppBar_accentSwatch__uqki99c";
903
+ var actions = "AppBar_actions__uqki999";
904
+ var actionsInner = "AppBar_actionsInner__uqki99a";
877
905
  var appBar = "AppBar_appBar__uqki990";
878
906
  var brand = "AppBar_brand__uqki991";
879
907
  var brandDivider = "AppBar_brandDivider__uqki993";
880
908
  var brandName = "AppBar_brandName__uqki992";
881
909
  var brandSub = "AppBar_brandSub__uqki994";
882
- var searchArea = "AppBar_searchArea__uqki995";
883
- var searchInput2 = "AppBar_searchInput__uqki996";
884
- var searchKbd = "AppBar_searchKbd__uqki997";
910
+ var searchArea = "AppBar_searchArea__uqki996";
911
+ var searchInput2 = "AppBar_searchInput__uqki997";
912
+ var searchKbd = "AppBar_searchKbd__uqki998";
913
+ var searchSpacer = "AppBar_searchSpacer__uqki995";
885
914
  function AppBar({
886
915
  brandName: brandName2 = "Achery",
887
916
  brandSub: brandSub2,
@@ -900,6 +929,17 @@ function AppBar({
900
929
  onSearchFocus,
901
930
  className
902
931
  }) {
932
+ const searchCtx = useAppBarSearch();
933
+ react.useEffect(() => {
934
+ if (!searchCtx || !showSearch) return;
935
+ searchCtx.setSearchConfig({
936
+ placeholder: searchPlaceholder,
937
+ ...searchKbd2 !== void 0 && { kbd: searchKbd2 },
938
+ ...onSearch !== void 0 && { onSearch },
939
+ ...onSearchFocus !== void 0 && { onSearchFocus }
940
+ });
941
+ return () => searchCtx.setSearchConfig(null);
942
+ }, [showSearch, searchPlaceholder, searchKbd2, onSearch, onSearchFocus]);
903
943
  return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: [appBar, className].filter(Boolean).join(" "), children: [
904
944
  onMenuClick && /* @__PURE__ */ jsxRuntime.jsx(
905
945
  Button,
@@ -919,7 +959,7 @@ function AppBar({
919
959
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: brandSub, children: brandSub2 })
920
960
  ] })
921
961
  ] }),
922
- showSearch && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: searchArea, children: [
962
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: showSearch ? searchArea : searchSpacer, children: showSearch && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
923
963
  /* @__PURE__ */ jsxRuntime.jsx(Glyph, { name: "compass", size: 12, "aria-hidden": "true" }),
924
964
  /* @__PURE__ */ jsxRuntime.jsx(
925
965
  "input",
@@ -935,32 +975,34 @@ function AppBar({
935
975
  }
936
976
  ),
937
977
  searchKbd2 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: searchKbd, children: searchKbd2 })
938
- ] }),
978
+ ] }) }),
939
979
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actions, children: [
940
- onAccentChange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: accentPicker, role: "group", "aria-label": "Brand colour", children: chunkLJ24EJ3N_cjs.accentColorNames.map((name) => /* @__PURE__ */ jsxRuntime.jsx(
941
- "button",
942
- {
943
- className: accentSwatch,
944
- "data-active": name === accent,
945
- onClick: () => onAccentChange(name),
946
- "aria-label": name,
947
- "aria-pressed": name === accent,
948
- style: { background: chunkLJ24EJ3N_cjs.accentColors[name].main }
949
- },
950
- name
951
- )) }),
952
- onToggleTheme && /* @__PURE__ */ jsxRuntime.jsx(
953
- Button,
954
- {
955
- variant: "ghost",
956
- size: "sm",
957
- glyph: isDark ? "sun" : "moon",
958
- onClick: onToggleTheme,
959
- "aria-label": isDark ? "Switch to light mode" : "Switch to dark mode"
960
- }
961
- ),
962
- onNewClick && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "accent", size: "sm", glyph: "plus", onClick: onNewClick, children: "New" }),
963
- actions2,
980
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: actionsInner, children: [
981
+ onAccentChange && /* @__PURE__ */ jsxRuntime.jsx("div", { className: accentPicker, role: "group", "aria-label": "Brand colour", children: chunkLJ24EJ3N_cjs.accentColorNames.map((name) => /* @__PURE__ */ jsxRuntime.jsx(
982
+ "button",
983
+ {
984
+ className: accentSwatch,
985
+ "data-active": name === accent,
986
+ onClick: () => onAccentChange(name),
987
+ "aria-label": name,
988
+ "aria-pressed": name === accent,
989
+ style: { background: chunkLJ24EJ3N_cjs.accentColors[name].main }
990
+ },
991
+ name
992
+ )) }),
993
+ onToggleTheme && /* @__PURE__ */ jsxRuntime.jsx(
994
+ Button,
995
+ {
996
+ variant: "ghost",
997
+ size: "sm",
998
+ glyph: isDark ? "sun" : "moon",
999
+ onClick: onToggleTheme,
1000
+ "aria-label": isDark ? "Switch to light mode" : "Switch to dark mode"
1001
+ }
1002
+ ),
1003
+ onNewClick && /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "accent", size: "sm", glyph: "plus", onClick: onNewClick, children: "New" }),
1004
+ actions2
1005
+ ] }),
964
1006
  avatarInitials && /* @__PURE__ */ jsxRuntime.jsx(Avatar, { initials: avatarInitials, size: "sm", tone: "neutral" })
965
1007
  ] })
966
1008
  ] });