@octanejs/select 0.1.13 → 0.1.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/select",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "React Select bindings for the Octane renderer.",
@@ -29,7 +29,7 @@
29
29
  "./async-creatable": "./src/async-creatable.tsrx"
30
30
  },
31
31
  "dependencies": {
32
- "@octanejs/transition-group": "0.0.27",
32
+ "@octanejs/transition-group": "0.0.29",
33
33
  "@emotion/cache": "11.9.3",
34
34
  "@emotion/serialize": "1.1.0",
35
35
  "@emotion/utils": "1.2.0",
@@ -37,7 +37,7 @@
37
37
  "memoize-one": "6.0.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "octane": "^0.10.0"
40
+ "octane": "^0.12.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/core": "7.19.6",
@@ -56,13 +56,13 @@
56
56
  "@testing-library/user-event": "10.4.1",
57
57
  "@types/react": "19.2.17",
58
58
  "@types/react-dom": "19.2.3",
59
- "@tsrx/react": "^0.3.7",
59
+ "@tsrx/react": "^0.4.5",
60
60
  "babel-jest": "25.5.1",
61
61
  "happy-dom": "^20.11.0",
62
62
  "jest": "25.5.4",
63
63
  "jest-environment-jsdom": "25.5.0",
64
64
  "jest-in-case": "1.0.2",
65
- "octane": "0.10.2",
65
+ "octane": "0.12.0",
66
66
  "playwright": "^1.61.1",
67
67
  "react": "19.2.7",
68
68
  "react-dom": "19.2.7",
@@ -3,8 +3,10 @@ import type { InputProps } from '../components.tsrx';
3
3
  import { asComponentElement } from './component-element';
4
4
 
5
5
  type InputComponent = typeof import('../components.tsrx').Input;
6
- type AnimatedTransitionProps =
7
- Pick<TransitionProps, 'in' | 'onExited' | 'appear' | 'enter' | 'exit'>;
6
+ type AnimatedTransitionProps = Pick<
7
+ TransitionProps,
8
+ 'in' | 'onExited' | 'appear' | 'enter' | 'exit'
9
+ >;
8
10
  export type AnimatedInputProps = InputProps & AnimatedTransitionProps;
9
11
 
10
12
  export function animatedInput(WrappedComponent: InputComponent): InputComponent {
@@ -30,14 +30,16 @@ export function Fade<Props extends Record<string, unknown>>(props: FadeProps<Pro
30
30
  const consumerStyle = (consumerInnerProps?.style ?? {}) as Record<string, unknown>;
31
31
 
32
32
  <Transition mountOnEnter unmountOnExit in={inProp} timeout={duration} nodeRef={nodeRef}>
33
- {(status: TransitionStatus) => <Tag
34
- {...componentProps as unknown as Props}
35
- innerProps={{
36
- ...consumerInnerProps,
37
- style: { ...consumerStyle, ...transition[status] },
38
- ref: nodeRef,
39
- }}
40
- />}
33
+ {(status: TransitionStatus) => (
34
+ <Tag
35
+ {...(componentProps as unknown as Props)}
36
+ innerProps={{
37
+ ...consumerInnerProps,
38
+ style: { ...consumerStyle, ...transition[status] },
39
+ ref: nodeRef,
40
+ }}
41
+ />
42
+ )}
41
43
  </Transition>
42
44
  }
43
45
 
@@ -56,8 +58,8 @@ export function Collapse(props: CollapseProps) @{
56
58
  useEffect(() => {
57
59
  const element = ref.current;
58
60
  if (!element) return;
59
- const frame = window.requestAnimationFrame(
60
- () => setWidth(element.getBoundingClientRect().width),
61
+ const frame = window.requestAnimationFrame(() =>
62
+ setWidth(element.getBoundingClientRect().width),
61
63
  );
62
64
  return () => window.cancelAnimationFrame(frame);
63
65
  }, []);
@@ -81,10 +83,10 @@ export function Collapse(props: CollapseProps) @{
81
83
  timeout={collapseDuration}
82
84
  nodeRef={ref}
83
85
  >
84
- {(status: TransitionStatus) =>
85
- <div
86
- ref={ref}
87
- style={{ overflow: 'hidden', whiteSpace: 'nowrap', ...styleFor(status) }}
88
- >{props.children}</div>}
86
+ {(status: TransitionStatus) => (
87
+ <div ref={ref} style={{ overflow: 'hidden', whiteSpace: 'nowrap', ...styleFor(status) }}>
88
+ {props.children}
89
+ </div>
90
+ )}
89
91
  </Transition>
90
92
  }
@@ -82,8 +82,8 @@ function MultiValueContainer(props: MultiValueContainerProps) @{
82
82
  const innerProps = {
83
83
  ...props.innerProps,
84
84
  style: {
85
- ...(props.innerProps?.style ?? {}) as Record<string, unknown>,
86
- display: props.isMulti && props.hasValue || displayFlex ? 'flex' : 'grid',
85
+ ...((props.innerProps?.style ?? {}) as Record<string, unknown>),
86
+ display: (props.isMulti && props.hasValue) || displayFlex ? 'flex' : 'grid',
87
87
  },
88
88
  };
89
89
 
@@ -9,12 +9,13 @@ import { useStateManager } from './use-state-manager.tsrx';
9
9
  import type { StateManagerProps } from './use-state-manager.tsrx';
10
10
  import type { GroupBase } from './types';
11
11
 
12
- export type AsyncCreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> =
13
- AsyncProps<Option, IsMulti, Group> & CreatableAdditionalProps<Option, Group> & StateManagerProps<
14
- Option,
15
- IsMulti,
16
- Group
17
- >;
12
+ export type AsyncCreatableProps<
13
+ Option,
14
+ IsMulti extends boolean,
15
+ Group extends GroupBase<Option>,
16
+ > = AsyncProps<Option, IsMulti, Group> &
17
+ CreatableAdditionalProps<Option, Group> &
18
+ StateManagerProps<Option, IsMulti, Group>;
18
19
 
19
20
  function AsyncCreatableSelect<
20
21
  Option = unknown,
@@ -24,7 +25,7 @@ function AsyncCreatableSelect<
24
25
  const asyncProps = useAsync<Option, IsMulti, Group>(props);
25
26
  const stateProps = useStateManager<Option, IsMulti, Group>(asyncProps);
26
27
  const creatableProps = useCreatable(stateProps as CreatableBaseProps<Option, IsMulti, Group>);
27
- <Select {...creatableProps as SelectProps<Option, IsMulti, Group>} />
28
+ <Select {...(creatableProps as SelectProps<Option, IsMulti, Group>)} />
28
29
  }
29
30
 
30
31
  export default AsyncCreatableSelect;
package/src/async.tsrx CHANGED
@@ -13,7 +13,7 @@ function AsyncSelect<
13
13
  >(props: AsyncProps<Option, IsMulti, Group> & SelectProps<Option, IsMulti, Group>) @{
14
14
  const asyncProps = useAsync<Option, IsMulti, Group>(props);
15
15
  const selectProps = useStateManager<Option, IsMulti, Group>(asyncProps);
16
- <Select {...selectProps as SelectProps<Option, IsMulti, Group>} />
16
+ <Select {...(selectProps as SelectProps<Option, IsMulti, Group>)} />
17
17
  }
18
18
 
19
19
  export default AsyncSelect;
@@ -18,10 +18,9 @@ import { useStyleResolver } from './style-context.tsrx';
18
18
  export type Ref<T> = ((value: T | null) => void) | { current: T | null } | null;
19
19
  export type ClassNamesState = Record<string, boolean>;
20
20
  export type CX = (state: ClassNamesState, ...classNames: (string | undefined)[]) => string;
21
- type DivProps =
22
- Omit<Octane.JSX.IntrinsicElements['div'], 'ref'> & {
23
- ref?: Octane.Ref<HTMLDivElement>;
24
- };
21
+ type DivProps = Omit<Octane.JSX.IntrinsicElements['div'], 'ref'> & {
22
+ ref?: Octane.Ref<HTMLDivElement>;
23
+ };
25
24
  type InputPropsBase = Omit<Octane.JSX.IntrinsicElements['input'], 'ref'>;
26
25
  type SpanProps = Octane.JSX.IntrinsicElements['span'];
27
26
  type SvgProps = Octane.JSX.IntrinsicElements['svg'];
@@ -85,9 +84,7 @@ export function CrossIcon(props: CrossIconProps) @{
85
84
  focusable="false"
86
85
  className={resolved.className}
87
86
  >
88
- <path
89
- d="M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"
90
- />
87
+ <path d="M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z" />
91
88
  </svg>
92
89
  }
93
90
 
@@ -105,9 +102,7 @@ export function DownChevron(props: DownChevronProps) @{
105
102
  focusable="false"
106
103
  className={resolved.className}
107
104
  >
108
- <path
109
- d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"
110
- />
105
+ <path d="M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z" />
111
106
  </svg>
112
107
  }
113
108
 
@@ -130,7 +125,9 @@ export function SelectContainer(props: ContainerProps) @{
130
125
  '--is-rtl': isRtl,
131
126
  })}
132
127
  {...innerProps}
133
- >{children}</div>
128
+ >
129
+ {children}
130
+ </div>
134
131
  }
135
132
 
136
133
  export interface ControlProps<
@@ -158,7 +155,9 @@ export function Control(props: ControlProps) @{
158
155
  })}
