@wix/editor-react-components 1.2768.0 → 1.2770.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.
Files changed (35) hide show
  1. package/dist/site/components/AccordionComponent/AccordionItem.d.ts +1 -0
  2. package/dist/site/components/AccordionComponent/component.js +58 -4
  3. package/dist/site/components/AccordionComponent/css.css +1 -0
  4. package/dist/site/components/AccordionComponent/hooks.d.ts +5 -0
  5. package/dist/site/components/AccordionComponent/manifest.js +6 -2
  6. package/dist/site/components/AudioPlayer/component.js +2 -2
  7. package/dist/site/components/Breadcrumbs/component.js +1 -1
  8. package/dist/site/components/DatePicker/DatePicker.types.d.ts +20 -76
  9. package/dist/site/components/DatePicker/component.js +232 -1240
  10. package/dist/site/components/DatePicker/components/DatePickerCalendar.d.ts +3 -2
  11. package/dist/site/components/DatePicker/components/DatePickerField.d.ts +1 -3
  12. package/dist/site/components/DatePicker/constants.d.ts +47 -79
  13. package/dist/site/components/DatePicker/css.css +60 -287
  14. package/dist/site/components/DatePicker/datePickerUtils.d.ts +8 -26
  15. package/dist/site/components/DatePicker/manifest.js +234 -207
  16. package/dist/site/components/Menu/component.js +1 -4
  17. package/dist/site/components/Menu/components/MenuContent/MenuItem/updateDropdownDomStyles.d.ts +0 -1
  18. package/dist/site/components/Repeater/component.js +6 -6
  19. package/dist/site/components/TextInput/component.js +2 -2
  20. package/dist/site/components/TimePicker/component.js +350 -3
  21. package/dist/site/components/chunks/Button.js +2 -2
  22. package/dist/site/components/chunks/{DismissSmall.js → DateField.js} +56 -430
  23. package/dist/site/components/chunks/Group.js +44 -44
  24. package/dist/site/components/chunks/I18nProvider.js +1 -1
  25. package/dist/site/components/chunks/Input.js +3 -26
  26. package/dist/site/components/chunks/VisuallyHidden.js +1 -1
  27. package/dist/site/components/chunks/constants37.js +59 -90
  28. package/dist/site/components/chunks/filterDOMProps.js +11 -11
  29. package/dist/site/components/chunks/getWixBannerHeight.js +7 -0
  30. package/package.json +3 -3
  31. package/dist/site/components/DatePicker/components/DatePickerLabel.d.ts +0 -8
  32. package/dist/site/components/DatePicker/components/DatePickerTooltip.d.ts +0 -5
  33. package/dist/site/components/DatePicker/hooks/useDateConstraints.d.ts +0 -12
  34. package/dist/site/components/DatePicker/hooks/useDatePickerValue.d.ts +0 -15
  35. package/dist/site/components/DatePicker/hooks/useUnavailableDates.d.ts +0 -3
@@ -7,6 +7,7 @@ export interface AccordionItemProps {
7
7
  isOpen?: boolean;
8
8
  titleHtmlTag?: string;
9
9
  elementProps?: AccordionElementProps;
10
+ triggerRef?: React.Ref<HTMLButtonElement>;
10
11
  }
11
12
  declare const AccordionItem: React.FC<AccordionItemProps>;
12
13
  export default AccordionItem;
@@ -1,12 +1,15 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import React__default, { useRef, useEffect, useMemo, useState, useCallback } from "react";
3
+ import React__default, { useRef, useEffect, useMemo, useState, useCallback, useLayoutEffect } from "react";
4
4
  import "react-dom";
5
5
  import { c as clsx } from "../chunks/clsx.js";
6
6
  import AnimatedIconWithReducedMotion from "../AnimatedIcon/component.js";
7
7
  import { D as DesignStates, a as DEFAULT_PROPS } from "../chunks/constants43.js";
