@caspeco/casper-ui-library 7.5.0 → 7.6.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.
@@ -5,5 +5,5 @@ import { ToggleButtonProps } from './types.js';
5
5
  * @see Toggle button role on MDN: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#toggle_buttons
6
6
  * @see Docs https://caspeco.github.io/casper-ui-library/components/toggle-button
7
7
  */
8
- export declare function ToggleButton({ isPressed, children, ...props }: ToggleButtonProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ToggleButton(props: ToggleButtonProps): import("react/jsx-runtime").JSX.Element;
9
9
  //# sourceMappingURL=toggle-button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../lib/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,SAAiB,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,2CAMxF"}
1
+ {"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../lib/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAUpD"}
@@ -1,8 +1,10 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { Button as n } from "@chakra-ui/react";
3
- function p({ isPressed: t = !1, children: o, ...r }) {
4
- return /* @__PURE__ */ e(n, { "aria-pressed": t, type: "button", variant: "toggle", ...r, children: o });
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { Button as s } from "@chakra-ui/react";
3
+ import { useButtonChildren as i } from "./use-button-children.js";
4
+ function c(t) {
5
+ const { isPressed: r = !1, subText: u, children: l, ...e } = t, o = i(t);
6
+ return /* @__PURE__ */ n(s, { "aria-pressed": r, type: "button", variant: "toggle", ...e, children: o });
5
7
  }
6
8
  export {
7
- p as ToggleButton
9
+ c as ToggleButton
8
10
  };
@@ -1,13 +1,30 @@
1
1
  import { CustomChakraBoxProps, LayoutProps, MarginProps, PaddingProps } from '../../theme/index.js';
2
2
  import { ButtonProps as ChakraButtonProps, ResponsiveValue } from '@chakra-ui/react';
3
3
  type CustomStyleProps = CustomChakraBoxProps & LayoutProps & MarginProps & PaddingProps;
4
- type CustomProperties = {
5
- /** Indicate wether button is pressed or not. Defaults to false. */
4
+ type ToggleButtonPropsBase = {
5
+ /** Indicate whether button is pressed or not. Defaults to false. */
6
6
  isPressed?: boolean;
7
7
  /** The size of the button, default: md */
8
8
  size?: ResponsiveValue<"lg" | "sm" | "md"> | undefined;
9
+ } & Pick<ChakraButtonProps, "children" | "isDisabled" | "onClick" | "type"> & CustomStyleProps;
10
+ type ToggleButtonPropsWithSubText = ToggleButtonPropsBase & {
11
+ /**
12
+ * Adds a subtext below the button text.
13
+ * Does not work for sm size.
14
+ * When subText is provided, aria-label is required for accessibility
15
+ * since the button content will be hidden from screen readers.
16
+ */
17
+ subText: string;
18
+ /**
19
+ * Accessible label for the button. Required when using subText
20
+ * since the button content will be aria-hidden.
21
+ */
22
+ "aria-label": string;
9
23
  };
10
- type ChakraButtonProperties = Pick<ChakraButtonProps, "children" | "isDisabled" | "onClick" | "type">;
11
- export type ToggleButtonProps = CustomProperties & ChakraButtonProperties & CustomStyleProps;
24
+ type ToggleButtonPropsWithoutSubText = ToggleButtonPropsBase & {
25
+ subText?: never;
26
+ "aria-label"?: string;
27
+ };
28
+ export type ToggleButtonProps = ToggleButtonPropsWithSubText | ToggleButtonPropsWithoutSubText;
12
29
  export {};
13
30
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/toggle-button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1F,KAAK,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;AAExF,KAAK,gBAAgB,GAAG;IACvB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,eAAe,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CACvD,CAAC;AAEF,KAAK,sBAAsB,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;AAEtG,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,sBAAsB,GAAG,gBAAgB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/components/toggle-button/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE1F,KAAK,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;AAExF,KAAK,qBAAqB,GAAG;IAC5B,oEAAoE;IACpE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,eAAe,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;CACvD,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC,GAC1E,gBAAgB,CAAC;AAElB,KAAK,4BAA4B,GAAG,qBAAqB,GAAG;IAC3D;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,+BAA+B,GAAG,qBAAqB,GAAG;IAC9D,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG,4BAA4B,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { ToggleButtonProps } from './types.js';
3
+ /**
4
+ * Custom hook that returns the children elements for the button, including subText if applicable.
5
+ * For responsive size values, dynamically shows/hides subText based on the current breakpoint.
6
+ * @returns If subText is provided and the current size is allowed, returns a container with the main text and subText. Otherwise it returns just the children.
7
+ */
8
+ export declare function useButtonChildren(props: ToggleButtonProps): ReactNode;
9
+ //# sourceMappingURL=use-button-children.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-button-children.d.ts","sourceRoot":"","sources":["../../../lib/components/toggle-button/use-button-children.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAoCrE"}
@@ -0,0 +1,27 @@
1
+ import { jsxs as a, jsx as o } from "react/jsx-runtime";
2
+ import { useBreakpointValue as u, Flex as d, Text as r } from "@chakra-ui/react";
3
+ import { ThemeFontSizeVariable as f } from "../../theme/theme-types.js";
4
+ const m = ["md", "lg"];
5
+ function T(s) {
6
+ const { size: l, children: t, subText: n } = s, e = l ?? "md", i = u(
7
+ typeof e == "string" || e === void 0 ? { base: e } : e,
8
+ { ssr: !1 }
9
+ ), c = i && m.includes(i);
10
+ return n && c ? /* @__PURE__ */ a(d, { "aria-hidden": "true", flexDirection: "column", alignItems: "center", overflow: "hidden", children: [
11
+ /* @__PURE__ */ o(r, { children: t }),
12
+ /* @__PURE__ */ o(
13
+ r,
14
+ {
15
+ fontSize: f.XSmall,
16
+ textOverflow: "ellipsis",
17
+ whiteSpace: "nowrap",
18
+ overflow: "hidden",
19
+ width: "100%",
20
+ children: n
21
+ }
22
+ )
23
+ ] }) : t;
24
+ }
25
+ export {
26
+ T as useButtonChildren
27
+ };
@@ -1,16 +1,6 @@
1
1
  import * as o from "react";
2
2
  import { createTable as u } from "../../../table-core/build/lib/index.js";
3
3
  import { ColumnFaceting as C, ColumnFiltering as S, ColumnGrouping as w, ColumnOrdering as b, ColumnPinning as y, ColumnSizing as F, ColumnVisibility as x, GlobalFaceting as h, GlobalFiltering as O, Headers as E, RowExpanding as M, RowPagination as v, RowPinning as G, RowSelection as P, RowSorting as $, _getVisibleLeafColumns as A, aggregationFns as H, buildHeaderGroups as V, createCell as j, createColumn as k, createColumnHelper as z, createRow as N, defaultColumnSizing as T, expandRows as U, filterFns as _, flattenBy as B, functionalUpdate as L, getCoreRowModel as q, getExpandedRowModel as D, getFilteredRowModel as I, getMemoOptions as J, getSortedRowModel as K, isFunction as Q, isNumberArray as W, isRowSelected as X, isSubRowSelected as Y, makeStateUpdater as Z, memo as ee, orderColumns as te, passiveEventSupported as ne, reSplitAlphaNumeric as oe, selectRowsFn as re, shouldAutoRemoveFilter as ae, sortingFns as ie } from "../../../table-core/build/lib/index.js";
4
- /**
5
- * react-table
6
- *
7
- * Copyright (c) TanStack
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE.md file in the root directory of this source tree.
11
- *
12
- * @license MIT
13
- */
14
4
  function f(e, t) {
15
5
  return e ? s(e) ? /* @__PURE__ */ o.createElement(e, t) : e : null;
16
6
  }
@@ -1,13 +1,3 @@
1
- /**
2
- * table-core
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
1
  function ot() {
12
2
  return {
13
3
  accessor: (e, o) => typeof e == "function" ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspeco/casper-ui-library",
3
- "version": "7.5.0",
3
+ "version": "7.6.0",
4
4
  "prettier": "@caspeco/prettier-config",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@arethetypeswrong/cli": "^0.18.2",
31
- "@caspeco/eslint-config": "^4.1.1",
31
+ "@caspeco/eslint-config-react": "^5.0.0",
32
32
  "@caspeco/prettier-config": "^1.0.7",
33
- "@eslint/js": "^9.39.0",
33
+ "@eslint/js": "^9.39.1",
34
34
  "@testing-library/jest-dom": "^6.9.1",
35
35
  "@testing-library/react": "^16.3.0",
36
36
  "@testing-library/user-event": "^14.6.1",
@@ -38,19 +38,19 @@
38
38
  "@types/node": "^24.10.0",
39
39
  "@types/react": "^18.3.12",
40
40
  "@types/react-dom": "^18.3.1",
41
- "@vitejs/plugin-react-swc": "^4.2.0",
42
- "eslint": "^9.39.0",
41
+ "@vitejs/plugin-react-swc": "^4.2.1",
42
+ "eslint": "^9.39.1",
43
43
  "eslint-plugin-react-hooks": "^7.0.1",
44
44
  "eslint-plugin-react-refresh": "^0.4.24",
45
45
  "globals": "^16.5.0",
46
46
  "jsdom": "^27.1.0",
47
47
  "tsc-alias": "^1.8.16",
48
48
  "typescript": "~5.9.3",
49
- "typescript-eslint": "^8.46.2",
50
- "vite": "^7.1.12",
49
+ "typescript-eslint": "^8.46.3",
50
+ "vite": "^7.2.2",
51
51
  "vite-plugin-dts": "^4.5.4",
52
52
  "vite-tsconfig-paths": "^5.1.4",
53
- "vitest": "^4.0.6"
53
+ "vitest": "^4.0.8"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@chakra-ui/react": "^2.8.2",