159
156
  {...innerProps}
160
157
  aria-disabled={isDisabled || undefined}
161
- >{children}</div>
158
+ >
159
+ {children}
160
+ </div>
162
161
  }
163
162
 
164
163
  export interface ValueContainerProps<
@@ -180,7 +179,9 @@ export function ValueContainer(props: ValueContainerProps) @{
180
179
  'value-container--has-value': hasValue,
181
180
  })}
182
181
  {...innerProps}
183
- >{children}</div>
182
+ >
183
+ {children}
184
+ </div>
184
185
  }
185
186
 
186
187
  export interface IndicatorsContainerProps<
@@ -194,10 +195,9 @@ export interface IndicatorsContainerProps<
194
195
  }
195
196
 
196
197
  export function IndicatorsContainer(props: IndicatorsContainerProps) @{
197
- <div
198
- {...useStyleProps(props, 'indicatorsContainer', { indicators: true })}
199
- {...props.innerProps}
200
- >{props.children}</div>
198
+ <div {...useStyleProps(props, 'indicatorsContainer', { indicators: true })} {...props.innerProps}>
199
+ {props.children}
200
+ </div>
201
201
  }
202
202
 
203
203
  export interface PlaceholderProps<
@@ -212,10 +212,9 @@ export interface PlaceholderProps<
212
212
  }
