@zag-js/radio-group
Advanced tools
Comparing version 0.0.0-dev-20221228102655 to 0.0.0-dev-20221228121448
@@ -1,105 +0,7 @@ | ||
import * as _zag_js_anatomy from '@zag-js/anatomy'; | ||
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types'; | ||
import * as _zag_js_core from '@zag-js/core'; | ||
import { StateMachine } from '@zag-js/core'; | ||
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "radio" | "radioLabel" | "radioControl" | "radioInput">; | ||
type ElementIds = Partial<{ | ||
root: string; | ||
label: string; | ||
radio(value: string): string; | ||
radioLabel(value: string): string; | ||
radioControl(value: string): string; | ||
radioInput(value: string): string; | ||
}>; | ||
type PublicContext = DirectionProperty & CommonProperties & { | ||
/** | ||
* The ids of the elements in the radio. Useful for composition. | ||
*/ | ||
ids?: ElementIds; | ||
/** | ||
* The value of the checked radio | ||
*/ | ||
value: string | null; | ||
/** | ||
* The name of the input fields in the radio | ||
* (Useful for form submission). | ||
*/ | ||
name?: string; | ||
/** | ||
* The associate form of the underlying input. | ||
*/ | ||
form?: string; | ||
/** | ||
* If `true`, the radio group will be disabled | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* If `true`, the radio group will be readonly | ||
*/ | ||
readOnly?: boolean; | ||
/** | ||
* Function called once a radio is checked | ||
* @param value the value of the checked radio | ||
*/ | ||
onChange?(details: { | ||
value: string; | ||
}): void; | ||
/** | ||
* Orientation of the radio group | ||
*/ | ||
orientation?: "horizontal" | "vertical"; | ||
}; | ||
type PrivateContext = Context<{}>; | ||
type UserDefinedContext = RequiredBy<PublicContext, "id">; | ||
type ComputedContext = Readonly<{}>; | ||
type MachineContext = PublicContext & PrivateContext & ComputedContext; | ||
type MachineState = { | ||
value: "unknown"; | ||
}; | ||
type State = StateMachine.State<MachineContext, MachineState>; | ||
type Send = StateMachine.Send<StateMachine.AnyEventObject>; | ||
type RadioProps = { | ||
value: string; | ||
/** | ||
* If `true`, the radio will be disabled | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* If `true`, the radio will be readonly | ||
*/ | ||
readOnly?: boolean; | ||
/** | ||
* If `true`, the radio is marked as invalid. | ||
*/ | ||
invalid?: boolean; | ||
}; | ||
type InputProps = RadioProps & { | ||
/** | ||
* If `true` and `disabled` is passed, the radio will | ||
* remain tabbable but not interactive | ||
*/ | ||
focusable?: boolean; | ||
/** | ||
* If `true`, the radio input is marked as required, | ||
*/ | ||
required?: boolean; | ||
}; | ||
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): { | ||
value: string | null; | ||
setValue(value: string): void; | ||
focus: () => void; | ||
blur(): void; | ||
rootProps: T["element"]; | ||
labelProps: T["element"]; | ||
getRadioProps(props: RadioProps): T["label"]; | ||
getRadioLabelProps(props: RadioProps): T["element"]; | ||
getRadioControlProps(props: RadioProps): T["element"]; | ||
getRadioInputProps(props: InputProps): T["input"]; | ||
}; | ||
declare function machine(userContext: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>; | ||
export { UserDefinedContext as Context, anatomy, connect, machine }; | ||
export { anatomy } from './radio-group.anatomy.js'; | ||
export { connect } from './radio-group.connect.js'; | ||
export { machine } from './radio-group.machine.js'; | ||
export { UserDefinedContext as Context } from './radio-group.types.js'; | ||
import '@zag-js/anatomy'; | ||
import '@zag-js/types'; | ||
import '@zag-js/core'; |
@@ -41,3 +41,3 @@ "use strict"; | ||
// ../../utilities/dom/dist/index.mjs | ||
// ../../utilities/dom/src/attrs.ts | ||
var dataAttr = (guard) => { | ||
@@ -49,2 +49,17 @@ return guard ? "" : void 0; | ||
}; | ||
// ../../utilities/core/src/guard.ts | ||
var isArray = (v) => Array.isArray(v); | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
// ../../utilities/core/src/object.ts | ||
function compact(obj) { | ||
if (obj === void 0) | ||
return obj; | ||
return Object.fromEntries( | ||
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value]) | ||
); | ||
} | ||
// ../../utilities/dom/src/query.ts | ||
function isDocument(el) { | ||
@@ -64,2 +79,6 @@ return el.nodeType === Node.DOCUMENT_NODE; | ||
} | ||
function getWindow(el) { | ||
var _a; | ||
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
} | ||
function defineDomHelpers(helpers) { | ||
@@ -102,2 +121,21 @@ const dom2 = { | ||
} | ||
// ../../utilities/dom/src/mutation-observer.ts | ||
function observeAttributes(node, attributes, fn) { | ||
if (!node) | ||
return; | ||
const attrs = Array.isArray(attributes) ? attributes : [attributes]; | ||
const win = node.ownerDocument.defaultView || window; | ||
const obs = new win.MutationObserver((changes) => { | ||
for (const change of changes) { | ||
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) { | ||
fn(change); | ||
} | ||
} | ||
}); | ||
obs.observe(node, { attributes: true, attributeFilter: attrs }); | ||
return () => obs.disconnect(); | ||
} | ||
// ../../utilities/dom/src/nodelist.ts | ||
function queryAll(root, selector) { | ||
@@ -107,2 +145,4 @@ var _a; | ||
} | ||
// ../../utilities/dom/src/visually-hidden.ts | ||
var visuallyHiddenStyle = { | ||
@@ -332,22 +372,3 @@ border: "0", | ||
// ../../utilities/form-utils/dist/index.mjs | ||
function getWindow(el) { | ||
var _a; | ||
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window; | ||
} | ||
function observeAttributes(node, attributes, fn) { | ||
if (!node) | ||
return; | ||
const attrs = Array.isArray(attributes) ? attributes : [attributes]; | ||
const win = node.ownerDocument.defaultView || window; | ||
const obs = new win.MutationObserver((changes) => { | ||
for (const change of changes) { | ||
if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) { | ||
fn(change); | ||
} | ||
} | ||
}); | ||
obs.observe(node, { attributes: true, attributeFilter: attrs }); | ||
return () => obs.disconnect(); | ||
} | ||
// ../../utilities/form-utils/src/input-event.ts | ||
function getDescriptor(el, options) { | ||
@@ -371,2 +392,4 @@ var _a; | ||
} | ||
// ../../utilities/form-utils/src/form.ts | ||
function getClosestForm(el) { | ||
@@ -413,13 +436,2 @@ if (isFormElement(el)) | ||
// ../../utilities/core/dist/index.mjs | ||
var isArray = (v) => Array.isArray(v); | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
function compact(obj) { | ||
if (obj === void 0) | ||
return obj; | ||
return Object.fromEntries( | ||
Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value]) | ||
); | ||
} | ||
// src/radio-group.machine.ts | ||
@@ -426,0 +438,0 @@ function machine(userContext) { |
{ | ||
"name": "@zag-js/radio-group", | ||
"version": "0.0.0-dev-20221228102655", | ||
"version": "0.0.0-dev-20221228121448", | ||
"description": "Core logic for the radio group widget implemented as a state machine", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"keywords": [ | ||
@@ -33,15 +30,28 @@ "js", | ||
"dependencies": { | ||
"@zag-js/anatomy": "0.0.0-dev-20221228102655", | ||
"@zag-js/core": "0.0.0-dev-20221228102655", | ||
"@zag-js/types": "0.3.1" | ||
"@zag-js/anatomy": "0.0.0-dev-20221228121448", | ||
"@zag-js/core": "0.0.0-dev-20221228121448", | ||
"@zag-js/types": "0.0.0-dev-20221228121448" | ||
}, | ||
"devDependencies": { | ||
"@zag-js/dom-utils": "0.2.1", | ||
"@zag-js/form-utils": "0.2.2", | ||
"@zag-js/utils": "0.3.1" | ||
"clean-package": "2.2.0", | ||
"@zag-js/dom-utils": "0.0.0-dev-20221228121448", | ||
"@zag-js/form-utils": "0.0.0-dev-20221228121448", | ||
"@zag-js/utils": "0.0.0-dev-20221228121448" | ||
}, | ||
"clean-package": "../../../clean-package.config.json", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"build-fast": "tsup src/index.ts --format=esm,cjs", | ||
"build-fast": "tsup src", | ||
"start": "pnpm build --watch", | ||
"build": "tsup src/index.ts --format=esm,cjs --dts", | ||
"build": "tsup src --dts", | ||
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests", | ||
@@ -48,0 +58,0 @@ "lint": "eslint src --ext .ts,.tsx", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
70781
25
2016
4
1
+ Added@zag-js/anatomy@0.0.0-dev-20221228121448(transitive)
+ Added@zag-js/core@0.0.0-dev-20221228121448(transitive)
+ Added@zag-js/store@0.0.0-dev-20221228121448(transitive)
+ Added@zag-js/types@0.0.0-dev-20221228121448(transitive)
- Removed@zag-js/anatomy@0.0.0-dev-20221228102655(transitive)
- Removed@zag-js/core@0.0.0-dev-20221228102655(transitive)
- Removed@zag-js/store@0.2.1(transitive)
- Removed@zag-js/types@0.3.1(transitive)