@shineuix/react 1.0.0 → 1.0.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
@@ -10,7 +10,7 @@ npm i @shineuix/core @shineuix/react
10
10
  import { SuiButton, SuiInputText } from '@shineuix/react';
11
11
  import '@shineuix/core/shineui.css';
12
12
 
13
- <SuiButton variant="accent" label="Pay bills" onClick={pay} />
13
+ <SuiButton variant="accent" label="Record payment" onClick={recordPayment} />
14
14
  <SuiInputText label="Customer email" required onSuiChange={(e) => save(e.detail)} />
15
15
  ```
16
16
 
package/dist/runtime.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Vendored from @stencil/react-output-target 1.6.2, src/runtime/create-component.ts.
3
3
  * The MIT License (MIT). Copyright (c) 2019-present Drifty Co.
4
- * Changed here: the wrapper renders nothing on the server and during hydration (useClientRender).
4
+ * Changed here: the wrapper renders nothing on the server and during hydration (useClientRender),
5
+ * and `slot` is written when React creates the element (beforeInsert).
5
6
  */
6
7
  import type { EventName, Options } from '@lit/react';
7
8
  import React from 'react';
package/dist/runtime.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /*!
2
2
  * Vendored from @stencil/react-output-target 1.6.2, src/runtime/create-component.ts.
3
3
  * The MIT License (MIT). Copyright (c) 2019-present Drifty Co.
4
- * Changed here: the wrapper renders nothing on the server and during hydration (useClientRender).
4
+ * Changed here: the wrapper renders nothing on the server and during hydration (useClientRender),
5
+ * and `slot` is written when React creates the element (beforeInsert).
5
6
  */
6
7
  import { createComponent as createComponentWrapper } from '@lit/react';
7
8
  import React from 'react';
@@ -39,12 +40,32 @@ const subscribeNever = () => () => { };
39
40
  * its first render.
40
41
  */
41
42
  const useClientRender = () => React.useSyncExternalStore(subscribeNever, () => true, () => false);
43
+ /**
44
+ * Props React has to write when it creates the element, before it inserts it anywhere.
45
+ *
46
+ * @lit/react sets every prop the element's prototype knows as a property in a layout effect, after
47
+ * React has inserted the element. That is too late for `slot`. A ShineUI element draws in its own
48
+ * light DOM, and it files a child under a slot when the child is inserted, as a shadow host would
49
+ * on assignment. A `SuiButton slot="actions"` that React adds to a rendered page header arrived
50
+ * with no slot, went to the default slot (the title) and stayed there when its slot came a moment
51
+ * later. On the first render it happened to work, because the header draws after the effect.
52
+ * Hiding these names from the prototype check makes @lit/react hand them to React, which writes
53
+ * them while it creates the element.
54
+ */
55
+ const beforeInsert = new Set(['slot']);
56
+ function withAttributesFirst(elementClass) {
57
+ // A server import may hand over no class at all; @lit/react reads it only in a client render.
58
+ if (!elementClass || typeof elementClass.prototype !== 'object' || typeof Proxy === 'undefined')
59
+ return elementClass;
60
+ const prototype = new Proxy(elementClass.prototype, { has: (target, key) => !beforeInsert.has(key) && Reflect.has(target, key) });
61
+ return { name: elementClass.name, prototype };
62
+ }
42
63
  export const createComponent = ({ defineCustomElement, tagName, transformTag, ...options }) => {
43
64
  if (typeof defineCustomElement !== 'undefined') {
44
65
  defineCustomElement();
45
66
  }
46
67
  const finalTagName = transformTag ? transformTag(tagName) : tagName;
47
- const ReactComponent = createComponentWrapper({ ...options, tagName: finalTagName });
68
+ const ReactComponent = createComponentWrapper({ ...options, elementClass: withAttributesFirst(options.elementClass), tagName: finalTagName });
48
69
  const WrappedComponent = React.forwardRef((props, ref) => {
49
70
  const { className, class: classProp, ...restProps } = props;
50
71
  const incomingClassName = className ?? classProp ?? '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shineuix/react",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React bindings for ShineUI web components.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@lit/react": "^1.0.8",
37
- "@shineuix/core": "1.0.0"
37
+ "@shineuix/core": "1.0.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": "^18 || ^19",
@@ -56,6 +56,11 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "git+https://github.com/smallandsimple/shineui.git",
62
+ "directory": "packages/react"
63
+ },
59
64
  "scripts": {
60
65
  "build": "tsc -p tsconfig.json && node scripts/vendor-runtime.mjs"
61
66
  }