@pepperi-addons/ngx-lib-react 0.0.1 → 0.0.2
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 +42 -0
- package/package.json +1 -1
- package/pep-button.js +9 -2
package/README.md
CHANGED
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
Thin React wrappers around Pepperi Angular Elements (Web Components) for better DX in React apps.
|
|
4
4
|
|
|
5
|
+
## Quickstart: test in another addon (0.0.1)
|
|
6
|
+
|
|
7
|
+
- **Install**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @pepperi-addons/ngx-lib-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- **Load Elements (embedded in this package)**
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// e.g., in src/index.tsx or src/main.tsx
|
|
17
|
+
import '@pepperi-addons/ngx-lib-react/elements/runtime.js';
|
|
18
|
+
import '@pepperi-addons/ngx-lib-react/elements/polyfills.js';
|
|
19
|
+
import '@pepperi-addons/ngx-lib-react/elements/main.js';
|
|
20
|
+
import '@pepperi-addons/ngx-lib-react/elements/styles.css';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **Theme wrapper**
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
export function App() {
|
|
27
|
+
return <div className="pepperi-theme">{/* ... */}</div>;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- **Use components**
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { PepButton, PepTextbox, PepSelect } from '@pepperi-addons/ngx-lib-react';
|
|
35
|
+
|
|
36
|
+
export function Example() {
|
|
37
|
+
return (
|
|
38
|
+
<div className="pepperi-theme">
|
|
39
|
+
<PepButton value="Save" styleType="strong" />
|
|
40
|
+
<PepTextbox label="Amount" type="currency" accessory="$" />
|
|
41
|
+
<PepSelect label="Status" options={[{ key: 'open', value: 'Open' }]} />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
5
47
|
This package expects you to load the Elements bundle and theme CSS (from `@pepperi-addons/ngx-lib-elements`) in your app.
|
|
6
48
|
|
|
7
49
|
## Install
|
package/package.json
CHANGED
package/pep-button.js
CHANGED
|
@@ -13,7 +13,14 @@ export const PepButton = ({ value, styleType, styleStateType, sizeType, disabled
|
|
|
13
13
|
el.iconName = iconName;
|
|
14
14
|
if (typeof iconPosition !== 'undefined')
|
|
15
15
|
el.iconPosition = iconPosition;
|
|
16
|
-
|
|
16
|
+
// Ensure style and size inputs are applied as properties so internal styling updates immediately
|
|
17
|
+
if (typeof styleType !== 'undefined')
|
|
18
|
+
el.styleType = styleType;
|
|
19
|
+
if (typeof styleStateType !== 'undefined')
|
|
20
|
+
el.styleStateType = styleStateType;
|
|
21
|
+
if (typeof sizeType !== 'undefined')
|
|
22
|
+
el.sizeType = sizeType;
|
|
23
|
+
}, [disabled, iconName, iconPosition, styleType, styleStateType, sizeType]);
|
|
17
24
|
// Attach events
|
|
18
25
|
useEffect(() => {
|
|
19
26
|
const el = ref.current;
|
|
@@ -23,6 +30,6 @@ export const PepButton = ({ value, styleType, styleStateType, sizeType, disabled
|
|
|
23
30
|
el.addEventListener('buttonClick', handler);
|
|
24
31
|
return () => el.removeEventListener('buttonClick', handler);
|
|
25
32
|
}, [onButtonClick]);
|
|
26
|
-
return (_jsx("pep-button", { ref: ref, value: value, "style-type": styleType, "style-state-type": styleStateType, "size-type": sizeType,
|
|
33
|
+
return (_jsx("pep-button", { ref: ref, value: value, "style-type": styleType, "style-state-type": styleStateType, "size-type": sizeType, className: className, ...rest }));
|
|
27
34
|
};
|
|
28
35
|
//# sourceMappingURL=pep-button.js.map
|