@destyler/checkbox 0.0.7-beta.9 → 0.2.0-beta.5

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.
@@ -156,4 +156,4 @@ declare function machine(userContext: UserDefinedContext): _destyler_xstate0.Mac
156
156
  declare const props: ("value" | "ids" | "disabled" | "invalid" | "required" | "checked" | "readOnly" | "onCheckedChange" | "name" | "form" | "dir" | "id" | "getRootNode")[];
157
157
  declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Props) => [Partial<UserDefinedContext>, Omit<Props, "value" | "ids" | "disabled" | "invalid" | "required" | "checked" | "readOnly" | "onCheckedChange" | "name" | "form" | "dir" | "id" | "getRootNode">];
158
158
  //#endregion
159
- export { type MachineApi as Api, type CheckedChangeDetails, type CheckedState, type UserDefinedContext as Context, type ElementIds, type Service, anatomy, connect, machine, props, splitProps };
159
+ export { type MachineApi as Api, type CheckedChangeDetails, type CheckedState, type UserDefinedContext as Context, type ElementIds, type MachineState, type Service, type State, anatomy, connect, machine, props, splitProps };
@@ -81,8 +81,7 @@ function connect(state, send, normalize) {
81
81
  });
82
82
  },
83
83
  onClick(event) {
84
- const target = getEventTarget(event);
85
- if (target === dom.getHiddenInputEl(state.context)) event.stopPropagation();
84
+ if (getEventTarget(event) === dom.getHiddenInputEl(state.context)) event.stopPropagation();
86
85
  }
87
86
  });
88
87
  },