213
213
 
214
214
  export function Placeholder(props: PlaceholderProps) @{
215
- <div
216
- {...useStyleProps(props, 'placeholder', { placeholder: true })}
217
- {...props.innerProps}
218
- >{props.children}</div>
215
+ <div {...useStyleProps(props, 'placeholder', { placeholder: true })} {...props.innerProps}>
216
+ {props.children}
217
+ </div>
219
218
  }
220
219
 
221
220
  export interface SingleValueProps<
@@ -236,7 +235,9 @@ export function SingleValue(props: SingleValueProps) @{
236
235
  'single-value--is-disabled': props.isDisabled,
237
236
  })}
238
237
  {...props.innerProps}
239
- >{props.children}</div>
238
+ >
239
+ {props.children}
240
+ </div>
240
241
  }
241
242
 
242
243
  export interface OptionProps<
@@ -266,14 +267,17 @@ export function Option(props: OptionProps) @{
266
267
  ref={props.innerRef}
267
268
  aria-disabled={props.isDisabled}
268
269
  {...props.innerProps}
269
- >{props.children}</div>
270
+ >
271
+ {props.children}
272
+ </div>
270
273
  }
271
274
 
272
275
  export interface InputProps<
273
276
  Option = unknown,
274
277
  IsMulti extends boolean = boolean,
275
278
  Group extends GroupBase<Option> = GroupBase<Option>,
276
- > extends CommonComponentProps<Option, IsMulti, Group>, Omit<InputPropsBase, 'className'> {
279
+ >
280
+ extends CommonComponentProps<Option, IsMulti, Group>, Omit<InputPropsBase, 'className'> {
277
281
  innerRef?: Ref<HTMLInputElement>;
278
282
  isHidden: boolean;
279
283
  isDisabled?: boolean;
@@ -406,11 +410,9 @@ export interface MenuProps<
406
410
  }
407
411
 
408
412
  export function Menu(props: MenuProps) @{
409
- <div
410
- {...useStyleProps(props, 'menu', { menu: true })}
411
- ref={props.innerRef}
412
- {...props.innerProps}
413
- >{props.children}</div>
413
+ <div {...useStyleProps(props, 'menu', { menu: true })} ref={props.innerRef} {...props.innerProps}>
414
+ {props.children}
415
+ </div>
414
416
  }
415
417
 
416
418
  export interface MenuListProps<
@@ -433,7 +435,9 @@ export function MenuList(props: MenuListProps) @{
433
435
  })}
