@manafishrov/ui 1.4.0 → 1.4.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@manafishrov/ui",
4
- "version": "1.4.0",
4
+ "version": "1.4.2",
5
5
  "description": "Styled component library for Manafish interfaces ",
6
6
  "license": "AGPL-3.0-or-later",
7
7
  "repository": {
@@ -1,17 +1,13 @@
1
+ import type { Component, ComponentProps, JSX, JSXElement } from 'solid-js';
2
+
1
3
  import { Select as SelectPrimitive } from '@ark-ui/solid/select';
2
- import {
3
- type Component,
4
- type ComponentProps,
5
- type JSX,
6
- type JSXElement,
7
- For,
8
- splitProps,
9
- } from 'solid-js';
10
4
  import { cn } from 'tailwind-variants';
11
5
  import CheckIcon from '~icons/material-symbols/check';
12
6
  import CloseIcon from '~icons/material-symbols/close';
13
7
  import ExpandMoreIcon from '~icons/material-symbols/expand-more';
14
8
 
9
+ import { createSelectTriggerRef } from '../primitives/selectTriggerRef';
10
+
15
11
  export const SelectControl = SelectPrimitive.Control;
16
12
  export const SelectItemContext = SelectPrimitive.ItemContext;
17
13
  export const SelectHiddenSelect = SelectPrimitive.HiddenSelect;
@@ -153,11 +149,14 @@ export const SelectValue: Component<SelectPrimitive.ValueTextProps> = (props) =>
153
149
  export const SelectTrigger: Component<
154
150
  SelectPrimitive.TriggerProps & { size?: 'sm' | 'default' }
155
151
  > = (props) => {
156
- const [local, others] = splitProps(props, ['class', 'size']);
152
+ const [local, others] = splitProps(props, ['class', 'size', 'ref']);
157
153
  const size = local.size ?? 'default';
154
+ const ref =
155
+ typeof local.ref === 'function' ? createSelectTriggerRef(local.ref) : createSelectTriggerRef();
158
156
 
159
157
  return (
160
158
  <SelectPrimitive.Trigger
159
+ ref={ref}
161
160
  data-slot='select-trigger'
162
161
  data-size={size}
163
162
  class={cn(
@@ -36,9 +36,7 @@ const ToastIcon: Component<{ type: ToastOptions['type'] }> = (props) => (
36
36
  const ToastItem: Component<{ toast: Accessor<ToastOptions> }> = (props) => (
37
37
  <Toast.Root
38
38
  class={cn(
39
- 'group gap-2 px-4 py-3.5 shadow-lg min-w-80 pointer-events-auto relative flex w-full items-center rounded-xl border bg-popover',
40
- 'data-[state=open]:sm:slide-in-from-bottom-full data-[state=open]:animate-in data-[state=open]:slide-in-from-top-full',
41
- 'data-[state=closed]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full',
39
+ 'group gap-2 px-4 py-3.5 shadow-lg min-w-80 ease-in-out pointer-events-auto relative flex w-full items-center rounded-xl border bg-popover',
42
40
  'border-border text-popover-foreground',
43
41
  )}
44
42
  >
@@ -4,7 +4,7 @@
4
4
  z-index: var(--z-index);
5
5
  height: var(--height);
6
6
  opacity: var(--opacity);
7
- will-change: translate, opacity, scale, height;
7
+ will-change: translate, opacity, scale;
8
8
  transition:
9
9
  translate 400ms,
10
10
  scale 400ms,
@@ -12,12 +12,12 @@
12
12
  height 400ms,
13
13
  box-shadow 200ms;
14
14
  transition-timing-function: cubic-bezier(0.21, 1.02, 0.73, 1);
15
- }
16
15
 
17
- [data-scope='toast'][data-part='root'][data-state='closed'] {
18
- transition:
19
- translate 400ms,
20
- scale 400ms,
21
- opacity 200ms;
22
- transition-timing-function: cubic-bezier(0.06, 0.71, 0.55, 1);
16
+ &[data-state='closed'] {
17
+ transition:
18
+ translate 400ms,
19
+ scale 400ms,
20
+ opacity 200ms;
21
+ transition-timing-function: cubic-bezier(0.06, 0.71, 0.55, 1);
22
+ }
23
23
  }
@@ -0,0 +1,33 @@
1
+ // Workaround for https://github.com/chakra-ui/ark/issues/3146
2
+ // SolidJS event delegation causes interact-outside to close the select on pointerdown,
3
+ // Then the delegated click re-opens it. We suppress that click when already open.
4
+ export const createSelectTriggerRef = (
5
+ forwardRef?: (element: HTMLButtonElement) => void,
6
+ ): ((element: HTMLButtonElement) => void) => {
7
+ let suppressNextClick = false;
8
+
9
+ return (element: HTMLButtonElement): void => {
10
+ element.addEventListener(
11
+ 'pointerdown',
12
+ () => {
13
+ if (element.getAttribute('aria-expanded') === 'true') {
14
+ suppressNextClick = true;
15
+ }
16
+ },
17
+ true,
18
+ );
19
+ element.addEventListener(
20
+ 'click',
21
+ (event) => {
22
+ if (suppressNextClick) {
23
+ suppressNextClick = false;
24
+ event.stopPropagation();
25
+ }
26
+ },
27
+ true,
28
+ );
29
+ if (forwardRef) {
30
+ forwardRef(element);
31
+ }
32
+ };
33
+ };