@phillips/seldon 1.87.0 → 1.88.1

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,5 +1,6 @@
1
1
  import { AccordionVariantKey } from './types';
2
- import { default as React } from 'react';
2
+ import { default as React, ComponentProps } from 'react';
3
+ import * as Accordion from '@radix-ui/react-accordion';
3
4
  export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
4
5
  /**
5
6
  * Unique id for component testing
@@ -16,6 +17,14 @@ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
16
17
  * Child element pass in to display as item content.
17
18
  */
18
19
  children?: React.ReactNode;
20
+ /**
21
+ * Optionally control the expanded state of the accordion items.
22
+ */
23
+ value?: ComponentProps<typeof Accordion.Root>['value'];
24
+ /**
25
+ * Callback function to be called when the expanded state of the items change.
26
+ */
27
+ onValueChanged?: ComponentProps<typeof Accordion.Root>['onValueChange'];
19
28
  }
20
29
  /**
21
30
  * ## Overview
@@ -26,5 +35,5 @@ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
26
35
  *
27
36
  * [Storybook Link](https://phillips-seldon.netlify.app/?path=/docs/components-accordion--overview)
28
37
  */
29
- declare const AccordionComponent: ({ className, children, ...props }: AccordionProps) => import("react/jsx-runtime").JSX.Element;
38
+ declare const AccordionComponent: React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<HTMLDivElement>>;
30
39
  export default AccordionComponent;
@@ -1,21 +1,31 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import c from "../../node_modules/classnames/index.js";
3
- import { getCommonProps as i } from "../../utils/index.js";
4
- import { Root as e } from "../../node_modules/@radix-ui/react-accordion/dist/index.js";
5
- import { getAccordionVariantProps as d } from "./utils.js";
6
- const N = ({ className: m, children: t, ...o }) => {
7
- const { className: a, ...r } = i(o, "Accordion"), n = d(o.variant);
8
- return /* @__PURE__ */ s(
9
- e,
10
- {
11
- className: c(`${a}`, m),
12
- ...r,
13
- ...n,
14
- id: o == null ? void 0 : o.id,
15
- children: t
16
- }
17
- );
18
- };
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { forwardRef as f } from "react";
3
+ import l from "../../node_modules/classnames/index.js";
4
+ import { getCommonProps as A } from "../../utils/index.js";
5
+ import { Root as C } from "../../node_modules/@radix-ui/react-accordion/dist/index.js";
6
+ import { getAccordionVariantProps as N } from "./utils.js";
7
+ const P = f(
8
+ ({ className: r, children: a, variant: t, value: m, onValueChanged: n, ...o }, s) => {
9
+ const { className: c, ...i } = A(o, "Accordion"), e = N(t, m);
10
+ return (
11
+ // @ts-expect-error radix-ui type checking is too aggressive ans we know the values are valid
12
+ /* @__PURE__ */ d(
13
+ C,
14
+ {
15
+ className: l(`${c}`, r),
16
+ ...i,
17
+ ...e,
18
+ id: o == null ? void 0 : o.id,
19
+ ref: s,
20
+ value: m,
21
+ onValueChange: n,
22
+ children: a
23
+ }
24
+ )
25
+ );
26
+ }
27
+ );
28
+ P.displayName = "Accordion";
19
29
  export {
20
- N as default
30
+ P as default
21
31
  };
@@ -3,10 +3,7 @@ import { AccordionItemProps } from './AccordionItem';
3
3
  import { AccordionVariants } from './types';