434
436
  ref={props.innerRef}
435
437
  {...props.innerProps}
436
- >{props.children}</div>
438
+ >
439
+ {props.children}
440
+ </div>
437
441
  }
438
442
 
439
443
  export interface NoticeProps<
@@ -453,7 +457,9 @@ export function NoOptionsMessage(props: NoticeProps) @{
453
457
  'menu-notice--no-options': true,
454
458
  })}
455
459
  {...props.innerProps}
456
- >{children}</div>
460
+ >
461
+ {children}
462
+ </div>
457
463
  }
458
464
 
459
465
  export function LoadingMessage(props: NoticeProps) @{
@@ -464,7 +470,9 @@ export function LoadingMessage(props: NoticeProps) @{
464
470
  'menu-notice--loading': true,
465
471
  })}
466
472
  {...props.innerProps}
467
- >{children}</div>
473
+ >
474
+ {children}
475
+ </div>
468
476
  }
469
477
 
470
478
  type ComponentType<Props> = (props: Props) => Octane.JSX.Element;
@@ -489,8 +497,8 @@ export type GroupHeadingProps<
489
497
  Option = unknown,
490
498
  IsMulti extends boolean = boolean,
491
499
  Group extends GroupBase<Option> = GroupBase<Option>,
492
- > =
493
- CommonComponentProps<Option, IsMulti, Group> & Omit<DivProps, 'className'> & {
500
+ > = CommonComponentProps<Option, IsMulti, Group> &
501
+ Omit<DivProps, 'className'> & {
494
502
  children?: OctaneNode;
495
503
  id: string;
496
504
  data: unknown;
@@ -528,7 +536,9 @@ export function Group(props: GroupProps) @{
528
536
  hasValue={props.hasValue}
529
537
  isMulti={props.isMulti}
530
538
  isRtl={props.isRtl}
531
- >{props.label}</Heading>
539
+ >
540
+ {props.label}
541
+ </Heading>
532
542
  <div>{props.children}</div>
533
543
  </div>
534
544
  }
@@ -563,7 +573,9 @@ export interface MultiValueRemoveProps<
563
573
  }
564
574
 
565
575
  export function MultiValueRemove(props: MultiValueRemoveProps) @{
566
- <div role="button" {...props.innerProps}>{props.children || <CrossIcon size={14} />}</div>
576
+ <div role="button" {...props.innerProps}>
577
+ {props.children || <CrossIcon size={14} />}
578
+ </div>
567
579
  }
568
580
 
569
581
  export interface MultiValueProps<
@@ -607,7 +619,9 @@ export function MultiValue(props: MultiValueProps) @{
607
619
  ...useStyleProps(props, 'multiValueLabel', { 'multi-value__label': true }),
608
620
  }}
609
621
  selectProps={props.selectProps}
610
- >{props.children}</Label>
622
+ >
623
+ {props.children}
624
+ </Label>
611
625
  <Remove
612
626
  data={props.data}
