@destyler/qr-code 0.2.11 → 0.2.13

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
@@ -1,12 +1,9 @@
1
- import * as _destyler_anatomy0 from "@destyler/anatomy";
2
1
  import { DataUrlType } from "@destyler/dom";
3
- import * as _destyler_xstate0 from "@destyler/xstate";
4
2
  import { AnyEventObject, Machine, XSend, XState } from "@destyler/xstate";
5
3
  import { QrCodeGenerateOptions, QrCodeGenerateOptions as QrCodeGenerateOptions$1, QrCodeGenerateResult, QrCodeGenerateResult as QrCodeGenerateResult$1 } from "uqr";
6
4
  import { CommonProperties, DirectionProperty, NormalizeProps, PropTypes, RequiredBy } from "@destyler/types";
7
-
8
5
  //#region src/anatomy.d.ts
9
- declare const anatomy: _destyler_anatomy0.AnatomyInstance<"root" | "frame" | "pattern" | "overlay" | "downloadTrigger">;
6
+ export declare const anatomy: import("@destyler/anatomy").AnatomyInstance<"root" | "frame" | "pattern" | "overlay" | "downloadTrigger">;
10
7
  //#endregion
11
8
  //#region src/types.d.ts
12
9
  type ElementIds = Partial<{
@@ -86,13 +83,13 @@ interface MachineApi<T extends PropTypes = PropTypes> {
86
83
  }
87
84
  //#endregion
88
85
  //#region src/connect.d.ts
89
- declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
86
+ export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
90
87
  //#endregion
91
88
  //#region src/machine.d.ts
92
- declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Machine<MachineContext, MachineState, _destyler_xstate0.AnyEventObject>;
89
+ export declare function machine(userContext: UserDefinedContext): import("@destyler/xstate").Machine<MachineContext, MachineState, import("@destyler/xstate").AnyEventObject>;
93
90
  //#endregion
94
91
  //#region src/props.d.ts
95
- declare const props: ("value" | "ids" | "encoding" | "onValueChange" | "dir" | "id" | "getRootNode")[];
96
- declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "ids" | "encoding" | "onValueChange" | "dir" | "id" | "getRootNode">];
92
+ export declare const props: ("value" | "ids" | "encoding" | "onValueChange" | "dir" | "id" | "getRootNode")[];
93
+ export declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "ids" | "encoding" | "onValueChange" | "dir" | "id" | "getRootNode">];
97
94
  //#endregion
98
- export { type MachineApi as Api, type UserDefinedContext as Context, type DownloadTriggerProps, type ElementIds, type MachineState, type QrCodeGenerateOptions, type QrCodeGenerateResult, type Send, type Service, type ValueChangeDetails, anatomy, connect, machine, props, splitProps };
95
+ export type { MachineApi as Api, UserDefinedContext as Context, DownloadTriggerProps, ElementIds, MachineState, QrCodeGenerateOptions, QrCodeGenerateResult, Send, Service, ValueChangeDetails };
package/dist/index.mjs CHANGED
@@ -5,11 +5,9 @@ import { createMachine } from "@destyler/xstate";
5
5
  import { memoize } from "proxy-memoize";
6
6
  import { encode } from "uqr";
7
7
  import { createProps } from "@destyler/types";
8
-
9
8
  //#region src/anatomy.ts
10
9
  const anatomy = createAnatomy("qr-code").parts("root", "frame", "pattern", "overlay", "downloadTrigger");
11
10
  const parts = anatomy.build();
12
-
13
11
  //#endregion
14
12
  //#region src/dom.ts
15
13
  const dom = createScope({
@@ -17,7 +15,6 @@ const dom = createScope({
17
15
  getFrameId: (ctx) => ctx.ids?.frame ?? `qr-code:${ctx.id}:frame`,
18
16
  getFrameEl: (ctx) => dom.getById(ctx, dom.getFrameId(ctx))
19
17
  });
20
-
21
18
  //#endregion
22
19
  //#region src/connect.ts
23
20
  function connect(state, send, normalize) {
@@ -40,7 +37,8 @@ function connect(state, send, normalize) {
40
37
  });
41
38
  },
42
39
  getDataUrl(type, quality) {
43
- return getDataUrl(dom.getFrameEl(state.context), {
40
+ const svgEl = dom.getFrameEl(state.context);
41
+ return getDataUrl(svgEl, {
44
42
  type,
45
43
  quality
46
44
  });
@@ -82,7 +80,7 @@ function connect(state, send, normalize) {
82
80
  }
83
81
  });
84
82
  },
85
- getDownloadTriggerProps(props$1) {
83
+ getDownloadTriggerProps(props) {
86
84
  return normalize.button({
87
85
  type: "button",
88
86
  ...parts.downloadTrigger.attrs,
@@ -90,14 +88,13 @@ function connect(state, send, normalize) {
90
88
  if (event.defaultPrevented) return;
91
89
  send({
92
90
  type: "DOWNLOAD_TRIGGER.CLICK",
93
- ...props$1
91
+ ...props
94
92
  });
95
93
  }
96
94
  });
97
95
  }
98
96
  };
99
97
  }
100
-
101
98
  //#endregion
102
99
  //#region src/machine.ts
103
100
  const set = { value(ctx, value) {
@@ -106,12 +103,14 @@ const set = { value(ctx, value) {
106
103
  ctx.onValueChange?.({ value });
107
104
  } };
108
105
  function machine(userContext) {
106
+ const ctx = compact(userContext);
109
107
  return createMachine({
110
108
  id: "qr-code",
111
109
  initial: "idle",
112
110
  context: {
113
111
  value: "",
114
- ...compact(userContext),
112
+ encoding: {},
113
+ ...ctx,
115
114
  pixelSize: 10
116
115
  },
117
116
  computed: { encoded: memoize((ctx) => encode(ctx.value, ctx.encoding)) },
@@ -143,7 +142,6 @@ function machine(userContext) {
143
142
  }
144
143
  } });
145
144
  }
146
-
147
145
  //#endregion
148
146
  //#region src/props.ts
149
147
  const props = createProps()([
@@ -156,6 +154,5 @@ const props = createProps()([
156
154
  "onValueChange"
157
155
  ]);
158
156
  const splitProps = createSplitProps(props);
159
-
160
157
  //#endregion
161
- export { anatomy, connect, machine, props, splitProps };
158
+ export { anatomy, connect, machine, props, splitProps };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@destyler/qr-code",
3
3
  "type": "module",
4
- "version": "0.2.11",
4
+ "version": "0.2.13",
5
5
  "description": "a component that generates a QR code based on the provided data.",
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.13",
26
+ "@destyler/dom": "0.2.13",
27
+ "@destyler/types": "0.2.13",
28
+ "@destyler/utils": "0.2.13",
29
+ "@destyler/xstate": "0.2.13",
25
30
  "proxy-memoize": "^3.0.1",
26
- "uqr": "^0.1.2",
27
- "@destyler/anatomy": "0.2.11",
28
- "@destyler/types": "0.2.11",
29
- "@destyler/dom": "0.2.11",
30
- "@destyler/xstate": "0.2.11",
31
- "@destyler/utils": "0.2.11"
31
+ "uqr": "^0.1.3"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"