4
4
  declare const meta: {
5
5
  title: string;
6
- component: ({ className, children, ...props }: AccordionProps) => import("react/jsx-runtime").JSX.Element;
7
- args: {
8
- transitionTimeInMs: number;
9
- };
6
+ component: import('react').ForwardRefExoticComponent<AccordionProps & import('react').RefAttributes<HTMLDivElement>>;
10
7
  argTypes: {
11
8
  variant: {
12
9
  options: AccordionVariants[];
@@ -20,3 +17,6 @@ export default meta;
20
17
  export declare const AccordionLarge: ({ transitionTimeInMs, ...props }: AccordionProps & AccordionItemProps) => import("react/jsx-runtime").JSX.Element;
21
18
  export declare const AccordionSmall: ({ transitionTimeInMs, ...props }: AccordionProps & AccordionItemProps) => import("react/jsx-runtime").JSX.Element;
22
19
  export declare const AccordionSubmenu: ({ transitionTimeInMs, ...props }: AccordionProps & AccordionItemProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const ControlledAccordion: ({ items, ...props }: AccordionProps & {
21
+ items: AccordionItemProps[];
22
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { AccordionMultipleProps, AccordionSingleProps } from '@radix-ui/react-accordion';
1
2
  export interface AccordionHeaderType {
2
3
  /**
3
4
  * Child element pass in to display as header label.
@@ -52,15 +53,11 @@ export declare enum AccordionVariants {
52
53
  singleNonCollapsible = "singleNonCollapsible"
53
54
  }
54
55
  export type AccordionVariantKey = keyof typeof AccordionVariants;
55
- export declare enum AccordionType {
56
- single = "single",
57
- multiple = "multiple"
58
- }
59
56
  export interface AccordionVariantProps {
60
57
  /**
61
58
  * Determines whether multiple elements can be opened at the same time or not.
62
59
  */
63
- type: AccordionType;
60
+ type: AccordionSingleProps['type'] | AccordionMultipleProps['type'];
64
61
  /**
65
62
  * Determines if an open element can be closed by clicking on it.
66
63
  * Only applicable to the `single` variants.
@@ -1,6 +1,5 @@
1
- var e = /* @__PURE__ */ ((l) => (l.multiple = "multiple", l.singleCollapsible = "singleCollapsible", l.singleNonCollapsible = "singleNonCollapsible", l))(e || {}), s = /* @__PURE__ */ ((l) => (l.single = "single", l.multiple = "multiple", l))(s || {}), g = /* @__PURE__ */ ((l) => (l.lg = "lg", l.sm = "sm", l))(g || {});
1
+ var e = /* @__PURE__ */ ((l) => (l.multiple = "multiple", l.singleCollapsible = "singleCollapsible", l.singleNonCollapsible = "singleNonCollapsible", l))(e || {}), s = /* @__PURE__ */ ((l) => (l.lg = "lg", l.sm = "sm", l))(s || {});
2
2
  export {
3
- g as AccordionItemVariant,
4
- s as AccordionType,
3
+ s as AccordionItemVariant,
5
4
  e as AccordionVariants
6
5
  };
@@ -1,9 +1,10 @@
1
- import { AccordionVariantKey, AccordionVariantProps } from './types';
1
+ import { AccordionVariantKey } from './types';
2
+ import { AccordionMultipleProps, AccordionSingleProps } from '@radix-ui/react-accordion';
2
3
  /**
3
4
  * Sets the type and collapsible props based on the variant prop
4
5
  * The collapsible prop should only be passed when the variant is single
5
6
  */
6
- export declare const getAccordionVariantProps: (variant?: AccordionVariantKey) => AccordionVariantProps;
7
+ export declare const getAccordionVariantProps: (variant?: AccordionVariantKey, value?: string[] | string) => AccordionSingleProps | AccordionMultipleProps;
7
8
  /**
8
9
  * A helper for getting the classes of the Accordion icons
9
10
  * @param className - The className of the component
@@ -1,12 +1,12 @@
1
- import s from "../../node_modules/classnames/index.js";
2
- import { AccordionType as l, AccordionVariants as e } from "./types.js";
3
- const c = (i) => {
4
- const o = { type: l.multiple };
5
- return i === e.singleCollapsible && (o.type = l.single, o.collapsible = !0), i === e.singleNonCollapsible && (o.type = l.single, o.collapsible = !1), o;
6
- }, p = (i, o, n) => s(`${i}__icon`, `${i}-${n}__icon`, {
7
- [`${i}__icon--lg`]: o
1
+ import i from "../../node_modules/classnames/index.js";
2
+ import { AccordionVariants as n } from "./types.js";
3
+ const t = (o, e) => {
4
+ const r = { type: "multiple" };
5
+ return (o === n.singleCollapsible || o === n.singleNonCollapsible) && Array.isArray(e) && console.error("The value prop should not be an array when using a single variant"), o === n.singleCollapsible ? { type: "single" } : o === n.singleNonCollapsible ? { type: "single" } : r;
6
+ }, p = (o, e, r) => i(`${o}__icon`, `${o}-${r}__icon`, {
7
+ [`${o}__icon--lg`]: e
8
8
  });
9
9
  export {
10
- c as getAccordionVariantProps,
10
+ t as getAccordionVariantProps,
11
11
  p as getIconClasses
12
12
  };
@@ -27,7 +27,7 @@ const ne = ({
27
27
  ...x
28
28
  }) => {
29
29
  var N;
30
- const { className: r, "data-testid": m, ...L } = j(x, "Search"), p = c.useContext(U), f = c.useRef(null), h = c.useRef(null), g = c.useRef(null), a = p.isSearchExpanded, s = (N = f.current) == null ? void 0 : N.value, T = S ? (e) => {
30
+ const { className: r, "data-testid": m, ...L } = j(x, "Search"), f = c.useContext(U), p = c.useRef(null), h = c.useRef(null), g = c.useRef(null), a = f.isSearchExpanded, s = (N = p.current) == null ? void 0 : N.value, T = S ? (e) => {
31
31
  S(e.target.value);
32
32
  } : void 0;
33
33
  M(g, (e) => {
@@ -38,22 +38,22 @@ const ne = ({
38
38
  if (e.stopPropagation(), e.key === "Enter") {
39
39
  if (e.preventDefault(), s && s.length > 2) {
40
40
  const y = I(v(s));
41
- window.location.href = y;
41
+ n(!1), window.location.href = y;
42
42
  }
43
- e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.click();
43
+ e.currentTarget instanceof HTMLAnchorElement && (n(!1), e.currentTarget.click());
44
44
  }
45
- e.key === "Escape" && ((o = h.current) == null || o.reset(), p.setIsSearchExpanded(!1));
45
+ e.key === "Escape" && ((o = h.current) == null || o.reset(), f.setIsSearchExpanded(!1));
46
46
  };
47
47
  V(() => {
48
48
  var e;
49
49
  if (a) {
50
- (e = f.current) == null || e.focus();
50
+ (e = p.current) == null || e.focus();
51
51
  return;
52
52
  }
53
53
  }, [a]);
54
54
  const n = (e) => {
55
55
  var o;
56
- (o = h.current) == null || o.reset(), p.setIsSearchExpanded(e);
56
+ (o = h.current) == null || o.reset(), f.setIsSearchExpanded(e);
57
57
  };
58
58
  return /* @__PURE__ */ t("div", { className: `${r}__container`, children: /* @__PURE__ */ u(
59
59
  "div",
@@ -113,7 +113,7 @@ const ne = ({
113
113
  invalidText: k,
114
114
  onKeyDown: $,
115
115
  onChange: T,
116
- ref: f
116
+ ref: p
117
117
  }
118
118
  )
119
119
  }
@@ -1,4 +1,4 @@
1
- import { __module as t } from "../../_virtual/index5.js";
1
+ import { __module as t } from "../../_virtual/index6.js";
2
2
  /*!
3
3
  Copyright (c) 2015 Jed Watson.
4
4
  Based on code that is Copyright 2013-2015, Facebook, Inc.
@@ -1,4 +1,4 @@
1
- import { __module as e } from "../../../../_virtual/index6.js";
1
+ import { __module as e } from "../../../../_virtual/index5.js";
2
2
  import { __require as o } from "./cjs/react-is.production.min.js";
3
3
  import { __require as t } from "./cjs/react-is.development.js";
4
4
  var r;
@@ -14,8 +14,9 @@ $lg: #{$px}-input--lg;
14
14
  }
15
15
 
16
16
  &__label {
17
+ @include text($string2);
18
+
17
19
  color: $pure-black;
18
- font-size: 0.75rem;
19
20
  font-variation-settings: 'wght' 600;
20
21
  margin-bottom: 0.5rem;
21
22
  word-break: break-word;
@@ -47,7 +48,7 @@ $lg: #{$px}-input--lg;
47
48
  -webkit-box-orient: vertical;
48
49
  display: -webkit-box;
49
50
  -webkit-line-clamp: 2;
50
- line-height: 1.25;
51
+ line-height: $spacing-md;
51
52
  overflow: hidden;
52
53
  }
53
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.87.0",
3
+ "version": "1.88.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"