613
627
  innerProps={{
@@ -670,12 +684,9 @@ export function LoadingIndicator(props: LoadingIndicatorProps) @{
670
684
 
671
685
  type MenuPlacement = 'auto' | 'bottom' | 'top';
672
686
  type MenuPosition = 'absolute' | 'fixed';
673
- const PortalPlacementContext = createContext<
674
- | {
675
- setPortalPlacement: (placement: 'bottom' | 'top') => void;
676
- }
677
- | null
678
- >(null);
687
+ const PortalPlacementContext = createContext<{
688
+ setPortalPlacement: (placement: 'bottom' | 'top') => void;
689
+ } | null>(null);
679
690
 
680
691
  function coercePlacement(placement: MenuPlacement): 'bottom' | 'top' {
681
692
  return placement === 'auto' ? 'bottom' : placement;
@@ -716,23 +727,20 @@ export function MenuPortal(props: MenuPortalProps) @{
716
727
  useLayoutEffect(() => {
717
728
  setPortalPlacement(coercePlacement(props.menuPlacement));
718
729
  }, [props.menuPlacement]);
719
- const [computedPosition, setComputedPosition] = useState<
720
- | {
721
- offset: number;
722
- rect: { left: number; width: number };
723
- }
724
- | null
725
- >(null);
730
+ const [computedPosition, setComputedPosition] = useState<{
731
+ offset: number;
732
+ rect: { left: number; width: number };
733
+ } | null>(null);
726
734
 
727
735
  const updateComputedPosition = useCallback(() => {
728
736
  if (!props.controlElement) return;
729
737
  const rect = boundingClientObject(props.controlElement);
730
- const scrollDistance =
731
- props.menuPosition === 'fixed' ? 0 : window.pageYOffset;
738
+ const scrollDistance = props.menuPosition === 'fixed' ? 0 : window.pageYOffset;
732
739
  const offset = rect[placement] + scrollDistance;
733
740
  if (
734
- offset !== computedPosition?.offset || rect.left !== computedPosition?.rect.left ||
735
- rect.width !== computedPosition?.rect.width
741
+ offset !== computedPosition?.offset ||
742
+ rect.left !== computedPosition?.rect.left ||
743
+ rect.width !== computedPosition?.rect.width
736
744
  ) {
737
745
  setComputedPosition({ offset, rect });
738
746
  }
@@ -767,12 +775,15 @@ export function MenuPortal(props: MenuPortalProps) @{
767
775
  return () => cleanupRef.current?.();
768
776
  }, [runAutoUpdate]);
769
777
 
770
- const setMenuPortalElement = useCallback((element: HTMLDivElement | null) => {
771
- menuPortalRef.current = element;
772
- runAutoUpdate();
773
- }, [runAutoUpdate]);
778
+ const setMenuPortalElement = useCallback(
779
+ (element: HTMLDivElement | null) => {
780
+ menuPortalRef.current = element;
781
+ runAutoUpdate();
782
+ },
783
+ [runAutoUpdate],
784
+ );
774
785
 
775
- if (!props.appendTo && props.menuPosition !== 'fixed' || !computedPosition) return null;
786
+ if ((!props.appendTo && props.menuPosition !== 'fixed') || !computedPosition) return null;
776
787
 
777
788
  const menuWrapperProps: DivProps = {
778
789
  ...useStyleProps(
@@ -831,8 +842,7 @@ export type SelectComponentsConfig<
831
842
  Option = unknown,
832
843
  IsMulti extends boolean = boolean,
833
844
  Group extends GroupBase<Option> = GroupBase<Option>,
834
- > =
835
- Partial<SelectComponents<Option, IsMulti, Group>>;
845
+ > = Partial<SelectComponents<Option, IsMulti, Group>>;
836
846
 
837
847
  export const components: SelectComponents = {
838
848
  ClearIndicator,
@@ -10,8 +10,11 @@ import {
10
10
  import { useStateManager, type StateManagerProps } from './use-state-manager.tsrx';
11
11
  import type { GroupBase } from './types';
12
12
 
13
- export type CreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> =
14
- StateManagerProps<Option, IsMulti, Group> & CreatableAdditionalProps<Option, Group>;
13
+ export type CreatableProps<
14
+ Option,
15
+ IsMulti extends boolean,
16
+ Group extends GroupBase<Option>,
17
+ > = StateManagerProps<Option, IsMulti, Group> & CreatableAdditionalProps<Option, Group>;
15
18
 
16
19
  function CreatableSelect<
17
20
  Option = unknown,
@@ -20,7 +23,7 @@ function CreatableSelect<
20
23
  >(props: CreatableProps<Option, IsMulti, Group>) @{
21
24
  const stateProps = useStateManager<Option, IsMulti, Group>(props);
22
25
  const creatableProps = useCreatable(stateProps as CreatableBaseProps<Option, IsMulti, Group>);
23
- <Select {...creatableProps as SelectProps<Option, IsMulti, Group>} />
26
+ <Select {...(creatableProps as SelectProps<Option, IsMulti, Group>)} />
24
27
  }
25
28
 
26
29
  export default CreatableSelect;