Socket
Socket
Sign inDemoInstall

@zag-js/dom-utils

Package Overview
Dependencies
Maintainers
1
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/dom-utils - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/typeahead.d.ts

1

dist/index.d.ts

@@ -27,2 +27,3 @@ export * from "./attrs";

export * from "./wait";
export * from "./typeahead";
//# sourceMappingURL=index.d.ts.map

@@ -43,2 +43,3 @@ var __create = Object.create;

findByText: () => findByText,
findByTypeahead: () => findByTypeahead,
focusableSelector: () => focusableSelector,

@@ -65,2 +66,3 @@ forceReflow: () => forceReflow,

isDisabled: () => isDisabled,
isElementEditable: () => isElementEditable,
isFocusable: () => isFocusable,

@@ -466,2 +468,13 @@ isHTMLElement: () => isHTMLElement,

}
function isElementEditable(el) {
if (el == null)
return false;
const selectors = [
"input:not([readonly])",
"textarea:not([readonly])",
"[contenteditable]",
"select:not([readonly])"
].join(", ");
return el.matches(selectors) || el.isContentEditable;
}

@@ -876,9 +889,18 @@ // src/scrollable.ts

}
var getValueText = (item) => {
var _a, _b;
return (_b = (_a = item.dataset.valuetext) != null ? _a : item.textContent) != null ? _b : "";
};
var match = (valueText, query2) => valueText.toLowerCase().startsWith(query2.toLowerCase());
var wrap = (v, idx) => {
return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
};
function findByText(v, text, currentId) {
const filtered = v.filter((item) => {
var _a;
const str = (_a = item.dataset.valuetext) != null ? _a : item.textContent;
return !!(str == null ? void 0 : str.toLowerCase().startsWith(text.toLowerCase()));
});
return currentId ? nextById(filtered, currentId) : null;
const index = currentId ? indexOfId(v, currentId) : -1;
let items = currentId ? wrap(v, index) : v;
const isSingleKey = text.length === 1;
if (isSingleKey) {
items = items.filter((item) => item.id !== currentId);
}
return items.find((item) => match(getValueText(item), text));
}

@@ -1114,2 +1136,32 @@ function sortByTreeOrder(v) {

}
// src/typeahead.ts
function findByTypeahead(_items, options) {
const { state: state2, activeId, key, timeout = 350 } = options;
const search = state2.keysSoFar + key;
const isRepeated = search.length > 1 && Array.from(search).every((char) => char === search[0]);
const query2 = isRepeated ? search[0] : search;
let items = _items.slice();
const next = findByText(items, query2, activeId);
function cleanup() {
clearTimeout(state2.timer);
state2.timer = -1;
}
function update(value) {
state2.keysSoFar = value;
cleanup();
if (value !== "") {
state2.timer = +setTimeout(() => {
update("");
cleanup();
}, timeout);
}
}
update(search);
return next;
}
findByTypeahead.defaultOptions = {
keysSoFar: "",
timer: -1
};
//# sourceMappingURL=index.js.map

@@ -14,3 +14,4 @@ /// <reference types="react" />

export declare function getNativeEvent<E>(event: E): React.ChangeEvent<any> extends E ? InputEvent : E extends React.SyntheticEvent<any, infer T> ? T : never;
export declare function isElementEditable(el: HTMLElement | null): boolean;
export {};
//# sourceMappingURL=query.d.ts.map

6

package.json
{
"name": "@zag-js/dom-utils",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -29,3 +29,3 @@ "keywords": [

"@types/react": "^18.0.0",
"@zag-js/utils": "^0.1.0",
"@zag-js/utils": "0.1.1",
"scroll-into-view-if-needed": "^2.2.29"

@@ -42,2 +42,2 @@ },

}
}
}

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

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

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