8
8
  import { g as getDefaultExportFromCjs } from "../chunks/_commonjsHelpers.js";
9
9
  import { r as require_baseGetTag, d as require_root, b as require_Symbol, c as requireIsArray, a as requireIsObjectLike, e as require_freeGlobal } from "../chunks/isObjectLike.js";
10
+ import { useService } from "@wix/services-manager-react";
11
+ import { E as EnvironmentDefinition } from "../chunks/index2.js";
12
+ import { g as getWixBannerHeight } from "../chunks/getWixBannerHeight.js";
10
13
  import { d as directionStyles } from "../chunks/direction.module.js";
11
14
  var isObject_1;
12
15
  var hasRequiredIsObject;
@@ -2515,7 +2518,7 @@ const styles = {
2515
2518
  };
2516
2519
  const AccordionItem = (props) => {
2517
2520
  var _a, _b, _c, _d, _e;
2518
- const { item, isOpen, titleHtmlTag, elementProps } = props;
2521
+ const { item, isOpen, titleHtmlTag, elementProps, triggerRef } = props;
2519
2522
  const { animatedIcon: animatedIconProps } = elementProps ?? {};
2520
2523
  const animatedIconRef = useRef(null);
2521
2524
  const isInitialRender = useRef(true);
@@ -2548,6 +2551,7 @@ const AccordionItem = (props) => {
2548
2551
  /* @__PURE__ */ jsx(Header, { asChild: true, children: /* @__PURE__ */ jsx(HeaderTag, { children: /* @__PURE__ */ jsxs(
2549
2552
  Trigger2,
2550
2553
  {
2554
+ ref: triggerRef,
2551
2555
  className: clsx(
2552
2556
  "item-title",
2553
2557
  styles["accordion-header"],
@@ -2687,6 +2691,51 @@ function useAccordionState(items, defaultOpen = "none", allowMultipleOpen = fals
2687
2691
  handleValueChange
2688
2692
  };
2689
2693
  }
2694
+ function useScrollToClickedItem(openedItems, onValueChange) {
2695
+ const itemTriggersRef = useRef([]);
2696
+ const itemTriggerRefCallbacksRef = useRef(
2697
+ /* @__PURE__ */ new Map()
2698
+ );
2699
+ const clickedItemIdRef = useRef(void 0);
2700
+ const { reducedMotion } = useService(EnvironmentDefinition);
2701
+ useLayoutEffect(() => {
2702
+ const clickedItemId = clickedItemIdRef.current;
2703
+ clickedItemIdRef.current = void 0;
2704
+ if (clickedItemId === void 0) {
2705
+ return;
2706
+ }
2707
+ const clickedItemTrigger = itemTriggersRef.current[parseInt(clickedItemId, 10)];
2708
+ if (!clickedItemTrigger) {
2709
+ return;
2710
+ }
2711
+ const isTriggerHiddenAboveViewport = clickedItemTrigger.getBoundingClientRect().top < getWixBannerHeight();
2712
+ if (isTriggerHiddenAboveViewport) {
2713
+ clickedItemTrigger.scrollIntoView({
2714
+ block: "start",
2715
+ behavior: reducedMotion ? "instant" : "smooth"
2716
+ });
2717
+ }
2718
+ }, [openedItems, reducedMotion]);
2719
+ const handleClickValueChange = useCallback(
2720
+ (value) => {
2721
+ clickedItemIdRef.current = normalizeAccordionValue(value).find(
2722
+ (id) => !openedItems.includes(id)
2723
+ );
2724
+ onValueChange(value);
2725
+ },
2726
+ [openedItems, onValueChange]
2727
+ );
2728
+ const getItemTriggerRef = useCallback((index) => {
2729
+ const refCallbacks = itemTriggerRefCallbacksRef.current;
2730
+ if (!refCallbacks.has(index)) {
2731
+ refCallbacks.set(index, (element) => {
2732
+ itemTriggersRef.current[index] = element;
2733
+ });
2734
+ }
2735
+ return refCallbacks.get(index);
2736
+ }, []);
2737
+ return { handleClickValueChange, getItemTriggerRef };
2738
+ }
2690
2739
  const AccordionContainer = (props) => {
2691
2740
  var _a, _b;
2692
2741
  const {
@@ -2715,6 +2764,10 @@ const AccordionContainer = (props) => {
2715
2764
  activeItem,
2716
2765
  previewItemContent
2717
2766
  );
2767
+ const { handleClickValueChange, getItemTriggerRef } = useScrollToClickedItem(
2768
+ openedItems,
2769
+ handleValueChange
2770
+ );
2718
2771
  const isMultipleMode = shouldUseMultipleMode(allowMultipleOpen, defaultOpen);
2719
2772
  const conditionalProps = isMultipleMode ? {
2720
2773
  type: "multiple",
@@ -2730,7 +2783,8 @@ const AccordionContainer = (props) => {
2730
2783
  item: { ...item, id: index.toString() },
2731
2784
  isOpen: openedItems.includes(index.toString()),
2732
2785
  titleHtmlTag,
2733
- elementProps
2786
+ elementProps,
2787
+ triggerRef: getItemTriggerRef(index)
2734
2788
  },
2735
2789
  index
2736
2790
  ));
@@ -2755,7 +2809,7 @@ const AccordionContainer = (props) => {
2755
2809
  children: /* @__PURE__ */ jsx(
2756
2810
  Root2,
2757
2811
  {
2758
- onValueChange: handleValueChange,
2812
+ onValueChange: handleClickValueChange,
2759
2813
  ...conditionalProps,
2760
2814
  className: styles["accordion-root"],
2761
2815
  children: accordionChildren
@@ -18,6 +18,7 @@
18
18
  justify-content: space-between;
19
19
  text-align: start;
20
20
  border-color: #000000;
21
+ scroll-margin-top: var(--wix-ads-height, 0px);
21
22
  }
22
23
  .accordion-header__eNiKz:hover .accordion-item-label__w-z9o, .accordion-header__eNiKz[data-state=open] .accordion-item-label__w-z9o, .accordion-header__eNiKz.accordion-component__item-title--hover .accordion-item-label__w-z9o, .accordion-header__eNiKz.accordion-component__item-title--selected .accordion-item-label__w-z9o {
23
24
  text-decoration: underline;
@@ -1,5 +1,10 @@
1
+ import { RefCallback } from 'react';
1
2
  import { AccordionItem, AccordionContainerProps } from './types';
2
3
  export declare function useAccordionState(items: Array<AccordionItem>, defaultOpen?: AccordionContainerProps['defaultOpen'], allowMultipleOpen?: boolean, activeItem?: number, previewItemContent?: boolean): {
3
4
  openedItems: string[];
4
5
  handleValueChange: (value: Array<string> | string) => void;
5
6
  };
7
+ export declare function useScrollToClickedItem(openedItems: Array<string>, onValueChange: (value: Array<string> | string) => void): {
8
+ handleClickValueChange: (value: Array<string> | string) => void;
9
+ getItemTriggerRef: (index: number) => RefCallback<HTMLElement> | undefined;
10
+ };
@@ -354,11 +354,15 @@ const manifest = {
354
354
  componentUrl: "./site/components/AccordionComponent/component.tsx",
355
355
  moduleSpecifier: "@wix/editor-react-components/AccordionComponent",
356
356
  dependencies: {
357
- componentDependencies: ["@wix/editor-react-components/AnimatedIcon"]
357
+ componentDependencies: ["@wix/editor-react-components/AnimatedIcon"],
358
+ serviceDependencies: ["@wix/viewer-service-environment"]
358
359
  }
359
360
  },
360
361
  editor: {
361
- componentUrl: "./site/components/AccordionComponent/component.preview.tsx"
362
+ componentUrl: "./site/components/AccordionComponent/component.preview.tsx",
363
+ dependencies: {
364
+ serviceDependencies: ["@wix/viewer-service-environment"]
365
+ }
362
366
  }
363
367
  },
364
368
  moduleConfiguration: {
@@ -9,8 +9,8 @@ import Image3 from "../Image3/component.js";
9
9
  import { A as ARIA_LABELS, s as selectors, d as dataDefaults } from "../chunks/constants42.js";
10
10
  import { c as commonjsGlobal } from "../chunks/_commonjsHelpers.js";
11
11
  import { g as $cbf007e418543821$export$b0d6fa1ab32e3295, h as $cbf007e418543821$export$16a4697467175487, a as $1dfb119a85e764e5$export$cc77c4ff7e8673c5, c as $240e9101ba2842f5$export$7d15b64cf5a3a4c4, i as $240e9101ba2842f5$export$cb6e0bb50bc19463, $ as $d2b4bc8c273e7be6$export$353f5b6fc5456de1 } from "../chunks/Button.js";
12
- import { b as $64fa3d84918910a7$export$29f1550f4b0d4415, d as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, f as $64fa3d84918910a7$export$4d86445c2cf5e3, g as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, h as $64fa3d84918910a7$export$2881499e37b75b9a, c as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../chunks/filterDOMProps.js";
13
- import { m as $48a7d519b337145d$export$4eaf04e54aa8eed6, n as $fe16bffc7a557bf0$export$7f54fc3180508a52, l as $d447af545b77c9f1$export$f21a1ffae260145a, f as $23f2114a1b82827e$export$e58f029f0fbfdb29, S as $0beb20c9744a2065$export$8467354a121f1b9f, R as $8f5a2122b0992be3$export$8397ddfc504fdb9a, e as $bbaa08b3cd72f041$export$9d1611c77c2fe928, t as $1969ac565cfec8d0$export$de79e2c695e052f3, U as $8296dad1a4c5e0dc$export$8f71654801c2f7cd, c as $d1116acdf220c2da$export$4c014de7c8940b4c, d as $3274bf1495747a7b$export$5add1d006293d136, b as $3e6197669829fe11$export$40bfa8c7b0832715, g as $01b77f81d0f07f68$export$75b6ee27786ba447, A as $e969f22b6713ca4a$export$ae780daf29e6d456, z as $0c4a58759813079a$export$4e328f61c538687f, $ as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../chunks/Group.js";
12
+ import { c as $64fa3d84918910a7$export$29f1550f4b0d4415, h as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, d as $64fa3d84918910a7$export$4d86445c2cf5e3, e as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, b as $64fa3d84918910a7$export$2881499e37b75b9a, g as $64fa3d84918910a7$export$fabf2dc03a41866e } from "../chunks/filterDOMProps.js";
13
+ import { r as $48a7d519b337145d$export$4eaf04e54aa8eed6, s as $fe16bffc7a557bf0$export$7f54fc3180508a52, q as $d447af545b77c9f1$export$f21a1ffae260145a, k as $23f2114a1b82827e$export$e58f029f0fbfdb29, S as $0beb20c9744a2065$export$8467354a121f1b9f, R as $8f5a2122b0992be3$export$8397ddfc504fdb9a, a as $bbaa08b3cd72f041$export$9d1611c77c2fe928, y as $1969ac565cfec8d0$export$de79e2c695e052f3, U as $8296dad1a4c5e0dc$export$8f71654801c2f7cd, c as $d1116acdf220c2da$export$4c014de7c8940b4c, j as $3274bf1495747a7b$export$5add1d006293d136, i as $3e6197669829fe11$export$40bfa8c7b0832715, l as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $e969f22b6713ca4a$export$ae780daf29e6d456, E as $0c4a58759813079a$export$4e328f61c538687f, g as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4 } from "../chunks/Group.js";
14
14
  import { a as $2eb8e6d23f3d0cb0$export$43bb16f9c6d9e3f7 } from "../chunks/I18nProvider.js";
15
15
  import { $ as $ea3928288112382f$export$439d29a4e110a164 } from "../chunks/VisuallyHidden.js";
16
16
  function $1dfdc54e7eb53ba0$export$36da96379f79f245(props) {
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React__default, { useContext, useState, useRef, useMemo, cloneElement, forwardRef, createContext, useCallback, isValidElement, useEffect } from "react";
3
3
  import { c as clsx } from "../chunks/clsx.js";
4
- import { p as $f39a9eba43920ace$export$8dc98ba7eadeaa56, i as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, $ as $8e9d2fae0ecb9001$export$457c3d6518dd4c6f, b as $64fa3d84918910a7$export$29f1550f4b0d4415, g as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, n as $3ef42575df84b30b$export$9d1611c77c2fe928, c as $64fa3d84918910a7$export$fabf2dc03a41866e, f as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../chunks/filterDOMProps.js";
4
+ import { p as $f39a9eba43920ace$export$8dc98ba7eadeaa56, j as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, a as $8e9d2fae0ecb9001$export$457c3d6518dd4c6f, c as $64fa3d84918910a7$export$29f1550f4b0d4415, e as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, n as $3ef42575df84b30b$export$9d1611c77c2fe928, g as $64fa3d84918910a7$export$fabf2dc03a41866e, d as $64fa3d84918910a7$export$4d86445c2cf5e3 } from "../chunks/filterDOMProps.js";
5
5
  import { $ as $cf2482eff2eeeec2$export$f12b703ca79dfbb1 } from "../chunks/useLocalizedStringFormatter.js";
6
6
  import { createPortal } from "react-dom";
7
7
  import { useService } from "@wix/services-manager-react";
@@ -1,30 +1,14 @@
1
- import { DateValue } from 'react-aria-components';
2
1
  import { A11y, Direction } from '@wix/editor-react-types';
3
- import { SdkFunctionChangeableProps, SdkFunctionFocusableProps } from '../../../utils/functions/sdkFunctionCallbackProps';
4
- import { FieldValidationProps } from '../../../utils/validation/types';
5
- /** Single date or a start–end range. */
6
- export type DatePickerSelectionMode = 'single' | 'range';
7
- /** Smallest editable time unit (React Aria `granularity`). */
8
- export type DatePickerGranularity = 'day' | 'hour' | 'minute';
9
- /** A resolved start–end range for the range calendar (or `null` when unset). */
10
- export type DateRangeValue = {
11
- start: DateValue;
12
- end: DateValue;
13
- } | null;
14
- /**
15
- * One blocked span. `from`/`to` are ISO `YYYY-MM-DD` strings (inclusive); a single
16
- * blocked day sets both to the same date. Comes from the `unavailableDates`
17
- * arrayItems data.
18
- */
19
- export type UnavailableDateRange = {
20
- from?: string;
21
- to?: string;
22
- };
2
+ /** A `localDate` data value: an ISO `YYYY-MM-DD` calendar date with no time or zone. */
3
+ export type LocalDate = string;
23
4
  export type DatePickerElementProps = {
24
5
  label?: {
25
6
  className?: string;
26
7
  };
27
- description?: {
8
+ helperText?: {
9
+ className?: string;
10
+ };
11
+ errorMessage?: {
28
12
  className?: string;
29
13
  };
30
14
  dateInput?: {
@@ -36,79 +20,39 @@ export type DatePickerElementProps = {
36
20
  popover?: {
37
21
  className?: string;
38
22
  };
39
- calendar?: {
23
+ calendarHeader?: {
40
24
  className?: string;
41
25
  };
42
- calendarDay?: {
26
+ weekdays?: {
43
27
  className?: string;
44
28
  };
45
- today?: {
29
+ dates?: {
46
30
  className?: string;
47
31
  };
48
32
  };
49
- export type DatePickerProps = Omit<SdkFunctionChangeableProps, 'onChange'> & SdkFunctionFocusableProps & FieldValidationProps<string> & {
50
- /** Fires with the selected ISO date string (range mode: the start date). */
51
- onChange?: (value: string) => void;
52
- /** Range mode: fires with the selected end date as an ISO string. */
53
- onEndChange?: (value: string) => void;
33
+ export type DatePickerProps = {
54
34
  /** DOM `id` on the root `.datePicker` wrapper. */
55
35
  id: string;
56
36
  /** Appended to the root `.datePicker`. Use this for CSS-variable and per-element overrides. */
57
37
  className: string;
58
- /** Single date or a start–end range. */
59
- selectionMode: DatePickerSelectionMode;
60
- /**
61
- * Smallest editable unit. `day` is date-only; `hour`/`minute` add time
62
- * segments and make the value an ISO datetime (local wall-clock, no zone).
63
- */
64
- granularity?: DatePickerGranularity;
65
- /**
66
- * The selected date as an ISO string — `YYYY-MM-DD`, or `YYYY-MM-DDTHH:MM`
67
- * with time granularity (range mode: the start date). The empty string means
68
- * no date is selected.
69
- */
70
- value: string;
71
- /**
72
- * Range mode only: the end date as an ISO string (`YYYY-MM-DD`, or
73
- * `YYYY-MM-DDTHH:MM` with time granularity).
74
- */
75
- endValue?: string;
76
- /** Uncontrolled initial selected date (ISO string). Used only when `value` is not provided. */
77
- defaultValue?: string;
78
- /** Uncontrolled initial range end date (ISO string). Used only when `endValue` is not provided (range mode). */
79
- defaultEndValue?: string;
38
+ /** The selected date. `undefined` (or an unparseable string) means no date is selected. */
39
+ value?: LocalDate;
40
+ /** Fires with the date the visitor picked, or `undefined` when they cleared it. */
41
+ onValueChange?: (value: LocalDate | undefined) => void;
80
42
  /** Optional text label rendered above the field. */
81
- label: string;
43
+ label?: string;
82
44
  /** Site-facing helper text rendered under the field. */
83
- description?: string;
84
- /** Hint text revealed from an info icon next to the label. */
85
- tooltip?: string;
86
- /** Earliest selectable date as an ISO `YYYY-MM-DD` string. */
87
- minDate?: string;
88
- /** Latest selectable date as an ISO `YYYY-MM-DD` string. */
89
- maxDate?: string;
90
- /**
91
- * Spans that can't be selected — a list of `{ from, to }` ISO date ranges
92
- * (inclusive); a single blocked day sets `from` and `to` to the same date.
93
- * Set via data binding / Velo, not the Settings panel.
94
- */
95
- unavailableDates?: Array<UnavailableDateRange>;
96
- /** When `false`, dates before today can't be selected (clamps min to today). */
97
- allowPastDates?: boolean;
98
- /** When `false`, dates after today can't be selected (clamps max to today). */
99
- allowFutureDates?: boolean;
100
- /** Marks the field required for form submission. */
101
- required?: boolean;
45
+ helperText?: string;
46
+ /** A non-empty message switches the field into the error state and is shown under it. */
47
+ errorMessage?: string;
102
48
  /** Shows the date but blocks editing. */
103
49
  readOnly?: boolean;
104
- /** Renders a clear (✕) control that empties the value. */
105
- clearable?: boolean;
106
50
  /** Disables interaction with the date picker. */
107
- isDisabled?: boolean;
51
+ disabled?: boolean;
108
52
  /** Writing direction applied to the root. */
109
53
  direction?: Direction;
110
54
  /**
111
- * Editor-only: forces the calendar popover open so the Popover/Calendar/Today
55
+ * Editor-only: forces the calendar popover open so the Popover/Dates
112
56
  * design parts are editable on the canvas. Set by the manifest `visibleState`.
113
57
  */
114
58
  previewCalendarOpen?: boolean;