Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/rating-group

Package Overview
Dependencies
Maintainers
1
Versions
793
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/rating-group - npm Package Compare versions

Comparing version 0.0.0-dev-20221228102655 to 0.0.0-dev-20221228121448

dist/chunk-3TK4DFZD.mjs

122

dist/index.d.ts

@@ -1,115 +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" | "hiddenInput" | "label" | "rating" | "control">;
type IntlTranslations = {
ratingValueText(index: number): string;
};
type ElementIds = Partial<{
root: string;
label: string;
hiddenInput: string;
control: string;
rating(id: string): string;
}>;
type PublicContext = DirectionProperty & CommonProperties & {
/**
* The ids of the elements in the rating. Useful for composition.
*/
ids?: ElementIds;
/**
* Specifies the localized strings that identifies the accessibility elements and their states
*/
translations: IntlTranslations;
/**
* The maximum rating value.
*/
max: number;
/**
* The name attribute of the rating element (used in forms).
*/
name?: string;
/**
* The associate form of the underlying input element.
*/
form?: string;
/**
* The current rating value.
*/
value: number;
/**
* Whether the rating is readonly.
*/
readOnly?: boolean;
/**
* Whether the rating is disabled.
*/
disabled?: boolean;
/**
* Whether to allow half stars.
*/
allowHalf?: boolean;
/**
* Whether to autofocus the rating.
*/
autoFocus?: boolean;
/**
* Function to be called when the rating value changes.
*/
onChange?: (details: {
value: number;
}) => void;
/**
* Function to be called when the rating value is hovered.
*/
onHover?: (details: {
value: number;
}) => void;
};
type UserDefinedContext = RequiredBy<PublicContext, "id">;
type ComputedContext = Readonly<{
/**
* @computed Whether the rating is interactive
*/
readonly isInteractive: boolean;
/**
* @computed Whether the pointer is hovering over the rating
*/
readonly isHovering: boolean;
}>;
type PrivateContext = Context<{}>;
type MachineContext = PublicContext & ComputedContext & PrivateContext;
type MachineState = {
value: "unknown" | "idle" | "hover" | "focus";
};
type State = StateMachine.State<MachineContext, MachineState>;
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
isHovering: boolean;
value: number;
hoveredValue: number;
size: number;
sizeArray: number[];
getRatingState(index: number): {
isEqual: boolean;
isValueEmpty: boolean;
isHighlighted: boolean;
isHalf: boolean;
isChecked: boolean;
};
rootProps: T["element"];
hiddenInputProps: T["input"];
labelProps: T["element"];
controlProps: T["element"];
getRatingProps({ index }: {
index: number;
}): T["element"];
};
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 './rating-group.anatomy.js';
export { connect } from './rating-group.connect.js';
export { machine } from './rating-group.machine.js';
export { UserDefinedContext as Context } from './rating-group.types.js';
import '@zag-js/anatomy';
import '@zag-js/types';
import '@zag-js/core';

@@ -34,3 +34,3 @@ "use strict";

// ../../utilities/dom/dist/index.mjs
// ../../utilities/dom/src/attrs.ts
var dataAttr = (guard) => {

@@ -42,5 +42,21 @@ return guard ? "" : void 0;

};
// ../../utilities/core/src/functions.ts
var cast = (v) => v;
// ../../utilities/core/src/guard.ts
var isArray = (v) => Array.isArray(v);
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
// ../../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) {

@@ -60,2 +76,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) {

@@ -98,2 +118,4 @@ const dom2 = {

}
// ../../utilities/dom/src/event.ts
function getNativeEvent(e) {

@@ -105,2 +127,4 @@ var _a;

var isLeftClick = (v) => v.button === 0;
// ../../utilities/dom/src/get-element-offset.ts
function getElementOffset(element) {

@@ -128,2 +152,4 @@ let left = 0;

}
// ../../utilities/dom/src/get-event-point.ts
var fallback = {

@@ -140,2 +166,4 @@ pageX: 0,

}
// ../../utilities/dom/src/get-point-relative-to-element.ts
function getPointRelativeToNode(point, element) {

@@ -147,2 +175,4 @@ const offset = getElementOffset(element);

}
// ../../utilities/dom/src/keyboard-event.ts
var rtlKeyMap = {

@@ -172,26 +202,4 @@ ArrowLeft: "ArrowRight",

}
function raf(fn) {
const id = globalThis.requestAnimationFrame(fn);
return function cleanup() {
globalThis.cancelAnimationFrame(id);
};
}
// ../../utilities/core/dist/index.mjs
var cast = (v) => v;
var isArray2 = (v) => Array.isArray(v);
var isObject2 = (v) => !(v == null || typeof v !== "object" || isArray2(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, isObject2(value) ? compact(value) : value])
);
}
// ../../utilities/form-utils/dist/index.mjs
function getWindow(el) {
var _a;
return (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
}
// ../../utilities/dom/src/mutation-observer.ts
function observeAttributes(node, attributes, fn) {

@@ -212,2 +220,12 @@ if (!node)

}
// ../../utilities/dom/src/next-tick.ts
function raf(fn) {
const id = globalThis.requestAnimationFrame(fn);
return function cleanup() {
globalThis.cancelAnimationFrame(id);
};
}
// ../../utilities/form-utils/src/input-event.ts
function getDescriptor(el, options) {

@@ -231,2 +249,4 @@ var _a;

}
// ../../utilities/form-utils/src/form.ts
function getClosestForm(el) {

@@ -233,0 +253,0 @@ if (isFormElement(el))

{
"name": "@zag-js/rating-group",
"version": "0.0.0-dev-20221228102655",
"version": "0.0.0-dev-20221228121448",
"description": "Core logic for the rating-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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc