@wonderflow/react-components 3.0.0-beta.25 → 3.0.0-beta.29

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.
@@ -2,14 +2,38 @@ import { MenuItemProps } from '..';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { Except } from 'type-fest';
4
4
  export declare type AutocompleteOptionProps = PropsWithChildren<PropsWithClass> & Except<MenuItemProps, 'padding' | 'autoFocus' | 'description' | 'onClick'> & {
5
+ /**
6
+ * Value of the option.
7
+ * This is the value that will be passed to the `onChange` callback.
8
+ */
5
9
  value: string;
10
+ /**
11
+ * Callback called when the option is clicked.
12
+ * It passes the value and the inner text of the option as arguments.
13
+ */
6
14
  onClick?(value?: string, content?: string): void;
15
+ /**
16
+ * Label of the option. This is the text that will be displayed in the option, which can be
17
+ * different from the value.
18
+ */
7
19
  children: string;
8
20
  };
9
21
  export declare const AutocompleteOption: import("react").ForwardRefExoticComponent<PropsWithClass & {
10
22
  children?: import("react").ReactNode;
11
23
  } & Except<MenuItemProps, "description" | "onClick" | "autoFocus" | "padding"> & {
24
+ /**
25
+ * Value of the option.
26
+ * This is the value that will be passed to the `onChange` callback.
27
+ */
12
28
  value: string;
29
+ /**
30
+ * Callback called when the option is clicked.
31
+ * It passes the value and the inner text of the option as arguments.
32
+ */
13
33
  onClick?(value?: string | undefined, content?: string | undefined): void;
34
+ /**
35
+ * Label of the option. This is the text that will be displayed in the option, which can be
36
+ * different from the value.
37
+ */
14
38
  children: string;
15
39
  } & import("react").RefAttributes<HTMLButtonElement>>;
@@ -2,8 +2,19 @@ import { AutocompleteOptionProps } from './autocomplete-option';
2
2
  import { ForwardRefExoticComponent, ReactNode } from 'react';
3
3
  import { TextfieldProps } from '..';
4
4
  export declare type AutocompleteProps = TextfieldProps & {
5
+ /**
6
+ * The callback called when an option is picked from the list
7
+ */
5
8
  onChange?(value?: string): void;
9
+ /**
10
+ * Set the maximum height of the options list after which
11
+ * it will scroll.
12
+ */
6
13
  maxHeight?: string;
14
+ /**
15
+ * Custom empty message to display when there are no options or
16
+ * when the value does not match any of the options.
17
+ */
7
18
  emptyMessage?: ReactNode;
8
19
  };