@@ -125,12 +124,11 @@ function connect(state, send, normalize) {
125
124
  "value": state.context.value,
126
125
  "style": visuallyHiddenStyle,
127
126
  onFocus() {
128
- const focusVisible$1 = isFocusVisible();
129
127
  send({
130
128
  type: "CONTEXT.SET",
131
129
  context: {
132
130
  focused: true,
133
- focusVisible: focusVisible$1
131
+ focusVisible: isFocusVisible()
134
132
  }
135
133
  });
136
134
  },
@@ -178,7 +176,6 @@ const set = { checked: (ctx, checked) => {
178
176
  invoke.change(ctx);
179
177
  } };
180
178
  function machine(userContext) {
181
- const ctx = compact(userContext);
182
179
  return createMachine({
183
180
  id: "checkbox",
184
181
  initial: "ready",
@@ -186,7 +183,7 @@ function machine(userContext) {
186
183
  checked: false,
187
184
  value: "on",
188
185
  disabled: false,
189
- ...ctx,
186
+ ...compact(userContext),
190
187
  fieldsetDisabled: false,
191
188
  focusVisible: false
192
189
  },
@@ -211,33 +208,33 @@ function machine(userContext) {
211
208
  "CONTEXT.SET": { actions: ["setContext"] }
212
209
  },
213
210
  computed: {
214
- isIndeterminate: (ctx$1) => isIndeterminate(ctx$1.checked),
215
- isChecked: (ctx$1) => isChecked(ctx$1.checked),
216
- isDisabled: (ctx$1) => !!ctx$1.disabled || ctx$1.fieldsetDisabled
211
+ isIndeterminate: (ctx) => isIndeterminate(ctx.checked),
212
+ isChecked: (ctx) => isChecked(ctx.checked),
213
+ isDisabled: (ctx) => !!ctx.disabled || ctx.fieldsetDisabled
217
214
  },
218
215
  states: { ready: {} }
219
216
  }, {
220
217
  guards: { isTrusted: (_ctx, evt) => !!evt.isTrusted },
221
218
  activities: {
222
- trackPressEvent(ctx$1) {
223
- if (ctx$1.isDisabled) return;
219
+ trackPressEvent(ctx) {
220
+ if (ctx.isDisabled) return;
224
221
  return trackPress({
225
- pointerNode: dom.getRootEl(ctx$1),
226
- keyboardNode: dom.getHiddenInputEl(ctx$1),
222
+ pointerNode: dom.getRootEl(ctx),
223
+ keyboardNode: dom.getHiddenInputEl(ctx),
227
224
  isValidKey: (event) => event.key === " ",
228
- onPress: () => ctx$1.active = false,
229
- onPressStart: () => ctx$1.active = true,
230
- onPressEnd: () => ctx$1.active = false
225
+ onPress: () => ctx.active = false,
226
+ onPressStart: () => ctx.active = true,
227
+ onPressEnd: () => ctx.active = false
231
228
  });
232
229
  },
233
- trackFocusVisible(ctx$1) {
234
- if (ctx$1.isDisabled) return;
235
- return trackFocusVisible({ root: dom.getRootNode(ctx$1) });
230
+ trackFocusVisible(ctx) {
231
+ if (ctx.isDisabled) return;
232
+ return trackFocusVisible({ root: dom.getRootNode(ctx) });
236
233
  },
237
- trackFormControlState(ctx$1, _evt, { send, initialContext }) {
238
- return trackFormControl(dom.getHiddenInputEl(ctx$1), {
234
+ trackFormControlState(ctx, _evt, { send, initialContext }) {
235
+ return trackFormControl(dom.getHiddenInputEl(ctx), {
239
236
  onFieldsetDisabledChange(disabled) {
240
- ctx$1.fieldsetDisabled = disabled;
237
+ ctx.fieldsetDisabled = disabled;
241
238
  },
242
239
  onFormReset() {
243
240
  send({
@@ -249,31 +246,30 @@ function machine(userContext) {
249
246
  }
250
247
  },
251
248
  actions: {
252
- setContext(ctx$1, evt) {
253
- Object.assign(ctx$1, evt.context);
249
+ setContext(ctx, evt) {
250
+ Object.assign(ctx, evt.context);
254
251
  },
255
- syncInputElement(ctx$1) {
256
- const inputEl = dom.getHiddenInputEl(ctx$1);
252
+ syncInputElement(ctx) {
253
+ const inputEl = dom.getHiddenInputEl(ctx);
257
254
  if (!inputEl) return;
258
- setElementChecked(inputEl, ctx$1.isChecked);
259
- inputEl.indeterminate = ctx$1.isIndeterminate;
255
+ setElementChecked(inputEl, ctx.isChecked);
256
+ inputEl.indeterminate = ctx.isIndeterminate;
260
257
  },
261
- removeFocusIfNeeded(ctx$1) {
262
- if (ctx$1.disabled && ctx$1.focused) {
263
- ctx$1.focused = false;
264
- ctx$1.focusVisible = false;
258
+ removeFocusIfNeeded(ctx) {
259
+ if (ctx.disabled && ctx.focused) {
260
+ ctx.focused = false;
261
+ ctx.focusVisible = false;
265
262
  }
266
263
  },
267
- setChecked(ctx$1, evt) {
268
- set.checked(ctx$1, evt.checked);
264
+ setChecked(ctx, evt) {
265
+ set.checked(ctx, evt.checked);
269
266
  },
270
- toggleChecked(ctx$1) {
271
- const checked = isIndeterminate(ctx$1.checked) ? true : !ctx$1.checked;
272
- set.checked(ctx$1, checked);
267
+ toggleChecked(ctx) {
268
+ const checked = isIndeterminate(ctx.checked) ? true : !ctx.checked;
269
+ set.checked(ctx, checked);
273
270
  },
274
- dispatchChangeEvent(ctx$1) {
275
- const inputEl = dom.getHiddenInputEl(ctx$1);
276
- dispatchInputCheckedEvent(inputEl, { checked: isChecked(ctx$1.checked) });
271
+ dispatchChangeEvent(ctx) {
272
+ dispatchInputCheckedEvent(dom.getHiddenInputEl(ctx), { checked: isChecked(ctx.checked) });
277
273
  }
278
274
  }
279
275
  });
package/package.json CHANGED
@@ -1,27 +1,36 @@
1
1
  {
2
2
  "name": "@destyler/checkbox",
3
3
  "type": "module",
4
- "version": "0.0.7-beta.9",
4
+ "version": "0.2.0-beta.5",
5
5
  "description": "a control that allows the user to toggle between checked and not checked.",
6
6
  "author": "Elone Hoo <elonehoo@gmail.com>",
7
7
  "license": "MIT",
8
+ "homepage": "https://github.com/destyler/destyler",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/destyler/destyler.git",
12
+ "directory": "packages/components/checkbox"
13
+ },
8
14
  "exports": {
9
- ".": "./dist/index.js"
15
+ ".": "./dist/index.mjs"
10
16
  },
11
- "main": "dist/index.js",
12
- "module": "dist/index.js",
13
- "types": "dist/index.d.ts",
17
+ "main": "dist/index.mjs",
18
+ "module": "dist/index.mjs",
19
+ "types": "dist/index.d.mts",
14
20
  "files": [
15
21
  "*.d.ts",
16
22
  "dist"
17
23
  ],
18
24
  "dependencies": {
19
- "@destyler/anatomy": "0.0.7-beta.9",
20
- "@destyler/dom": "0.0.7-beta.9",
21
- "@destyler/focus-visible": "0.0.7-beta.9",
22
- "@destyler/types": "0.0.7-beta.9",
23
- "@destyler/utils": "0.0.7-beta.9",
24
- "@destyler/xstate": "0.0.7-beta.9"
25
+ "@destyler/anatomy": "0.2.0-beta.5",
26
+ "@destyler/dom": "0.2.0-beta.5",
27
+ "@destyler/focus-visible": "0.2.0-beta.5",
28
+ "@destyler/utils": "0.2.0-beta.5",
29
+ "@destyler/xstate": "0.2.0-beta.5",
30
+ "@destyler/types": "0.2.0-beta.5"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
25
34
  },
26
35
  "scripts": {
27
36
  "clear": "rimraf ./dist",