@zag-js/solid
Advanced tools
Comparing version 0.0.0-dev-20220413091534 to 0.0.0-dev-20220413174154
declare type StyleObject = Record<string, any>; | ||
export declare function cssify(style: StyleObject): StyleObject; | ||
export {}; | ||
//# sourceMappingURL=cssify.d.ts.map |
@@ -6,1 +6,2 @@ export * from "./normalize-props"; | ||
export * from "./use-setup"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,166 @@ | ||
var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var M=(e,t)=>{for(var n in t)f(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of j(t))!w.call(e,r)&&r!==n&&f(e,r,{get:()=>t[r],enumerable:!(o=P(t,r))||o.enumerable});return e};var N=e=>k(f({},"__esModule",{value:!0}),e);var W={};M(W,{normalizeProps:()=>R,useActor:()=>B,useMachine:()=>J,useSetup:()=>U});module.exports=N(W);function y(e){return{button:e,label:e,input:e,output:e,element:e}}var _=y(e=>e);var G=(()=>{let e=0;return()=>(e++,e.toString(36))})();var K=e=>Array.isArray(e);var S=e=>!(e==null||typeof e!="object"||K(e)),d=e=>typeof e=="number"&&!Number.isNaN(e),c=e=>typeof e=="string";var D=/[A-Z]/g,I=/^ms-/,m={};function F(e){return"-"+e.toLowerCase()}function z(e){if(m.hasOwnProperty(e))return m[e];var t=e.replace(D,F);return m[e]=I.test(t)?"-"+t:t}var v=z;var H=e=>e.startsWith("--")?e:v(e);function x(e){let t={};for(let n in e){let o=e[n];!c(o)&&!d(o)||(t[H(n)]=o)}return t}var h={onFocus:"onFocusIn",onBlur:"onFocusOut",onDoubleClick:"onDblClick",onChange:"onInput"};function L(e){return e in h?h[e]:e}var R=y(e=>{let t={};for(let n in e){let o=e[n];if(n==="style"&&S(o)){t.style=x(o);continue}if(n==="children"){c(o)&&(t.textContent=o);continue}t[L(n)]=o}return t});var g=require("solid-js"),T=require("solid-js/store");var b=e=>JSON.parse(JSON.stringify(e)),u=e=>({value:String(e.value),previousValue:String(e.previousValue),context:b(e.context),event:b(e.event),done:Boolean(e.done),tags:Array.from(e.tags)});function B(e){let[t,n]=(0,T.createStore)(u(e.state)),o=e.subscribe(r=>{n(r)});return(0,g.onCleanup)(()=>{o()}),[t,e.send]}var a=require("solid-js"),p=require("solid-js/store");function J(e,t){let{actions:n,state:o,preserve:r,context:i}=t!=null?t:{},s=typeof e=="function"?e():r?e:e.clone(),[E,O]=(0,p.createStore)(u(s.state));s.start(o),(0,a.createEffect)(()=>{i&&s.setContext(i)});let A=s.subscribe(C=>{O((0,p.reconcile)(C))});return(0,a.onCleanup)(()=>{A(),s.stop()}),(0,a.onMount)(()=>{s.setActions(n)}),[E,s.send,s]}var l=require("solid-js");function U(e){let{send:t,id:n}=e,[o,r]=(0,l.createSignal)();return(0,l.onMount)(()=>{Promise.resolve().then(()=>{var i;t({type:"SETUP",doc:(i=o())==null?void 0:i.ownerDocument,id:n})})}),r} | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
normalizeProps: () => normalizeProps, | ||
useActor: () => useActor, | ||
useMachine: () => useMachine, | ||
useSetup: () => useSetup | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
// ../../types/src/prop-types.ts | ||
function createNormalizer(fn) { | ||
return { button: fn, label: fn, input: fn, output: fn, element: fn }; | ||
} | ||
var normalizeProp = createNormalizer((v) => v); | ||
// ../../utilities/core/src/guard.ts | ||
var isArray = (v) => Array.isArray(v); | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v); | ||
var isString = (v) => typeof v === "string"; | ||
// ../../../node_modules/hyphenate-style-name/index.js | ||
var uppercasePattern = /[A-Z]/g; | ||
var msPattern = /^ms-/; | ||
var cache = {}; | ||
function toHyphenLower(match) { | ||
return "-" + match.toLowerCase(); | ||
} | ||
function hyphenateStyleName(name) { | ||
if (cache.hasOwnProperty(name)) { | ||
return cache[name]; | ||
} | ||
var hName = name.replace(uppercasePattern, toHyphenLower); | ||
return cache[name] = msPattern.test(hName) ? "-" + hName : hName; | ||
} | ||
var hyphenate_style_name_default = hyphenateStyleName; | ||
// src/cssify.ts | ||
var format = (v) => v.startsWith("--") ? v : hyphenate_style_name_default(v); | ||
function cssify(style) { | ||
let css = {}; | ||
for (const property in style) { | ||
const value = style[property]; | ||
if (!isString(value) && !isNumber(value)) | ||
continue; | ||
css[format(property)] = value; | ||
} | ||
return css; | ||
} | ||
// src/normalize-props.ts | ||
var eventMap = { | ||
onFocus: "onFocusIn", | ||
onBlur: "onFocusOut", | ||
onDoubleClick: "onDblClick", | ||
onChange: "onInput" | ||
}; | ||
function toSolidProp(prop) { | ||
return prop in eventMap ? eventMap[prop] : prop; | ||
} | ||
var normalizeProps = createNormalizer((props) => { | ||
const normalized = {}; | ||
for (const key in props) { | ||
const value = props[key]; | ||
if (key === "style" && isObject(value)) { | ||
normalized["style"] = cssify(value); | ||
continue; | ||
} | ||
if (key === "children") { | ||
if (isString(value)) { | ||
normalized["textContent"] = value; | ||
} | ||
continue; | ||
} | ||
normalized[toSolidProp(key)] = value; | ||
} | ||
return normalized; | ||
}); | ||
// src/use-actor.ts | ||
var import_solid_js = require("solid-js"); | ||
var import_store = require("solid-js/store"); | ||
// src/unwrap.ts | ||
var toPOJO = (v) => JSON.parse(JSON.stringify(v)); | ||
var unwrap = (state) => ({ | ||
value: String(state.value), | ||
previousValue: String(state.previousValue), | ||
context: toPOJO(state.context), | ||
event: toPOJO(state.event), | ||
done: Boolean(state.done), | ||
tags: Array.from(state.tags) | ||
}); | ||
// src/use-actor.ts | ||
function useActor(service) { | ||
const [current, setCurrent] = (0, import_store.createStore)(unwrap(service.state)); | ||
const unsubscribe = service.subscribe((state) => { | ||
setCurrent(state); | ||
}); | ||
(0, import_solid_js.onCleanup)(() => { | ||
unsubscribe(); | ||
}); | ||
return [current, service.send]; | ||
} | ||
// src/use-machine.ts | ||
var import_solid_js2 = require("solid-js"); | ||
var import_store2 = require("solid-js/store"); | ||
function useMachine(machine, options) { | ||
const { actions, state: hydratedState, preserve, context } = options != null ? options : {}; | ||
const service = typeof machine === "function" ? machine() : preserve ? machine : machine.clone(); | ||
const [state, setState] = (0, import_store2.createStore)(unwrap(service.state)); | ||
service.start(hydratedState); | ||
(0, import_solid_js2.createEffect)(() => { | ||
if (context) { | ||
service.setContext(context); | ||
} | ||
}); | ||
const unsubscribe = service.subscribe((s) => { | ||
setState((0, import_store2.reconcile)(s)); | ||
}); | ||
(0, import_solid_js2.onCleanup)(() => { | ||
unsubscribe(); | ||
service.stop(); | ||
}); | ||
(0, import_solid_js2.onMount)(() => { | ||
service.setActions(actions); | ||
}); | ||
const _state = state; | ||
return [_state, service.send, service]; | ||
} | ||
// src/use-setup.ts | ||
var import_solid_js3 = require("solid-js"); | ||
function useSetup(props) { | ||
const { send, id } = props; | ||
const [el, setEl] = (0, import_solid_js3.createSignal)(); | ||
(0, import_solid_js3.onMount)(() => { | ||
Promise.resolve().then(() => { | ||
var _a; | ||
send({ type: "SETUP", doc: (_a = el()) == null ? void 0 : _a.ownerDocument, id }); | ||
}); | ||
}); | ||
return setEl; | ||
} | ||
//# sourceMappingURL=index.js.map |
export declare const normalizeProps: import("@zag-js/types").NormalizeProps; | ||
//# sourceMappingURL=normalize-props.d.ts.map |
@@ -11,1 +11,2 @@ import type * as Solid from "solid-js"; | ||
export {}; | ||
//# sourceMappingURL=prop-types.d.ts.map |
@@ -9,1 +9,2 @@ export declare const unwrap: (state: any) => { | ||
}; | ||
//# sourceMappingURL=unwrap.d.ts.map |
import { Machine, StateMachine as S } from "@zag-js/core"; | ||
export declare function useActor<TContext extends Record<string, any>, TState extends S.StateSchema, TEvent extends S.EventObject = S.AnyEventObject>(service: Machine<TContext, TState, TEvent>): readonly [S.State<TContext, TState, TEvent>, (evt: S.Event<TEvent>) => void]; | ||
//# sourceMappingURL=use-actor.d.ts.map |
@@ -8,1 +8,2 @@ import { MachineSrc, StateMachine as S } from "@zag-js/core"; | ||
export {}; | ||
//# sourceMappingURL=use-machine.d.ts.map |
@@ -7,1 +7,2 @@ import type { StateMachine as S } from "@zag-js/core"; | ||
export declare function useSetup<T extends HTMLElement = HTMLDivElement>(props: UseSetupProps): import("solid-js").Setter<T>; | ||
//# sourceMappingURL=use-setup.d.ts.map |
{ | ||
"name": "@zag-js/solid", | ||
"version": "0.0.0-dev-20220413091534", | ||
"version": "0.0.0-dev-20220413174154", | ||
"description": "The solid.js wrapper for zag", | ||
@@ -22,3 +22,3 @@ "keywords": [ | ||
"files": [ | ||
"dist" | ||
"dist/**/*" | ||
], | ||
@@ -32,3 +32,3 @@ "publishConfig": { | ||
"dependencies": { | ||
"@zag-js/core": "0.0.0-dev-20220413091534", | ||
"@zag-js/core": "0.0.0-dev-20220413174154", | ||
"hyphenate-style-name": "^1.0.4", | ||
@@ -42,3 +42,12 @@ "valtio": "^1.5.2" | ||
"solid-js": ">=1.1.3" | ||
}, | ||
"scripts": { | ||
"build:fast": "zag build", | ||
"start": "zag build --watch", | ||
"build": "zag build --prod", | ||
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests", | ||
"lint": "eslint src --ext .ts,.tsx", | ||
"test:ci": "yarn test --ci --runInBand", | ||
"test:watch": "yarn test --watch --updateSnapshot" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
21
333
1
41445
1
+ Added@zag-js/core@0.0.0-dev-20220413174154(transitive)
- Removed@zag-js/core@0.0.0-dev-20220413091534(transitive)