anu-verzum 2.2.0 → 2.2.1

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.
package/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  <h3>@author: <strong>Anubis-programmer</strong></h3>
6
6
  <h3>@license: <strong>MIT</strong></h3>
7
- <h3>@version: <strong>2.2.0</strong></h3>
8
7
 
9
8
  <br>
10
9
 
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.updateDomProperties = exports.getHTMLValidSvgTag = exports.createDomElement = exports.SVG_ELEMENT_LIST = void 0;
7
7
  var _elements = require("./elements");
8
+ const HTML_ATTRIBUTE_NAME_MAP = {
9
+ acceptCharset: 'accept-charset',
10
+ httpEquiv: 'http-equiv'
11
+ };
8
12
  const getHTMLValidSvgTag = fiberType => {
9
13
  switch (fiberType) {
10
14
  case 'anchor':
@@ -46,8 +50,18 @@ const updateDomProperties = (dom, prevProps, nextProps, isSvgElement = false) =>
46
50
  dom.setAttribute(name, nextProps[name]);
47
51
  }
48
52
  } else {
49
- if (name.includes('-') || name === 'role') {
53
+ if (name === 'className' || name === 'htmlFor') {
54
+ // Both have working IDL aliases (el.className / el.htmlFor).
55
+ el[name] = nextProps[name];
56
+ } else if (name.includes('-') || name === 'role') {
50
57
  dom.setAttribute(name, nextProps[name]);
58
+ } else if (dom.nodeType === 1 && /[A-Z]/.test(name)) {
59
+ // camelCase HTML attribute (inputMode, autoComplete, …): the
60
+ // DOM name is the lowercased key, except for the hyphenated
61
+ // cases captured in HTML_ATTRIBUTE_NAME_MAP. Setting these as
62
+ // IDL properties is unreliable (e.g. el.autoComplete is not a
63
+ // reflected property), so route them through setAttribute.
64
+ dom.setAttribute(HTML_ATTRIBUTE_NAME_MAP[name] ?? name.toLowerCase(), nextProps[name]);
51
65
  } else {
52
66
  el[name] = nextProps[name];
53
67
  }
@@ -1,17 +1,19 @@
1
- type EventInit = globalThis.EventInit & Record<string, any>;
1
+ type EventInit = globalThis.EventInit & {
2
+ target?: Record<string, any>;
3
+ } & Record<string, any>;
2
4
  export declare const fireEvent: {
3
5
  (element: Element, eventName: string, init?: EventInit): boolean;
4
- click(el: Element, init?: MouseEventInit): boolean;
5
- dblclick(el: Element, init?: MouseEventInit): boolean;
6
- change(el: Element, init?: globalThis.EventInit): boolean;
7
- input(el: Element, init?: globalThis.EventInit): boolean;
8
- focus(el: Element, init?: FocusEventInit): boolean;
9
- blur(el: Element, init?: FocusEventInit): boolean;
10
- keyDown(el: Element, init?: KeyboardEventInit): boolean;
11
- keyUp(el: Element, init?: KeyboardEventInit): boolean;
12
- keyPress(el: Element, init?: KeyboardEventInit): boolean;
13
- submit(el: Element, init?: globalThis.EventInit): boolean;
14
- mouseDown(el: Element, init?: MouseEventInit): boolean;
15
- mouseUp(el: Element, init?: MouseEventInit): boolean;
6
+ click(el: Element, init?: EventInit): boolean;
7
+ dblclick(el: Element, init?: EventInit): boolean;
8
+ change(el: Element, init?: EventInit): boolean;
9
+ input(el: Element, init?: EventInit): boolean;
10
+ focus(el: Element, init?: EventInit): boolean;
11
+ blur(el: Element, init?: EventInit): boolean;
12
+ keyDown(el: Element, init?: EventInit): boolean;
13
+ keyUp(el: Element, init?: EventInit): boolean;
14
+ keyPress(el: Element, init?: EventInit): boolean;
15
+ submit(el: Element, init?: EventInit): boolean;
16
+ mouseDown(el: Element, init?: EventInit): boolean;
17
+ mouseUp(el: Element, init?: EventInit): boolean;
16
18
  };
17
19
  export {};
@@ -26,7 +26,14 @@ const buildEvent = (eventName, init) => {
26
26
  return new Event(eventName, opts);
27
27
  };
28
28
  const fireEvent = (element, eventName, init) => {
29
- const dispatched = element.dispatchEvent(buildEvent(eventName, init));
29
+ const {
30
+ target,
31
+ ...eventInit
32
+ } = init ?? {};
33
+ if (target) {
34
+ Object.assign(element, target);
35
+ }
36
+ const dispatched = element.dispatchEvent(buildEvent(eventName, eventInit));
30
37
  (0, _act.flushEffects)();
31
38
  return dispatched;
32
39
  };
@@ -9,9 +9,6 @@ const IMPLICIT_ROLES = {
9
9
  button: ['button'],
10
10
  link: ['a'],
11
11
  heading: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
12
- textbox: ['input'],
13
- checkbox: ['input[type="checkbox"]'],
14
- radio: ['input[type="radio"]'],
15
12
  combobox: ['select'],
16
13
  img: ['img'],
17
14
  list: ['ul', 'ol'],
@@ -22,6 +19,21 @@ const IMPLICIT_ROLES = {
22
19
  banner: ['header'],
23
20
  contentinfo: ['footer']
24
21
  };
22
+ const INPUT_TYPE_ROLES = {
23
+ text: 'textbox',
24
+ search: 'textbox',
25
+ email: 'textbox',
26
+ tel: 'textbox',
27
+ url: 'textbox',
28
+ number: 'spinbutton',
29
+ range: 'slider',
30
+ checkbox: 'checkbox',
31
+ radio: 'radio',
32
+ button: 'button',
33
+ submit: 'button',
34
+ reset: 'button',
35
+ image: 'button'
36
+ };
25
37
  const getAccessibleName = el => {
26
38
  const ariaLabel = el.getAttribute('aria-label');
27
39
  if (ariaLabel) {
@@ -44,17 +56,15 @@ const hasRole = (el, role) => {
44
56
  if (el.getAttribute('role') === role) {
45
57
  return true;
46
58
  }
59
+ if (el.tagName.toLowerCase() === 'input') {
60
+ const type = (el.getAttribute('type') ?? 'text').toLowerCase();
61
+ return INPUT_TYPE_ROLES[type] === role;
62
+ }
47
63
  const selectors = IMPLICIT_ROLES[role];
48
64
  if (!selectors) {
49
65
  return false;
50
66
  }
51
- return selectors.some(sel => {
52
- if (sel === 'input' && role === 'textbox') {
53
- const type = el.getAttribute('type') ?? 'text';
54
- return el.tagName.toLowerCase() === 'input' && ['text', 'search', 'email', 'tel', 'url'].indexOf(type) >= 0;
55
- }
56
- return el.matches(sel);
57
- });
67
+ return selectors.some(sel => el.matches(sel));
58
68
  };
59
69
  const queryAllByRole = (container, role, options) => {
60
70
  const results = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anu-verzum",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "A \"React-like\" UI library that supports JSX syntax, Redux-like state management, array-rendering, i18n, routing and many more.",
5
5
  "keywords": [
6
6
  "anu-verzum",