@a-type/ui 4.1.1 → 4.1.3

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.
@@ -13,19 +13,13 @@ var __rest = (this && this.__rest) || function (s, e) {
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Dialog } from '@base-ui/react/dialog';
15
15
  import clsx from 'clsx';
16
- import { AnimatePresence } from 'motion/react';
17
16
  import { createContext, useContext, useId } from 'react';
18
17
  import { Button } from '../button/Button.js';
19
18
  const QuickActionIdContext = createContext('qab');
20
- export const QuickActionRoot = ({ children, }) => {
19
+ export const QuickActionRoot = (_a) => {
20
+ var { children } = _a, props = __rest(_a, ["children"]);
21
21
  const id = useId();
22
- return (_jsx(Dialog.Root, { children: _jsx(QuickActionIdContext.Provider, { value: id.replace(/:/g, ''), children: children }) }));
23
- };
24
- const transition = {
25
- type: 'spring',
26
- damping: 25,
27
- stiffness: 300,
28
- mass: 0.5,
22
+ return (_jsx(Dialog.Root, Object.assign({}, props, { children: _jsx(QuickActionIdContext.Provider, { value: id.replace(/:/g, ''), children: children }) })));
29
23
  };
30
24
  const QuickActionTrigger = (_a) => {
31
25
  var { className, emphasis = 'primary', children } = _a, props = __rest(_a, ["className", "emphasis", "children"]);
@@ -40,14 +34,14 @@ const QuickActionTrigger = (_a) => {
40
34
  };
41
35
  const QuickActionContent = ({ children, className, align = 'center', }) => {
42
36
  const layoutId = useContext(QuickActionIdContext);
43
- return (_jsx(Dialog.Portal, { children: _jsx(AnimatePresence, { children: _jsx(Dialog.Popup, { className: clsx('layer-components:contain-layout layer-components:border-1 layer-components:rounded-md layer-components:border-solid layer-components:shadow-lg layer-components:transition-all layer-components:bg-white layer-components:border-black', 'layer-components:fixed layer-components:bottom-[anchor(bottom)] layer-components:overflow-clip', {
44
- '[justify-self:anchor-center]': align === 'center',
45
- 'left-[anchor(left)]': align === 'start',
46
- 'right-[anchor(right)]': align === 'end',
47
- }, 'data-[starting-style]:[will-change:width,height,transform] data-[starting-style]:h-[anchor-size(height)] data-[starting-style]:w-[anchor-size(width)] data-[starting-style]:rounded-200px data-[starting-style]:opacity-0', 'layer-components:[&[data-starting-style]>*]:opacity-0', 'data-[ending-style]:[will-change:width,height,transform] data-[ending-style]:h-[anchor-size(height)] data-[ending-style]:w-[anchor-size(width)] data-[ending-style]:rounded-200px data-[ending-style]:opacity-80', 'layer-components:[&[data-ending-style]>*]:opacity-0', className), style: {
48
- // @ts-ignore
49
- 'position-anchor': `--${layoutId}`,
50
- }, children: children }) }) }));
37
+ return (_jsx(Dialog.Portal, { children: _jsx(Dialog.Popup, { className: clsx('layer-components:contain-layout layer-components:border-1 layer-components:rounded-md layer-components:border-solid layer-components:shadow-lg layer-components:transition-all layer-components:bg-white layer-components:border-black', 'layer-components:fixed layer-components:bottom-[anchor(bottom)] layer-components:overflow-clip', {
38
+ '[justify-self:anchor-center]': align === 'center',
39
+ 'left-[anchor(left)]': align === 'start',
40
+ 'right-[anchor(right)]': align === 'end',
41
+ }, 'data-[starting-style]:[will-change:width,height,transform] data-[starting-style]:h-[anchor-size(height)] data-[starting-style]:w-[anchor-size(width)] data-[starting-style]:rounded-200px data-[starting-style]:opacity-0', 'layer-components:[&[data-starting-style]>*]:opacity-0', 'data-[ending-style]:[will-change:width,height,transform] data-[ending-style]:h-[anchor-size(height)] data-[ending-style]:w-[anchor-size(width)] data-[ending-style]:rounded-200px data-[ending-style]:opacity-80', 'layer-components:[&[data-ending-style]>*]:opacity-0', className), style: {
42
+ // @ts-ignore
43
+ 'position-anchor': `--${layoutId}`,
44
+ }, children: children }) }));
51
45
  };
52
46
  export const QuickAction = Object.assign(QuickActionRoot, {
53
47
  Trigger: QuickActionTrigger,
@@ -1 +1 @@
1
- {"version":3,"file":"QuickAction.js","sourceRoot":"","sources":["../../../../src/components/quickAction/QuickAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C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EACD,KAAK,EAAE;oBACN,aAAa;oBACb,UAAU,EAAE,KAAK,QAAQ,EAAE;iBAC3B,IACA,CACF,CAAA;SAAA,YAEA,QAAQ,IACO,CACjB,CAAC;AACH,CAAC,CAAC;AAOF,MAAM,kBAAkB,GAAG,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,KAAK,GAAG,QAAQ,GACS,EAAE,EAAE;IAC7B,MAAM,QAAQ,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAClD,OAAO,CACN,KAAC,MAAM,CAAC,MAAM,cACb,KAAC,eAAe,cACf,KAAC,MAAM,CAAC,KAAK,IACZ,SAAS,EAAE,IAAI,CACd,mHAAmH,EACnH,gEAAgE,EAChE;oBACC,8BAA8B,EAAE,KAAK,KAAK,QAAQ;oBAClD,qBAAqB,EAAE,KAAK,KAAK,OAAO;oBACxC,uBAAuB,EAAE,KAAK,KAAK,KAAK;iBACxC,EACD,qIAAqI,EACrI,uDAAuD,EACvD,oIAAoI,EACpI,qDAAqD,EACrD,SAAS,CACT,EACD,KAAK,EAAE;oBACN,aAAa;oBACb,iBAAiB,EAAE,KAAK,QAAQ,EAAE;iBAClC,YAEA,QAAQ,GACK,GACE,GACH,CAChB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IACzD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;CAC3B,CAAC,CAAC"}
1
+ {"version":3,"file":"QuickAction.js","sourceRoot":"","sources":["../../../../src/components/quickAction/QuickAction.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,uBAAuB,CAAC;AAChE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC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AU,CAAC,oBAAoB,CAAC,CAAC;IAClD,OAAO,CACN,KAAC,MAAM,CAAC,MAAM,cACb,KAAC,MAAM,CAAC,KAAK,IACZ,SAAS,EAAE,IAAI,CACd,mHAAmH,EACnH,gEAAgE,EAChE;gBACC,8BAA8B,EAAE,KAAK,KAAK,QAAQ;gBAClD,qBAAqB,EAAE,KAAK,KAAK,OAAO;gBACxC,uBAAuB,EAAE,KAAK,KAAK,KAAK;aACxC,EACD,qIAAqI,EACrI,uDAAuD,EACvD,oIAAoI,EACpI,qDAAqD,EACrD,SAAS,CACT,EACD,KAAK,EAAE;gBACN,aAAa;gBACb,iBAAiB,EAAE,KAAK,QAAQ,EAAE;aAClC,YAEA,QAAQ,GACK,GACA,CAChB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;IACzD,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;CAC3B,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-type/ui",
3
- "version": "4.1.1",
3
+ "version": "4.1.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "url": "https://github.com/a-type/ui"
@@ -1,7 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { useState } from 'react';
3
3
  import { Box } from '../box/Box.js';
4
- import { Button } from '../button/Button.js';
5
4
  import { Icon } from '../icon/Icon.js';
6
5
  import { Combobox } from './Combobox.js';
7
6
 
@@ -101,7 +100,17 @@ export const Default: Story = {
101
100
  <ExampleCombobox.Input
102
101
  icon={<Icon name="food" />}
103
102
  className="w-[200px]"
104
- />
103
+ >
104
+ {creatable && (
105
+ <ExampleCombobox.CreateButton
106
+ size="small"
107
+ emphasis="primary"
108
+ className="aspect-1 h-full"
109
+ >
110
+ <Icon name="plus" />
111
+ </ExampleCombobox.CreateButton>
112
+ )}
113
+ </ExampleCombobox.Input>
105
114
  <ExampleCombobox.Content arrow={arrow}>
106
115
  <ExampleCombobox.List>
107
116
  {(item) => (
@@ -217,9 +226,13 @@ export const NotPopover: Story = {
217
226
  >
218
227
  <Box border p surface="white" col>
219
228
  <GroupedCombobox.Input disableCaret className="w-full" disableClear>
220
- <Button size="small" emphasis="primary" className="aspect-1 h-full">
229
+ <GroupedCombobox.CreateButton
230
+ size="small"
231
+ emphasis="primary"
232
+ className="aspect-1 h-full"
233
+ >
221
234
  <Icon name="plus" />
222
- </Button>
235
+ </GroupedCombobox.CreateButton>
223
236
  </GroupedCombobox.Input>
224
237
  <GroupedCombobox.List>
225
238
  {(group) => (
@@ -1,4 +1,3 @@
1
- import { ButtonProps } from '@base-ui/react/button';
2
1
  import * as BaseCombobox from '@base-ui/react/combobox';
3
2
  import clsx from 'clsx';
4
3
  import {
@@ -13,6 +12,7 @@ import {
13
12
  import { withClassName } from '../../hooks.js';
14
13
  import { PaletteName } from '../../uno/index.js';
15
14
  import { Button } from '../button/Button.js';
15
+ import { ButtonProps } from '../button/index.js';
16
16
  import { Chip, ChipProps } from '../chip/Chip.js';
17
17
  import { Icon } from '../icon/Icon.js';
18
18
  import { Input, InputProps } from '../input/Input.js';
@@ -145,7 +145,7 @@ export function ComboboxComposedInput({
145
145
  export const ComboboxValueContext = createContext<any>(null);
146
146
 
147
147
  const ComboboxCreatableContext = createContext<{
148
- onInputEnter?: (value: string) => void;
148
+ onCreate?: (value: string) => void;
149
149
  inputValue: string;
150
150
  showCreatableItem?: boolean;
151
151
  }>({
@@ -214,7 +214,7 @@ const ComboboxRoot = ({
214
214
  highlightedItemRef.current = item;
215
215
  onItemHighlighted?.(item, ev);
216
216
  };
217
- const onInputEnter = onCreate
217
+ const handleCreate = onCreate
218
218
  ? (value: string) => {
219
219
  if (highlightedItemRef.current) return;
220
220
  onCreate(value);
@@ -245,7 +245,11 @@ const ComboboxRoot = ({
245
245
  return (
246
246
  <ComboboxAnchorContext.Provider value={anchorRef}>
247
247
  <ComboboxCreatableContext.Provider
248
- value={{ inputValue, onInputEnter, showCreatableItem: canCreate }}
248
+ value={{
249
+ inputValue,
250
+ onCreate: handleCreate,
251
+ showCreatableItem: canCreate,
252
+ }}
249
253
  >
250
254
  <ComboboxValueContext.Provider value={props.value || null}>
251
255
  <BaseCombobox.Combobox.Root
@@ -306,7 +310,7 @@ function ComboboxInput({
306
310
  onKeyDown: userOnKeyDown,
307
311
  ...outerProps
308
312
  }: ComboboxInputProps) {
309
- const { onInputEnter } = useContext(ComboboxCreatableContext);
313
+ const { onCreate: onInputEnter } = useContext(ComboboxCreatableContext);
310
314
  const handleKeyDown: ComboboxInputProps['onKeyDown'] = (ev) => {
311
315
  if (ev.key === 'Enter' && onInputEnter) {
312
316
  onInputEnter(ev.currentTarget.value);
@@ -332,6 +336,21 @@ function ComboboxInput({
332
336
  );
333
337
  }
334
338
 
339
+ function ComboboxCreateButton({ onClick, ...props }: ButtonProps) {
340
+ const { onCreate: onInputEnter, inputValue } = useContext(
341
+ ComboboxCreatableContext,
342
+ );
343
+ return (
344
+ <Button
345
+ onClick={(ev) => {
346
+ onInputEnter?.(inputValue);
347
+ onClick?.(ev);
348
+ }}
349
+ {...props}
350
+ />
351
+ );
352
+ }
353
+
335
354
  const ComboboxAnchorContext =
336
355
  createContext<RefObject<HTMLDivElement | null> | null>(null);
337
356
 
@@ -620,6 +639,7 @@ const baseSubComponents = {
620
639
  Chips: ComboboxChips,
621
640
  Chip: ComboboxChip,
622
641
  ChipsList: ComboboxChipsList,
642
+ CreateButton: ComboboxCreateButton,
623
643
 
624
644
  Value: BaseCombobox.Combobox.Value,
625
645
  MultiValue: ComboboxMultiValue,
@@ -11,7 +11,6 @@ import { inputInfo } from '../../systems/inputs.js';
11
11
 
12
12
  export const inputClassName = clsx(
13
13
  'layer-components:(min-w-60px flex-1 select-auto border-none px-0 py-1.25 text-md font-inherit bg-transparent)',
14
- 'layer-components:md:(min-w-120px)',
15
14
  'layer-components:placeholder:(color-gray-dark)',
16
15
  'layer-components:focus:(outline-none)',
17
16
  'layer-components:focus-visible:(outline-none)',
@@ -1,6 +1,5 @@
1
- import { Dialog } from '@base-ui/react/dialog';
1
+ import { Dialog, DialogRootProps } from '@base-ui/react/dialog';
2
2
  import clsx from 'clsx';
3
- import { AnimatePresence, Transition } from 'motion/react';
4
3
  import { createContext, useContext, useId } from 'react';
5
4
  import { Button, ButtonProps } from '../button/Button.js';
6
5
 
@@ -8,12 +7,13 @@ const QuickActionIdContext = createContext<string>('qab');
8
7
 
9
8
  export const QuickActionRoot = ({
10
9
  children,
11
- }: {
12
- children: React.ReactNode;
10
+ ...props
11
+ }: Omit<DialogRootProps, 'children'> & {
12
+ children?: React.ReactNode;
13
13
  }) => {
14
14
  const id = useId();
15
15
  return (
16
- <Dialog.Root>
16
+ <Dialog.Root {...props}>
17
17
  <QuickActionIdContext.Provider value={id.replace(/:/g, '')}>
18
18
  {children}
19
19
  </QuickActionIdContext.Provider>
@@ -21,13 +21,6 @@ export const QuickActionRoot = ({
21
21
  );
22
22
  };
23
23
 
24
- const transition: Transition = {
25
- type: 'spring',
26
- damping: 25,
27
- stiffness: 300,
28
- mass: 0.5,
29
- };
30
-
31
24
  export type QuickActionTriggerProps = ButtonProps;
32
25
  const QuickActionTrigger = ({
33
26
  className,
@@ -73,30 +66,28 @@ const QuickActionContent = ({
73
66
  const layoutId = useContext(QuickActionIdContext);
74
67
  return (
75
68
  <Dialog.Portal>
76
- <AnimatePresence>
77
- <Dialog.Popup
78
- className={clsx(
79
- 'layer-components:(contain-layout border-1 rounded-md border-solid shadow-lg transition-all bg-white border-black)',
80
- 'layer-components:(fixed bottom-[anchor(bottom)] overflow-clip)',
81
- {
82
- '[justify-self:anchor-center]': align === 'center',
83
- 'left-[anchor(left)]': align === 'start',
84
- 'right-[anchor(right)]': align === 'end',
85
- },
86
- 'data-[starting-style]:([will-change:width,height,transform] h-[anchor-size(height)] w-[anchor-size(width)] rounded-200px opacity-0)',
87
- 'layer-components:[&[data-starting-style]>*]:opacity-0',
88
- 'data-[ending-style]:([will-change:width,height,transform] h-[anchor-size(height)] w-[anchor-size(width)] rounded-200px opacity-80)',
89
- 'layer-components:[&[data-ending-style]>*]:opacity-0',
90
- className,
91
- )}
92
- style={{
93
- // @ts-ignore
94
- 'position-anchor': `--${layoutId}`,
95
- }}
96
- >
97
- {children}
98
- </Dialog.Popup>
99
- </AnimatePresence>
69
+ <Dialog.Popup
70
+ className={clsx(
71
+ 'layer-components:(contain-layout border-1 rounded-md border-solid shadow-lg transition-all bg-white border-black)',
72
+ 'layer-components:(fixed bottom-[anchor(bottom)] overflow-clip)',
73
+ {
74
+ '[justify-self:anchor-center]': align === 'center',
75
+ 'left-[anchor(left)]': align === 'start',
76
+ 'right-[anchor(right)]': align === 'end',
77
+ },
78
+ 'data-[starting-style]:([will-change:width,height,transform] h-[anchor-size(height)] w-[anchor-size(width)] rounded-200px opacity-0)',
79
+ 'layer-components:[&[data-starting-style]>*]:opacity-0',
80
+ 'data-[ending-style]:([will-change:width,height,transform] h-[anchor-size(height)] w-[anchor-size(width)] rounded-200px opacity-80)',
81
+ 'layer-components:[&[data-ending-style]>*]:opacity-0',
82
+ className,
83
+ )}
84
+ style={{
85
+ // @ts-ignore
86
+ 'position-anchor': `--${layoutId}`,
87
+ }}
88
+ >
89
+ {children}
90
+ </Dialog.Popup>
100
91
  </Dialog.Portal>
101
92
  );
102
93
  };