@rettangoli/ui 0.1.1 → 0.1.2-rc2
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 +76 -19
- package/dist/rettangoli-iife-layout.min.js +3 -3
- package/dist/rettangoli-iife-ui.min.js +50 -50
- package/package.json +8 -4
- package/src/components/form/form.handlers.js +20 -4
- package/src/components/form/form.view.yaml +3 -2
- package/src/primitives/input.js +4 -4
- package/src/common/BaseElement.js +0 -182
- package/src/lib/uhtml.js +0 -9
package/README.md
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
|
|
2
2
|
# Rettangoli
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
The following:
|
|
7
|
-
* rtgl-view
|
|
8
|
-
* rtgl-text
|
|
9
|
-
* rtgl-image
|
|
10
|
-
* rtgl-svg
|
|
11
|
-
* rtgl-button
|
|
12
|
-
* rtgl-input
|
|
13
|
-
* rtgl-textarea
|
|
14
|
-
|
|
15
|
-
All UI components should be able to be built from the above primitives
|
|
4
|
+
## Development
|
|
16
5
|
|
|
6
|
+
### Folder Structure
|
|
17
7
|
|
|
18
|
-
|
|
8
|
+
```
|
|
9
|
+
src/
|
|
10
|
+
├── primitives/ # Basic web components built from scratch, no dependencies
|
|
11
|
+
└── components/ # Pre-built components using @rettangoli/fe
|
|
12
|
+
vt/ # Uses @rettangoli/vt visual testing library
|
|
13
|
+
├── reference/ # Golden screenshots for visual testing
|
|
14
|
+
└── specs/ # HTML test specifications
|
|
15
|
+
```
|
|
19
16
|
|
|
20
17
|
### Install dependencies
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
Use npx to install `rtgl` cli globally. You run into issues if try to use `bunx`.
|
|
23
20
|
|
|
24
21
|
```bash
|
|
25
|
-
|
|
22
|
+
npx i -g rtgl
|
|
26
23
|
```
|
|
27
24
|
|
|
25
|
+
Install dependencies
|
|
28
26
|
|
|
27
|
+
```bash
|
|
28
|
+
bun install
|
|
29
|
+
```
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
### Generate test screens
|
|
31
|
+
### Generate specification screens
|
|
32
32
|
|
|
33
33
|
Bundles the code to be used for `rettangoli-vt`
|
|
34
34
|
|
|
@@ -39,11 +39,68 @@ bun run build:dev
|
|
|
39
39
|
Uses `rettangoli-vt` to generates test screens
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
bun run
|
|
42
|
+
bun run vt:generate
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Test for any change using `rettangoli-vt`
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
bun run vt:report
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Accept the changes by updating the reference screenshots
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
bun run vt:accept
|
|
43
55
|
```
|
|
44
56
|
|
|
45
57
|
You can then access the generates screens
|
|
46
58
|
|
|
47
59
|
```bash
|
|
48
|
-
|
|
60
|
+
bun run serve
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Open http://localhost:3000/view to see the specification screens
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
### Install via CDN
|
|
69
|
+
|
|
70
|
+
Use via CDN iife (Immediately Invoked Function Expression) us [JSDeliver](https://www.jsdelivr.com/package/npm/@rettangoli/ui)
|
|
71
|
+
|
|
72
|
+
Primitives only. This might be useful if you want a light weight version and use only the primitives.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<script src="https://cdn.jsdelivr.net/npm/@rettangoli/ui@latest/dist/rettangoli-layout.iife.min.js"></script>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
All primitives and components
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<script src="https://cdn.jsdelivr.net/npm/@rettangoli/ui@latest/dist/rettangoli-ui.iife.min.js"></script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Install via NPM
|
|
85
|
+
|
|
86
|
+
Install package
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install @rettangoli/ui
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Import the package. This allows you to configure more flexible options and to treeshake only the code that you need.
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
import { RettangoliView } '@rettangoli/ui';
|
|
96
|
+
customElements.define("rtgl-view", RettangoliView({}));
|
|
49
97
|
```
|
|
98
|
+
|
|
99
|
+
### Stylesheet file
|
|
100
|
+
|
|
101
|
+
Make sure you import a stylesheet file from your html file. [Example](./src/vt/static/public/theme.css)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
@@ -688,8 +688,8 @@ var rettangoli=(()=>{function h(e,...t){let s="";return e.forEach((r,g)=>{s+=r+(
|
|
|
688
688
|
font-weight: var(--xs-font-weight);
|
|
689
689
|
line-height: var(--xs-line-height);
|
|
690
690
|
letter-spacing: var(--xs-letter-spacing);
|
|
691
|
-
padding-left: var(--spacing-
|
|
692
|
-
padding-right: var(--spacing-
|
|
691
|
+
padding-left: var(--spacing-md);
|
|
692
|
+
padding-right: var(--spacing-md);
|
|
693
693
|
height: 24px;
|
|
694
694
|
}
|
|
695
695
|
input:focus {
|
|
@@ -700,7 +700,7 @@ var rettangoli=(()=>{function h(e,...t){let s="";return e.forEach((r,g)=>{s+=r+(
|
|
|
700
700
|
}
|
|
701
701
|
${b}
|
|
702
702
|
${m}
|
|
703
|
-
`))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._inputElement=document.createElement("input"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._inputElement),this._inputElement.addEventListener("
|
|
703
|
+
`))}constructor(){super(),e.initializeStyleSheet(),this.shadow=this.attachShadow({mode:"closed"}),this.shadow.adoptedStyleSheets=[e.styleSheet],this._styles={default:{},sm:{},md:{},lg:{},xl:{}},this._lastStyleString="",this._inputElement=document.createElement("input"),this._styleElement=document.createElement("style"),this.shadow.appendChild(this._styleElement),this.shadow.appendChild(this._inputElement),this._inputElement.addEventListener("input",this._onChange)}static get observedAttributes(){return["key","type","placeholder","disabled","s",...x([...y,"wh","w","h","hidden","visible","op","z"])]}get value(){return this._inputElement.value}_onChange=t=>{this.dispatchEvent(new CustomEvent("input-change",{detail:{value:this._inputElement.value}}))};attributeChangedCallback(t,s,r){if(["type","placeholder","disabled","s"].includes(t)){this._updateInputAttributes();return}this._styles={default:{},sm:{},md:{},lg:{},xl:{}},["default","sm","md","lg","xl"].forEach(i=>{let o=v=>`${i==="default"?"":`${i}-`}${v}`,l=this.getAttribute(o("wh")),a=c(l===null?this.getAttribute(o("w")):l),d=c(l===null?this.getAttribute(o("h")):l),u=this.getAttribute(o("op")),f=this.getAttribute(o("z"));f!==null&&(this._styles[i]["z-index"]=f),u!==null&&(this._styles[i].opacity=u),a==="f"?this._styles[i].width="var(--width-stretch)":a!==void 0&&(this._styles[i].width=a,this._styles[i]["min-width"]=a,this._styles[i]["max-width"]=a),d==="f"?this._styles[i].height="100%":d!==void 0&&(this._styles[i].height=d,this._styles[i]["min-height"]=d,this._styles[i]["max-height"]=d),this.hasAttribute(o("hidden"))&&(this._styles[i].display="none !important"),this.hasAttribute(o("visible"))&&(this._styles[i].display="block !important")});let g=w(this._styles,"input");g!==this._lastStyleString&&(this._styleElement.textContent=g,this._lastStyleString=g)}_updateInputAttributes(){let t=this.getAttribute("type")||"text",s=this.getAttribute("placeholder"),r=this.hasAttribute("disabled");this._inputElement.setAttribute("type",t),s!==null?this._inputElement.setAttribute("placeholder",s):this._inputElement.removeAttribute("placeholder"),r?this._inputElement.setAttribute("disabled",""):this._inputElement.removeAttribute("disabled")}connectedCallback(){this._updateInputAttributes()}},G=({render:e,html:t})=>O;var W=class e extends HTMLElement{static styleSheet=null;static initializeStyleSheet(){e.styleSheet||(e.styleSheet=new CSSStyleSheet,e.styleSheet.replaceSync(h`
|
|
704
704
|
:host {
|
|
705
705
|
display: contents;
|
|
706
706
|
}
|