@edifice.io/react 2.6.0-develop-enabling.20260720144517 → 2.6.0-develop-pedago.20260721150256

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.
@@ -6,6 +6,11 @@ export type NotificationBadgeVariant = {
6
6
  type: 'notification';
7
7
  level: 'success' | 'warning' | 'danger' | 'info';
8
8
  };
9
+ /** Badge variant : status */
10
+ export type StatusBadgeVariant = {
11
+ type: 'status';
12
+ level: 'validate' | 'success' | 'warning' | 'danger' | 'info';
13
+ };
9
14
  /** Badge variant : content */
10
15
  export type ContentBadgeVariant = {
11
16
  type: 'content';
@@ -27,22 +32,29 @@ export type LinkBadgeVariant = {
27
32
  type: 'link';
28
33
  };
29
34
  /**
30
- * Badge variant : beta.
31
- * Beta Badge is used to indicate that a feature is in beta phase.
32
- * The color prop allows to customize the badge color to match the app color.
33
- * Defaults to black if not provided.
34
- * Beta Badge has a fixed text 'BÊTA' unless children is provided.
35
- * If app is provided, the color of the Beta Badge is derived from the application colors.
36
- * Example:
37
- * <Badge variant={{ type: 'beta', color: '#823AA1', app: myApp }} />
38
- * where myApp is of type IWebApp.
35
+ * Badge variant : App Version.
36
+ *
37
+ * Displays a badge showing the app version, for example: BÊTA, ALPHA, NEW or a custom version label.
38
+ *
39
+ * Default label is BÊTA unless a label is provided as a children of the component.
40
+ * Example of usage:
41
+ * <Badge variant={{ type: 'appVersion', app: myApp }}>NEW</Badge>
42
+ *
43
+ * The color prop allows to customize the badge color to match the app color (Defaults to black if not provided).
44
+ * Example of usage:
45
+ * <Badge variant={{ type: 'appVersion', color: '#823AA1' }} />
46
+ *
47
+ * If app prop is provided, the color of the App Version Badge is derived from the application colors,
48
+ * for example if the app provided is Blog then the Badge will have the same color as Blog app.
49
+ * Example of usage:
50
+ * <Badge variant={{ type: 'appVersion', app: blog }} />
39
51
  */
40
- export type BetaBadgeVariant = {
41
- type: 'beta';
52
+ export type AppVersionBadgeVariant = {
53
+ type: 'appVersion';
42
54
  color?: string;
43
55
  app?: IWebApp;
44
56
  };
45
- export type BadgeVariants = NotificationBadgeVariant | ContentBadgeVariant | ProfileBadgeVariant | ChipBadgeVariant | LinkBadgeVariant | BetaBadgeVariant;
57
+ export type BadgeVariants = NotificationBadgeVariant | StatusBadgeVariant | ContentBadgeVariant | ProfileBadgeVariant | ChipBadgeVariant | LinkBadgeVariant | AppVersionBadgeVariant;
46
58
  export interface BadgeProps extends React.ComponentPropsWithRef<'span'> {
47
59
  /**
48
60
  * Badge variant : notification, link or profile (Teacher|Student|Relative|Personnel)
@@ -51,7 +63,6 @@ export interface BadgeProps extends React.ComponentPropsWithRef<'span'> {
51
63
  variant?: BadgeVariants;
52
64
  /**
53
65
  * Text or icon (or whatever) to render as children elements.
54
- * Defaults to 'BÊTA' for beta variant.
55
66
  */
56
67
  children?: ReactNode;
57
68
  /**
@@ -16,16 +16,16 @@ const Badge = /* @__PURE__ */ forwardRef(({
16
16
  getBackgroundLightIconClass,
17
17
  getBorderIconClass
18
18
  } = useEdificeIcons();
19
- let badgeColorClassName = "";
20
- if (variant.type === "beta" && variant.app) {
19
+ let appVersionBadgeColorClassName = "";
20
+ if (variant.type === "appVersion" && variant.app) {
21
21
  const colorAppClassName = getIconClass(variant.app), backgroundLightAppClassName = getBackgroundLightIconClass(variant.app), borderAppClassName = getBorderIconClass(variant.app);
22
- badgeColorClassName = `${colorAppClassName} ${backgroundLightAppClassName} ${borderAppClassName}`;
22
+ appVersionBadgeColorClassName = `${colorAppClassName} ${backgroundLightAppClassName} ${borderAppClassName}`;
23
23
  }
24
- const classes = clsx("badge rounded-pill", (variant.type === "content" || variant.type === "user") && "background" in variant ? "bg-gray-200" : (variant.type === "content" || variant.type === "user") && !("background" in variant) ? "border border-0" : "", variant.type === "content" && `text-${variant.level}`, variant.type === "notification" && `badge-notification bg-${variant.level} text-light border border-0`, variant.type === "user" && `badge-profile-${variant.profile.toLowerCase()}`, variant.type === "link" && "badge-link border border-0", variant.type === "chip" && "bg-gray-200", variant.type === "beta" && badgeColorClassName, className);
24
+ const classes = clsx("badge rounded-pill", (variant.type === "content" || variant.type === "user") && "background" in variant ? "bg-gray-200" : (variant.type === "content" || variant.type === "user") && !("background" in variant) ? "border border-0" : "", variant.type === "content" && `text-${variant.level}`, variant.type === "notification" && `badge-notification bg-${variant.level} text-light border border-0`, variant.type === "status" && `badge-status badge-status-${variant.level} caption fw-normal`, variant.type === "user" && `badge-profile-${variant.profile.toLowerCase()}`, variant.type === "link" && "badge-link border border-0", variant.type === "chip" && "bg-gray-200", variant.type === "appVersion" && appVersionBadgeColorClassName, className);
25
25
  return /* @__PURE__ */ jsxs("span", { ref, className: classes, ...restProps, children: [
26
26
  variant.type === "chip" && /* @__PURE__ */ jsx("div", { className: "d-flex fw-800 align-items-center", children }),
27
- variant.type === "beta" && (children ?? "BÊTA"),
28
- variant.type !== "chip" && variant.type !== "beta" && children
27
+ variant.type === "appVersion" && (children ?? "BÊTA"),
28
+ variant.type !== "chip" && variant.type !== "appVersion" && children
29
29
  ] });
30
30
  });
31
31
  export {
@@ -1,19 +1,15 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { Suspense, lazy } from "react";
3
2
  import clsx from "clsx";
4
3
  import { Toaster } from "react-hot-toast";
5
4
  import { useTranslation } from "react-i18next";
6
5
  import { useEdificeTheme } from "../../providers/EdificeThemeProvider/EdificeThemeProvider.hook.js";
7
6
  import Header from "./components/Header.js";
8
- import HeaderNotificationsOverlay from "./components/HeaderNotificationsOverlay.js";
9
- import { useOverlay } from "../PageLayout/hook/useOverlay.js";
10
- import useUiOverride from "../../hooks/useUiOverride/useUiOverride.js";
11
7
  import useCookiesConsent from "../../hooks/useCookiesConsent/useCookiesConsent.js";
12
8
  import useZendeskGuide from "../../hooks/useZendeskGuide/useZendeskGuide.js";
13
9
  import useCantoo from "../../hooks/useCantoo/useCantoo.js";
14
10
  import Alert from "../Alert/Alert.js";
15
11
  import Button from "../Button/Button.js";
16
- const HeaderV2 = /* @__PURE__ */ lazy(() => import("../../modules/homepage/components/Header/Header.js")), Layout = ({
12
+ const Layout = ({
17
13
  children,
18
14
  headless = !1,
19
15
  whiteBg = !0,
@@ -22,9 +18,7 @@ const HeaderV2 = /* @__PURE__ */ lazy(() => import("../../modules/homepage/compo
22
18
  }) => {
23
19
  const {
24
20
  theme
25
- } = useEdificeTheme(), override = useUiOverride("layout.header"), isHeaderV2 = (override == null ? void 0 : override.variant) === "v2", {
26
- toggleOverlay
27
- } = useOverlay(), {
21
+ } = useEdificeTheme(), {
28
22
  t
29
23
  } = useTranslation(), {
30
24
  showCookiesConsent,
@@ -37,12 +31,11 @@ const HeaderV2 = /* @__PURE__ */ lazy(() => import("../../modules/homepage/compo
37
31
  "container-fluid": !headless,
38
32
  "rounded-4 border": (theme == null ? void 0 : theme.is1d) && !headless,
39
33
  "mt-24": (theme == null ? void 0 : theme.is1d) && !headless
40
- }, className), renderHeader = headless ? null : isHeaderV2 ? /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(HeaderV2, { src: theme == null ? void 0 : theme.basePath, dataProduct: override == null ? void 0 : override.theme, onNotificationsClick: toggleOverlay }) }) : /* @__PURE__ */ jsx(Header, { is1d: theme == null ? void 0 : theme.is1d, src: theme == null ? void 0 : theme.basePath }), renderNotificationsOverlay = !headless && isHeaderV2 && /* @__PURE__ */ jsx(HeaderNotificationsOverlay, {}), renderCookies = showCookiesConsent && /* @__PURE__ */ jsx(Alert, { type: "info", className: "m-12 rgpd", isConfirm: !0, position: "bottom-right", button: /* @__PURE__ */ jsx(Button, { color: "tertiary", variant: "ghost", onClick: handleConsultCookies, children: t("rgpd.cookies.banner.button.consult") }), onClose: handleCloseCookiesConsent, children: t("rgpd.cookies.banner.text1") }), renderToaster = /* @__PURE__ */ jsx(Toaster, { containerClassName: "toaster-container", toastOptions: {
34
+ }, className), renderHeader = headless ? null : /* @__PURE__ */ jsx(Header, { is1d: theme == null ? void 0 : theme.is1d, src: theme == null ? void 0 : theme.basePath }), renderCookies = showCookiesConsent && /* @__PURE__ */ jsx(Alert, { type: "info", className: "m-12 rgpd", isConfirm: !0, position: "bottom-right", button: /* @__PURE__ */ jsx(Button, { color: "tertiary", variant: "ghost", onClick: handleConsultCookies, children: t("rgpd.cookies.banner.button.consult") }), onClose: handleCloseCookiesConsent, children: t("rgpd.cookies.banner.text1") }), renderToaster = /* @__PURE__ */ jsx(Toaster, { containerClassName: "toaster-container", toastOptions: {
41
35
  position: "top-right"
42
36
  } });
43
37
  return /* @__PURE__ */ jsxs(Fragment, { children: [
44
38
  renderHeader,
45
- renderNotificationsOverlay,
46
39
  /* @__PURE__ */ jsx("main", { className: classes, ...restProps, children }),
47
40
  renderToaster,
48
41
  renderCookies
@@ -1,5 +1,5 @@
1
1
  import { create } from "zustand";
2
- import { createSelectors } from "../../../utilities/create-selectors/create-selectors.js";
2
+ import { createSelectors } from "../../../utilities/create-selectors/createSelectors.js";
3
3
  const useOverlayStore = createSelectors(create((set) => ({
4
4
  overlayOpen: !1,
5
5
  updateOverlayOpen: (value) => set((previousState) => ({
@@ -30,7 +30,6 @@ export * from './useToast';
30
30
  export * from './useToggle';
31
31
  export * from './useTrapFocus';
32
32
  export * from './useTrashedResource';
33
- export * from './useUiOverride';
34
33
  export * from './useUpload';
35
34
  export * from './useUploadFiles';
36
35
  export * from './useUser';
package/dist/index.js CHANGED
@@ -106,17 +106,16 @@ import { default as default104 } from "./hooks/useToast/useToast.js";
106
106
  import { default as default105 } from "./hooks/useToggle/useToggle.js";
107
107
  import { default as default106 } from "./hooks/useTrapFocus/useTrapFocus.js";
108
108
  import { default as default107 } from "./hooks/useTrashedResource/useTrashedResource.js";
109
- import { default as default108 } from "./hooks/useUiOverride/useUiOverride.js";
110
- import { default as default109 } from "./modules/modals/ResourceModal/hooks/useUpdateMutation.js";
111
- import { default as default110 } from "./hooks/useUpload/useUpload.js";
112
- import { default as default111 } from "./hooks/useUploadFiles/useUploadFiles.js";
113
- import { default as default112 } from "./hooks/useUser/useUser.js";
114
- import { default as default113 } from "./hooks/useWorkspaceFile/useWorkspaceFile.js";
115
- import { default as default114 } from "./hooks/useWorkspaceFolders/useWorkspaceFolders.js";
116
- import { WORKSPACE_SHARED_FOLDER_ID, WORKSPACE_USER_FOLDER_ID, default as default115 } from "./hooks/useWorkspaceFolders/useWorkspaceFoldersTree.js";
117
- import { default as default116 } from "./hooks/useWorkspaceSearch/useWorkspaceSearch.js";
118
- import { default as default117 } from "./hooks/useXitiTrackPageLoad/useXitiTrackPageLoad.js";
119
- import { default as default118 } from "./hooks/useZendeskGuide/useZendeskGuide.js";
109
+ import { default as default108 } from "./modules/modals/ResourceModal/hooks/useUpdateMutation.js";
110
+ import { default as default109 } from "./hooks/useUpload/useUpload.js";
111
+ import { default as default110 } from "./hooks/useUploadFiles/useUploadFiles.js";
112
+ import { default as default111 } from "./hooks/useUser/useUser.js";
113
+ import { default as default112 } from "./hooks/useWorkspaceFile/useWorkspaceFile.js";
114
+ import { default as default113 } from "./hooks/useWorkspaceFolders/useWorkspaceFolders.js";
115
+ import { WORKSPACE_SHARED_FOLDER_ID, WORKSPACE_USER_FOLDER_ID, default as default114 } from "./hooks/useWorkspaceFolders/useWorkspaceFoldersTree.js";
116
+ import { default as default115 } from "./hooks/useWorkspaceSearch/useWorkspaceSearch.js";
117
+ import { default as default116 } from "./hooks/useXitiTrackPageLoad/useXitiTrackPageLoad.js";
118
+ import { default as default117 } from "./hooks/useZendeskGuide/useZendeskGuide.js";
120
119
  import { AccessiblePalette, DefaultPalette } from "./components/ColorPicker/ColorPalette.js";
121
120
  import { AntProvider } from "./providers/AntThemeProvider/AntProvider.js";
122
121
  import { BetaSwitch } from "./components/BetaSwitch/BetaSwitch.js";
@@ -147,7 +146,6 @@ import { UserSearch } from "./components/UserSearch/UserSearch.js";
147
146
  import { VisibleType } from "./components/UserSearch/types/visible.js";
148
147
  import { buildTree, determineNewParentId, findItemIndexInTree, flattenNodes, flattenTree, generateUpdateData, getActiveAndOverNodes, getDragDepth, getIndicesToUpdate, getProjection, updateParentIds } from "./components/Tree/utilities/tree-sortable.js";
149
148
  import { checkUserRight } from "./utilities/check-user-rights/check-user-rights.js";
150
- import { createSelectors } from "./utilities/create-selectors/create-selectors.js";
151
149
  import { emptyScreenMapping } from "./utilities/emptyscreen-mapping/emptyscreen-mapping.js";
152
150
  import { getRotateTransitionStyle } from "./utilities/rotate-transition-style/get-rotate-transition-style.js";
153
151
  import { invalidateQueriesWithFirstPage } from "./utilities/react-query/react-query-utils.js";
@@ -278,7 +276,6 @@ export {
278
276
  arrayUnique,
279
277
  buildTree,
280
278
  checkUserRight,
281
- createSelectors,
282
279
  deleteNode,
283
280
  determineNewParentId,
284
281
  emptyScreenMapping,
@@ -345,16 +342,15 @@ export {
345
342
  default107 as useTrashedResource,
346
343
  useTreeSortable,
347
344
  useTreeView,
348
- default108 as useUiOverride,
349
- default109 as useUpdateMutation,
350
- default110 as useUpload,
351
- default111 as useUploadFiles,
352
- default112 as useUser,
353
- default113 as useWorkspaceFile,
354
- default114 as useWorkspaceFolders,
355
- default115 as useWorkspaceFoldersTree,
356
- default116 as useWorkspaceSearch,
357
- default117 as useXitiTrackPageLoad,
358
- default118 as useZendeskGuide,
345
+ default108 as useUpdateMutation,
346
+ default109 as useUpload,
347
+ default110 as useUploadFiles,
348
+ default111 as useUser,
349
+ default112 as useWorkspaceFile,
350
+ default113 as useWorkspaceFolders,
351
+ default114 as useWorkspaceFoldersTree,
352
+ default115 as useWorkspaceSearch,
353
+ default116 as useXitiTrackPageLoad,
354
+ default117 as useZendeskGuide,
359
355
  wrapTreeNode
360
356
  };
@@ -1,11 +1,9 @@
1
1
  export interface HeaderProps {
2
2
  src: string | undefined;
3
3
  onNotificationsClick?: () => void;
4
- /** Scope this header's CSS theme (`data-product`) to its own subtree, independently of the page's ambient theme. */
5
- dataProduct?: string;
6
4
  }
7
5
  declare const Header: {
8
- ({ src, onNotificationsClick, dataProduct, }: HeaderProps): JSX.Element;
6
+ ({ src, onNotificationsClick, }: HeaderProps): JSX.Element;
9
7
  displayName: string;
10
8
  };
11
9
  export default Header;
@@ -25,8 +25,7 @@ import Avatar from "../../../../components/Avatar/Avatar.js";
25
25
  import { Popover, PopoverBody } from "../../../../components/Popover/Popover.js";
26
26
  const Header = ({
27
27
  src = "",
28
- onNotificationsClick,
29
- dataProduct
28
+ onNotificationsClick
30
29
  }) => {
31
30
  const {
32
31
  t
@@ -48,7 +47,7 @@ const Header = ({
48
47
  } = useEdificeTheme(), hasMessages = messages > 0, [userRef, isUserHovered] = useHover(), popoverUserId = useId(), handleNotificationsClick = () => {
49
48
  onNotificationsClick == null || onNotificationsClick();
50
49
  };
51
- return /* @__PURE__ */ jsx("header", { className: classes, "data-product": dataProduct, children: /* @__PURE__ */ jsxs(Navbar, { className: "px-24", children: [
50
+ return /* @__PURE__ */ jsx("header", { className: classes, children: /* @__PURE__ */ jsxs(Navbar, { className: "px-24", children: [
52
51
  /* @__PURE__ */ jsx(LogoBeta, { src: `${src}/img/illustrations/logo.png` }),
53
52
  /* @__PURE__ */ jsxs("ul", { className: "navbar-nav", children: [
54
53
  /* @__PURE__ */ jsx(NavItem, { children: /* @__PURE__ */ jsx(NavLink, { link: "/timeline/timeline", translate: t("navbar.home"), "data-testid": "header-home-button", children: /* @__PURE__ */ jsx(SvgIconHomeBeta, {}) }) }),
@@ -1,13 +1,12 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
3
- import { useState } from "react";
2
+ import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
4
3
  import { EdificeClientContext } from "../EdificeClientProvider/EdificeClientProvider.context.js";
5
4
  import { EdificeThemeContext } from "../EdificeThemeProvider/EdificeThemeProvider.context.js";
6
5
  import { mockQueryResult, mockSession, mockConf } from "./MockedProvider.mocks.js";
7
- const MockedProvider = ({
6
+ const queryClient = new QueryClient(), MockedProvider = ({
8
7
  children
9
8
  }) => {
10
- const [queryClient] = useState(() => new QueryClient()), themeContextValue = {
9
+ const themeContextValue = {
11
10
  theme: "default",
12
11
  setTheme: vi.fn()
13
12
  }, clientContextValue = {
@@ -0,0 +1,10 @@
1
+ import { StoreApi, UseBoundStore } from 'zustand';
2
+ type WithSelectors<S> = S extends {
3
+ getState: () => infer T;
4
+ } ? S & {
5
+ use: {
6
+ [K in keyof T]: () => T[K];
7
+ };
8
+ } : never;
9
+ export declare const createSelectors: <S extends UseBoundStore<StoreApi<object>>>(_store: S) => WithSelectors<S>;
10
+ export {};
@@ -1,5 +1,4 @@
1
1
  export * from './check-user-rights';
2
- export * from './create-selectors';
3
2
  export * from './emptyscreen-mapping';
4
3
  export * from './react-query';
5
4
  export * from './refs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.0-develop-enabling.20260720144517",
3
+ "version": "2.6.0-develop-pedago.20260721150256",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -140,9 +140,9 @@
140
140
  "swiper": "10.1.0",
141
141
  "ua-parser-js": "1.0.36",
142
142
  "zustand": "4.5.7",
143
- "@edifice.io/bootstrap": "2.6.0-develop-enabling.20260720144517",
144
- "@edifice.io/utilities": "2.6.0-develop-enabling.20260720144517",
145
- "@edifice.io/tiptap-extensions": "2.6.0-develop-enabling.20260720144517"
143
+ "@edifice.io/bootstrap": "2.6.0-develop-pedago.20260721150256",
144
+ "@edifice.io/tiptap-extensions": "2.6.0-develop-pedago.20260721150256",
145
+ "@edifice.io/utilities": "2.6.0-develop-pedago.20260721150256"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/plugin-transform-react-pure-annotations": "7.27.1",
@@ -173,8 +173,8 @@
173
173
  "vite": "5.4.14",
174
174
  "vite-plugin-dts": "4.5.4",
175
175
  "vite-tsconfig-paths": "5.1.4",
176
- "@edifice.io/client": "2.6.0-develop-enabling.20260720144517",
177
- "@edifice.io/config": "2.6.0-develop-enabling.20260720144517"
176
+ "@edifice.io/client": "2.6.0-develop-pedago.20260721150256",
177
+ "@edifice.io/config": "2.6.0-develop-pedago.20260721150256"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "@react-spring/web": "9.7.5",
@@ -1,5 +0,0 @@
1
- declare const HeaderNotificationsOverlay: {
2
- (): import("react/jsx-runtime").JSX.Element;
3
- displayName: string;
4
- };
5
- export default HeaderNotificationsOverlay;
@@ -1,18 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { NotificationListContainer } from "../../../modules/homepage/components/Notifications/NotificationListContainer.js";
3
- import PageLayoutOverlay from "../../PageLayout/components/PageLayoutOverlay.js";
4
- import { useOverlay } from "../../PageLayout/hook/useOverlay.js";
5
- const HeaderNotificationsOverlay = () => {
6
- const {
7
- isOverlayOpen,
8
- updateOverlayOpen
9
- } = useOverlay(), handleClose = () => updateOverlayOpen(!1);
10
- return (
11
- // NotificationList renders its own header with a close button, so
12
- // PageLayoutOverlay's default close button would be redundant (double X).
13
- /* @__PURE__ */ jsx(PageLayoutOverlay, { onClose: handleClose, closeButton: !1, children: isOverlayOpen && /* @__PURE__ */ jsx(NotificationListContainer, { onCloseNotifications: handleClose }) })
14
- );
15
- };
16
- export {
17
- HeaderNotificationsOverlay as default
18
- };
@@ -1 +0,0 @@
1
- export { default as useUiOverride } from './useUiOverride';
@@ -1,5 +0,0 @@
1
- /** Read the platform-driven UI override registered under `key` in the theme-conf, normalized to an object form. */
2
- export default function useUiOverride(key: string): {
3
- variant: string;
4
- theme?: string;
5
- } | undefined;
@@ -1,13 +0,0 @@
1
- import { useEdificeTheme } from "../../providers/EdificeThemeProvider/EdificeThemeProvider.hook.js";
2
- function useUiOverride(key) {
3
- var _a;
4
- const {
5
- theme
6
- } = useEdificeTheme(), raw = (_a = theme == null ? void 0 : theme.uiOverrides) == null ? void 0 : _a[key];
7
- return typeof raw == "string" ? {
8
- variant: raw
9
- } : raw;
10
- }
11
- export {
12
- useUiOverride as default
13
- };
@@ -1,37 +0,0 @@
1
- import { StoreApi, UseBoundStore } from 'zustand';
2
- type WithSelectors<S> = S extends {
3
- getState: () => infer T;
4
- } ? S & {
5
- use: {
6
- [K in keyof T]: () => T[K];
7
- };
8
- } : never;
9
- /**
10
- * Augments a Zustand store with auto-generated, per-field selector hooks,
11
- * so consumers can call `store.use.myValue()` instead of
12
- * `store((s) => s.myValue)` and never forget a selector.
13
- *
14
- * Pattern from the Zustand docs:
15
- * https://zustand.docs.pmnd.rs/guides/auto-generating-selectors
16
- *
17
- * @param _store - The bound store to augment.
18
- * @returns The same store instance, mutated with a `use` object exposing one
19
- * selector hook per state key.
20
- *
21
- * @remarks
22
- * - The store is mutated in place; the returned reference is the input store.
23
- * - Selectors are generated once, from the keys present at call time. Fields
24
- * added to the state later won't get a `use.<key>` selector.
25
- *
26
- * @example
27
- * ```ts
28
- * const useBearStore = createSelectors(
29
- * create<BearState>(() => ({ bears: 0 })),
30
- * );
31
- *
32
- * // In a component:
33
- * const bears = useBearStore.use.bears();
34
- * ```
35
- */
36
- export declare const createSelectors: <S extends UseBoundStore<StoreApi<object>>>(_store: S) => WithSelectors<S>;
37
- export {};
@@ -1 +0,0 @@
1
- export * from './create-selectors';