@destyler/tooltip 0.2.6 → 0.2.9

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/dist/index.d.mts CHANGED
@@ -85,9 +85,10 @@ interface PublicContext extends DirectionProperty, CommonProperties {
85
85
  */
86
86
  'open'?: boolean | undefined;
87
87
  /**
88
- * Whether the tooltip is controlled by the user
88
+ * The initial open state of the tooltip when it is not controlled.
89
+ * Prefer this over seeding with `open` for uncontrolled usage.
89
90
  */
90
- 'open.controlled'?: boolean | undefined;
91
+ 'defaultOpen'?: boolean | undefined;
91
92
  }
92
93
  type UserDefinedContext = RequiredBy<PublicContext, 'id'>;
93
94
  type ComputedContext = Readonly<{
@@ -143,7 +144,7 @@ declare function connect<T extends PropTypes>(state: State, send: Send, normaliz
143
144
  declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
144
145
  //#endregion
145
146
  //#region src/props.d.ts
146
- declare const props: ("open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode")[];
147
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "id" | "ids" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "open.controlled" | "dir" | "getRootNode">];
147
+ declare const props: ("open" | "ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "defaultOpen" | "dir" | "getRootNode")[];
148
+ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "open" | "ids" | "id" | "openDelay" | "closeDelay" | "closeOnPointerDown" | "closeOnEscape" | "closeOnScroll" | "closeOnClick" | "interactive" | "onOpenChange" | "aria-label" | "positioning" | "disabled" | "defaultOpen" | "dir" | "getRootNode">];
148
149
  //#endregion
149
150
  export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type OpenChangeDetails, type Placement, type PositioningOptions, type Service, anatomy, connect, machine, props, splitProps };
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { addDomEvent, createScope, dataAttr, getOverflowAncestors, isComposingEv
3
3
  import { isFocusVisible, trackFocusVisible } from "@destyler/focus-visible";
4
4
  import { getPlacement, getPlacementStyles } from "@destyler/popper";
5
5
  import { createMachine, guards, proxy, subscribe } from "@destyler/xstate";
6
- import { compact, createSplitProps } from "@destyler/utils";
6
+ import { compact, createSplitProps, isControlled, resolveControllableOpen, withControllableProvided } from "@destyler/utils";
7
7
  import { createProps } from "@destyler/types";
8
8
 
9
9
  //#region src/anatomy.ts
@@ -167,10 +167,11 @@ function connect(state, send, normalize) {
167
167
  //#region src/machine.ts
168
168
  const { and, not } = guards;
169
169
  function machine(userContext) {
170
- const ctx = compact(userContext);
170
+ const ctx = compact(withControllableProvided(userContext, ["open"]));
171
+ const { initialOpen } = resolveControllableOpen(ctx);
171
172
  return createMachine({
172
173
  id: "tooltip",
173
- initial: ctx.open ? "open" : "closed",
174
+ initial: initialOpen ? "open" : "closed",
174
175
  activities: ["trackFocusVisible"],
175
176
  context: {
176
177
  openDelay: 1e3,
@@ -454,7 +455,7 @@ function machine(userContext) {
454
455
  isVisible: (ctx$1) => ctx$1.id === store.id,
455
456
  isInteractive: (ctx$1) => ctx$1.interactive,
456
457
  hasPointerMoveOpened: (ctx$1) => !!ctx$1.hasPointerMoveOpened,
457
- isOpenControlled: (ctx$1) => !!ctx$1["open.controlled"]
458
+ isOpenControlled: (ctx$1) => isControlled(ctx$1, "open")
458
459
  },
459
460
  delays: {
460
461
  OPEN_DELAY: (ctx$1) => ctx$1.openDelay,
@@ -479,8 +480,8 @@ const props = createProps()([
479
480
  "ids",
480
481
  "interactive",
481
482
  "onOpenChange",
482
- "open.controlled",
483
483
  "open",
484
+ "defaultOpen",
484
485
  "openDelay",
485
486
  "positioning"
486
487
  ]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@destyler/tooltip",
3
3
  "type": "module",
4
- "version": "0.2.6",
4
+ "version": "0.2.9",
5
5
  "description": "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.",
6
6
  "author": "Elone Hoo <elonehoo@gmail.com>",
7
7
  "license": "MIT",
@@ -22,13 +22,13 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@destyler/anatomy": "0.2.6",
26
- "@destyler/dom": "0.2.6",
27
- "@destyler/popper": "0.2.6",
28
- "@destyler/focus-visible": "0.2.6",
29
- "@destyler/types": "0.2.6",
30
- "@destyler/utils": "0.2.6",
31
- "@destyler/xstate": "0.2.6"
25
+ "@destyler/anatomy": "0.2.9",
26
+ "@destyler/dom": "0.2.9",
27
+ "@destyler/popper": "0.2.9",
28
+ "@destyler/types": "0.2.9",
29
+ "@destyler/focus-visible": "0.2.9",
30
+ "@destyler/utils": "0.2.9",
31
+ "@destyler/xstate": "0.2.9"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"