9
20
  declare type AutocompleteComponent = ForwardRefExoticComponent<AutocompleteProps> & {
@@ -4,7 +4,7 @@ import { AutocompleteOption } from './autocomplete-option';
4
4
  import { Children, cloneElement, forwardRef, useCallback, useMemo, useRef, useState, useEffect } from 'react';
5
5
  import { useDebounce, useFocusWithin, useKeyPress, useSize } from 'ahooks';
6
6
  import { Text, Menu, Textfield } from '..';
7
- import { Autocomplete as AutocompleteClass, OptionsList } from './autocomplete.module.css';
7
+ import { Autocomplete as AutocompleteClass, OptionsList, PopUp } from './autocomplete.module.css';
8
8
  import { usePopperTooltip } from 'react-popper-tooltip';
9
9
  import { useUIDSeed } from 'react-uid';
10
10
  const AutocompleteAnimation = {
@@ -29,7 +29,7 @@ export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly
29
29
  const seedID = useUIDSeed();
30
30
  const autocompleteRef = useRef(forwardedRef);
31
31
  const [isOpen, setIsOpen] = useState(false);
32
- const [content, setContent] = useState(String(value));
32
+ const [content, setContent] = useState(value ? String(value) : '');
33
33
  const isInteractive = useMemo(() => !disabled && !readOnly, [disabled, readOnly]);
34
34
  const debouncedFieldContent = useDebounce(content, { wait: 100 });
35
35
  const filteredOptions = useMemo(() => {
@@ -72,7 +72,7 @@ export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly
72
72
  useEffect(() => {
73
73
  value && setContent(String(value));
74
74
  }, [value]);
75
- return (_jsxs("div", { ref: autocompleteRef, className: AutocompleteClass, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(motion.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsx(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: OptionsList, style: dynamicStyle, "aria-labelledby": seedID('autocomplete-trigger'), children: filteredOptions.length === 0
75
+ return (_jsxs("div", { ref: autocompleteRef, className: AutocompleteClass, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(motion.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsx(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: OptionsList, style: dynamicStyle, "aria-labelledby": seedID('autocomplete-trigger'), children: filteredOptions.length === 0
76
76
  ? _jsx(Text, { as: "div", textAlign: "center", dimmed: 5, children: emptyMessage }, void 0)
77
77
  : Children.map(filteredOptions, (child) => cloneElement(child, {
78
78
  onClick: handleOptionClick
@@ -1 +1 @@
1
- .Autocomplete{display:contents}.OptionsList{-webkit-overflow-scrolling:touch;max-block-size:var(--max-h);overflow:auto;overscroll-behavior:contain}
1
+ .Autocomplete{display:contents}.PopUp{z-index:2}.OptionsList{-webkit-overflow-scrolling:touch;max-block-size:var(--max-h);overflow:auto;overscroll-behavior:contain}
package/list/list.js CHANGED
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Children, forwardRef, useMemo } from 'react';
3
3
  import { List as ListClass, Marker } from './list.module.css';
4
4
  import clsx from 'clsx';
5
- import { Text, Icon } from '../';
5
+ import { Text, Stack, Icon } from '../';
6
6
  export const List = forwardRef(({ as: Wrapper = 'ul', children, marker = 'circle', dimension = 'regular', className, markerColor, hideMarker = false, ...otherProps }, forwardedRef) => {
7
7
  const sizes = {
8
8
  small: {
@@ -19,5 +19,5 @@ export const List = forwardRef(({ as: Wrapper = 'ul', children, marker = 'circle
19
19
  }
20
20
  };
21
21
  const isUnordered = useMemo(() => Wrapper === 'ul', [Wrapper]);
22
- return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Text, { as: "li", size: sizes[dimension].text, children: [(isUnordered && !hideMarker) && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, "data-list-default-marker": marker === 'circle', dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), child.props.children] }, void 0))) }, void 0));
22
+ return (_jsx(Wrapper, { ref: forwardedRef, className: clsx(ListClass, className), "data-list-size": dimension, "data-list-ordered": !isUnordered, "data-list-no-marker": hideMarker, ...otherProps, children: Children.map(children, (child) => (_jsxs(Stack, { as: "li", direction: "row", horizontalAlign: "start", verticalAlign: "start", fill: false, children: [(isUnordered && !hideMarker) && (_jsx(Icon, { name: marker, className: Marker, fill: markerColor, "data-list-default-marker": marker === 'circle', dimension: marker !== 'circle' ? sizes[dimension].icon : 16 }, void 0)), _jsx(Text, { as: "span", size: sizes[dimension].text, children: child.props.children }, void 0)] }, void 0))) }, void 0));
23
23
  });
@@ -1 +1 @@
1
- .List{--marker-size:0.89rem;--marker-gap:0.44rem}.List[data-list-ordered=false]{list-style:none;padding:0}.List[data-list-ordered=false] li{padding-inline-start:calc(var(--marker-size) + var(--marker-gap));position:relative}.List[data-list-ordered=true] li{padding-inline-start:var(--marker-gap)}.List[data-list-ordered=true] li::marker{color:var(--dimmed-5)}.List[data-list-size=small]{--marker-size:0.77rem;--marker-gap:0.44rem}.List[data-list-size=big]{--marker-size:1.11rem;--marker-gap:0.89rem}.List[data-list-no-marker=true]{--marker-size:0;--marker-gap:0;list-style:none;padding:0}.Marker{block-size:var(--marker-size);inline-size:var(--marker-size);left:0;position:absolute;top:calc(var(--marker-size)/2.4)}.Marker[data-list-default-marker=true]{transform:scale(.7)}.List[data-list-size=small] .Marker{top:3px}.List[data-list-size=big] .Marker{top:calc(var(--marker-size)/3)}
1
+ .List{--marker-size:0.89rem;--marker-gap:0.44rem}.List li{gap:var(--marker-gap)}.List[data-list-ordered=false]{list-style:none;padding:0}.List[data-list-ordered=true] li::marker{color:var(--dimmed-5)}.List[data-list-size=small]{--marker-size:0.77rem;--marker-gap:0.44rem}.List[data-list-size=big]{--marker-size:1.11rem;--marker-gap:0.89rem}.List[data-list-no-marker=true]{--marker-size:0;--marker-gap:0;list-style:none;padding:0}.Marker{block-size:var(--marker-size);flex-shrink:0;inline-size:var(--marker-size);margin-block-start:calc(var(--marker-size)/2.5)}.Marker[data-list-default-marker=true]{transform:scale(.7)}.List[data-list-size=big] .Marker,.Marker[data-list-default-marker=true]{margin-block-start:calc(var(--marker-size)/3)}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wonderflow/react-components",
3
3
  "description": "UI components from Wonderflow's Wanda design system",
4
- "version": "3.0.0-beta.25",
4
+ "version": "3.0.0-beta.29",
5
5
  "author": "Wonderflow",
6
6
  "license": "MIT",
7
7
  "main": "index.js",
package/themes/dark.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 05 Jan 2022 09:02:04 GMT
3
+ * Generated on Wed, 05 Jan 2022 13:29:57 GMT
4
4
  */
5
5
 
6
6
  :root {
package/themes/light.css CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Wed, 05 Jan 2022 09:02:04 GMT
3
+ * Generated on Wed, 05 Jan 2022 13:29:57 GMT
4
4
  */
5
5
 
6
6
  :root {