godown 3.0.0-canary.1 → 3.0.0-canary.11
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 +38 -9
- package/components/alert.d.ts +6 -3
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +22 -14
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +7 -2
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +13 -6
- package/components/avatar.js.map +1 -1
- package/components/breath.d.ts +4 -2
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +8 -6
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +20 -11
- package/components/button.d.ts.map +1 -1
- package/components/button.js +23 -20
- package/components/button.js.map +1 -1
- package/components/card.d.ts +2 -2
- package/components/card.d.ts.map +1 -1
- package/components/card.js +8 -13
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +8 -5
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +18 -11
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +7 -3
- package/components/details.d.ts.map +1 -1
- package/components/details.js +7 -3
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +9 -5
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +20 -14
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +3 -4
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +6 -7
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts +9 -8
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +3 -2
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts +3 -1
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js +13 -4
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +2 -3
- package/components/form.d.ts.map +1 -1
- package/components/form.js +0 -2
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +9 -3
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +6 -4
- package/components/grid.js.map +1 -1
- package/components/input.d.ts +4 -4
- package/components/input.d.ts.map +1 -1
- package/components/input.js +5 -7
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +4 -6
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +23 -12
- package/components/layout.js.map +1 -1
- package/components/link.d.ts +3 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +3 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +4 -12
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +9 -17
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +45 -18
- package/components/range.d.ts.map +1 -1
- package/components/range.js +133 -62
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +3 -2
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js +1 -1
- package/components/rotate.js.map +1 -1
- package/components/router.d.ts +15 -17
- package/components/router.d.ts.map +1 -1
- package/components/router.js +10 -10
- package/components/router.js.map +1 -1
- package/components/select.d.ts +6 -9
- package/components/select.d.ts.map +1 -1
- package/components/select.js +48 -43
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts +2 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +5 -5
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +20 -2
- package/components/split.d.ts.map +1 -1
- package/components/split.js +54 -20
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +6 -5
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +7 -6
- package/components/switch.js.map +1 -1
- package/components/text.d.ts +2 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +5 -6
- package/components/text.js.map +1 -1
- package/components/time.d.ts +6 -22
- package/components/time.d.ts.map +1 -1
- package/components/time.js +7 -67
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +13 -2
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +24 -5
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts +4 -4
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +4 -5
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +9 -2
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts +2 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +4 -3
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +5 -5
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +3 -6
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts +6 -3
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +38 -25
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +7 -2
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +28 -13
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +4 -2
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +20 -6
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +20 -11
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +34 -25
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +2 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +25 -30
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +8 -5
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +35 -20
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +7 -3
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +12 -4
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +9 -5
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +30 -24
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +3 -4
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +20 -8
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts +9 -8
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +8 -1
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +3 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +24 -4
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +2 -3
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +0 -2
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +9 -3
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +17 -4
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +4 -4
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +3 -21
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +4 -6
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +33 -13
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +3 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +3 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +4 -12
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +14 -18
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +45 -18
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +164 -109
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +3 -2
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +1 -1
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +15 -17
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +10 -10
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +6 -9
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +58 -45
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts +2 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +6 -6
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +20 -2
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +69 -32
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +6 -5
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +23 -20
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts +2 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +7 -7
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts +6 -22
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +9 -67
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +13 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +55 -20
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +4 -4
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +11 -5
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +18 -10
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts +2 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +8 -5
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +5 -5
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +21 -20
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts.map +1 -1
- package/dev/core/super-openable.js +1 -1
- package/dev/core/super-openable.js.map +1 -1
- package/dev/range.d.ts +1 -1
- package/dev/range.d.ts.map +1 -1
- package/index.js +13 -13
- package/package.json +11 -8
- package/range.d.ts +1 -1
- package/range.d.ts.map +1 -1
- package/src/alert.ts +11 -0
- package/src/avatar.ts +11 -0
- package/src/breath.ts +13 -0
- package/src/button.ts +11 -0
- package/src/card.ts +11 -0
- package/src/carousel.ts +11 -0
- package/src/components/alert.ts +284 -0
- package/src/components/avatar.ts +109 -0
- package/src/components/breath.ts +165 -0
- package/src/components/button.ts +292 -0
- package/src/components/card.ts +83 -0
- package/src/components/carousel.ts +183 -0
- package/src/components/details.ts +121 -0
- package/src/components/dialog.ts +166 -0
- package/src/components/divider.ts +56 -0
- package/src/components/dragbox.ts +134 -0
- package/src/components/flex.ts +82 -0
- package/src/components/form.ts +82 -0
- package/src/components/grid.ts +87 -0
- package/src/components/input.ts +73 -0
- package/src/components/layout.ts +89 -0
- package/src/components/link.ts +38 -0
- package/src/components/progress.ts +100 -0
- package/src/components/range.ts +399 -0
- package/src/components/rotate.ts +95 -0
- package/src/components/router.ts +281 -0
- package/src/components/select.ts +281 -0
- package/src/components/skeleton.ts +119 -0
- package/src/components/split.ts +225 -0
- package/src/components/switch.ts +184 -0
- package/src/components/text.ts +93 -0
- package/src/components/time.ts +84 -0
- package/src/components/tooltip.ts +150 -0
- package/src/components/typewriter.ts +159 -0
- package/src/core/global-style.ts +105 -0
- package/src/core/super-anchor.ts +55 -0
- package/src/core/super-input.ts +230 -0
- package/src/core/super-openable.ts +51 -0
- package/src/details.ts +11 -0
- package/src/dialog.ts +11 -0
- package/src/divider.ts +11 -0
- package/src/dragbox.ts +11 -0
- package/src/flex.ts +11 -0
- package/src/form.ts +11 -0
- package/src/grid.ts +11 -0
- package/src/index.ts +28 -0
- package/src/input.ts +13 -0
- package/src/layout.ts +12 -0
- package/src/link.ts +13 -0
- package/src/progress.ts +12 -0
- package/src/range.ts +13 -0
- package/src/rotate.ts +13 -0
- package/src/router.ts +12 -0
- package/src/select.ts +13 -0
- package/src/skeleton.ts +13 -0
- package/src/split.ts +13 -0
- package/src/switch.ts +13 -0
- package/src/text.ts +13 -0
- package/src/time.ts +13 -0
- package/src/tooltip.ts +13 -0
- package/src/typewriter.ts +11 -0
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/index.js
CHANGED
@@ -26,6 +26,19 @@ import './text.js';
|
|
26
26
|
import './time.js';
|
27
27
|
import './tooltip.js';
|
28
28
|
import './typewriter.js';
|
29
|
+
export { default as Alert } from './components/alert.js';
|
30
|
+
export { default as Avatar } from './components/avatar.js';
|
31
|
+
export { default as Breath } from './components/breath.js';
|
32
|
+
export { default as Button } from './components/button.js';
|
33
|
+
export { default as Card } from './components/card.js';
|
34
|
+
export { default as Carousel } from './components/carousel.js';
|
35
|
+
export { default as Details } from './components/details.js';
|
36
|
+
export { default as Dialog } from './components/dialog.js';
|
37
|
+
export { default as Divider } from './components/divider.js';
|
38
|
+
export { default as Dragbox } from './components/dragbox.js';
|
39
|
+
export { default as Flex } from './components/flex.js';
|
40
|
+
export { default as Form } from './components/form.js';
|
41
|
+
export { default as Grid } from './components/grid.js';
|
29
42
|
export { default as Input } from './components/input.js';
|
30
43
|
export { default as Layout } from './components/layout.js';
|
31
44
|
export { default as Link } from './components/link.js';
|
@@ -41,17 +54,4 @@ export { default as Text } from './components/text.js';
|
|
41
54
|
export { default as Time } from './components/time.js';
|
42
55
|
export { default as Tooltip } from './components/tooltip.js';
|
43
56
|
export { default as Typewriter } from './components/typewriter.js';
|
44
|
-
export { default as Alert } from './components/alert.js';
|
45
|
-
export { default as Avatar } from './components/avatar.js';
|
46
|
-
export { default as Breath } from './components/breath.js';
|
47
|
-
export { default as Button } from './components/button.js';
|
48
|
-
export { default as Card } from './components/card.js';
|
49
|
-
export { default as Carousel } from './components/carousel.js';
|
50
|
-
export { default as Details } from './components/details.js';
|
51
|
-
export { default as Dialog } from './components/dialog.js';
|
52
|
-
export { default as Divider } from './components/divider.js';
|
53
|
-
export { default as Dragbox } from './components/dragbox.js';
|
54
|
-
export { default as Flex } from './components/flex.js';
|
55
|
-
export { default as Form } from './components/form.js';
|
56
|
-
export { default as Grid } from './components/grid.js';
|
57
57
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "godown",
|
3
|
-
"version": "3.0.0-canary.
|
4
|
-
"description": "
|
3
|
+
"version": "3.0.0-canary.11",
|
4
|
+
"description": "Non Composite Web Components Library",
|
5
5
|
"type": "module",
|
6
6
|
"main": "index.js",
|
7
7
|
"exports": {
|
@@ -13,22 +13,24 @@
|
|
13
13
|
"development": "./dev/*",
|
14
14
|
"default": "./*"
|
15
15
|
},
|
16
|
+
"./src/*": "./src/*",
|
16
17
|
"./*.json": "./*.json"
|
17
18
|
},
|
18
19
|
"repository": {
|
19
20
|
"type": "git",
|
20
21
|
"url": "https://github.com/startracex/godown.git",
|
21
|
-
"directory": "packages/
|
22
|
+
"directory": "packages/godown"
|
22
23
|
},
|
23
24
|
"keywords": [],
|
24
25
|
"author": "startracex",
|
25
26
|
"license": "MIT",
|
26
27
|
"dependencies": {
|
28
|
+
"fmtime": "^0.0.3",
|
27
29
|
"lit": "^3.0.0",
|
28
30
|
"tslib": "^2.7.0",
|
29
|
-
"@godown/
|
30
|
-
"@godown/
|
31
|
-
"@godown/f7-icon": "^0.0.
|
31
|
+
"@godown/colors": "^0.0.1",
|
32
|
+
"@godown/element": "^0.1.0",
|
33
|
+
"@godown/f7-icon": "^0.0.4"
|
32
34
|
},
|
33
35
|
"publishConfig": {
|
34
36
|
"access": "public"
|
@@ -37,7 +39,8 @@
|
|
37
39
|
"**/*.{js,d.ts}+(|.map)",
|
38
40
|
"custom-elements.json",
|
39
41
|
"web-types.json",
|
40
|
-
"vscode.{css,html}-custom-data.json"
|
42
|
+
"vscode.{css,html}-custom-data.json",
|
43
|
+
"src"
|
41
44
|
],
|
42
45
|
"custom-elements": "./custom-elements.json",
|
43
46
|
"customElements": "./custom-elements.json",
|
@@ -49,7 +52,7 @@
|
|
49
52
|
"build": "tsc && tsx build.ts",
|
50
53
|
"build:ts": "tsc",
|
51
54
|
"fmt": "dprint fmt",
|
52
|
-
"lint": "eslint --fix",
|
55
|
+
"lint": "eslint . --fix",
|
53
56
|
"manifest": "tsx manifest.ts"
|
54
57
|
}
|
55
58
|
}
|
package/range.d.ts
CHANGED
package/range.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["src/range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,uBAAuB,CAAC;AAI1C,eAAe,KAAK,CAAC;AAErB,cAAc,uBAAuB,CAAC;AAEtC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,
|
1
|
+
{"version":3,"file":"range.d.ts","sourceRoot":"","sources":["src/range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,uBAAuB,CAAC;AAI1C,eAAe,KAAK,CAAC;AAErB,cAAc,uBAAuB,CAAC;AAEtC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,KAAK,CAAC;KACvB;CACF"}
|
package/src/alert.ts
ADDED
package/src/avatar.ts
ADDED
package/src/breath.ts
ADDED
package/src/button.ts
ADDED
package/src/card.ts
ADDED
package/src/carousel.ts
ADDED
@@ -0,0 +1,284 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { htmlStyle } from "@godown/element/directives/html-style.js";
|
6
|
+
import { constructCSSObject, toVar } from "@godown/element/tools/css.js";
|
7
|
+
import iconCheckAltCircle from "@godown/f7-icon/icons/checkmark-alt-circle.js";
|
8
|
+
import iconExclamationCircle from "@godown/f7-icon/icons/exclamationmark-circle.js";
|
9
|
+
import iconInfoCircle from "@godown/f7-icon/icons/info-circle.js";
|
10
|
+
import iconLightbulb from "@godown/f7-icon/icons/lightbulb.js";
|
11
|
+
import iconQuestionCircle from "@godown/f7-icon/icons/question-circle.js";
|
12
|
+
import iconSlashCircle from "@godown/f7-icon/icons/slash-circle.js";
|
13
|
+
import iconXmark from "@godown/f7-icon/icons/xmark.js";
|
14
|
+
import iconXmarkCircle from "@godown/f7-icon/icons/xmark-circle.js";
|
15
|
+
import { css, html, type TemplateResult } from "lit";
|
16
|
+
import { property } from "lit/decorators.js";
|
17
|
+
|
18
|
+
import { cssGlobalVars, GlobalStyle, scopePrefix } from "../core/global-style.js";
|
19
|
+
|
20
|
+
const protoName = "alert";
|
21
|
+
const cssScope = scopePrefix(protoName);
|
22
|
+
|
23
|
+
const vars = ["color", "background"].map((v) => `${cssScope}--${v}`);
|
24
|
+
|
25
|
+
const genDark = (key: string) => {
|
26
|
+
return [cssGlobalVars._colors[key][5], cssGlobalVars._colors[key][9]];
|
27
|
+
};
|
28
|
+
|
29
|
+
const darkStyles = constructCSSObject(
|
30
|
+
vars,
|
31
|
+
{
|
32
|
+
green: genDark("green"),
|
33
|
+
blue: genDark("blue"),
|
34
|
+
orange: genDark("orange"),
|
35
|
+
red: genDark("red"),
|
36
|
+
yellow: genDark("yellow"),
|
37
|
+
purple: genDark("purple"),
|
38
|
+
teal: genDark("teal"),
|
39
|
+
pink: genDark("pink"),
|
40
|
+
gray: [cssGlobalVars._colors.lightgray[5], cssGlobalVars._colors.darkgray[5]],
|
41
|
+
white: [cssGlobalVars._colors.lightgray[2], cssGlobalVars._colors.darkgray[7]],
|
42
|
+
black: [cssGlobalVars._colors.darkgray[8], cssGlobalVars._colors.lightgray[5]],
|
43
|
+
},
|
44
|
+
() => `:host`,
|
45
|
+
(prop) => toVar(prop),
|
46
|
+
);
|
47
|
+
|
48
|
+
const genLight = (key: string) => {
|
49
|
+
return [cssGlobalVars._colors[key][6], cssGlobalVars._colors[key][0]];
|
50
|
+
};
|
51
|
+
|
52
|
+
const lightStyles = constructCSSObject(
|
53
|
+
vars,
|
54
|
+
{
|
55
|
+
green: genLight("green"),
|
56
|
+
blue: genLight("blue"),
|
57
|
+
orange: genLight("orange"),
|
58
|
+
red: genLight("red"),
|
59
|
+
yellow: genLight("yellow"),
|
60
|
+
purple: genLight("purple"),
|
61
|
+
teal: genLight("teal"),
|
62
|
+
pink: genLight("pink"),
|
63
|
+
gray: [cssGlobalVars._colors.darkgray[5], cssGlobalVars._colors.lightgray[7]],
|
64
|
+
white: [cssGlobalVars._colors.lightgray[0], cssGlobalVars._colors.darkgray[0]],
|
65
|
+
black: [cssGlobalVars._colors.darkgray[7], cssGlobalVars._colors.lightgray[3]],
|
66
|
+
},
|
67
|
+
() => `:host`,
|
68
|
+
(prop) => toVar(prop),
|
69
|
+
);
|
70
|
+
|
71
|
+
const calls = {
|
72
|
+
tip: {
|
73
|
+
color: "teal",
|
74
|
+
icon: iconLightbulb,
|
75
|
+
},
|
76
|
+
success: {
|
77
|
+
color: "green",
|
78
|
+
icon: iconCheckAltCircle,
|
79
|
+
},
|
80
|
+
info: {
|
81
|
+
color: "blue",
|
82
|
+
icon: iconInfoCircle,
|
83
|
+
},
|
84
|
+
warning: {
|
85
|
+
color: "orange",
|
86
|
+
icon: iconExclamationCircle,
|
87
|
+
},
|
88
|
+
danger: {
|
89
|
+
color: "red",
|
90
|
+
icon: iconXmarkCircle,
|
91
|
+
},
|
92
|
+
error: {
|
93
|
+
color: "red",
|
94
|
+
icon: iconXmarkCircle,
|
95
|
+
},
|
96
|
+
help: {
|
97
|
+
color: "purple",
|
98
|
+
icon: iconQuestionCircle,
|
99
|
+
},
|
100
|
+
deprecated: {
|
101
|
+
color: "gray",
|
102
|
+
icon: iconSlashCircle,
|
103
|
+
},
|
104
|
+
};
|
105
|
+
|
106
|
+
/**
|
107
|
+
* {@linkcode Alert} renders a alert.
|
108
|
+
*
|
109
|
+
* Color defaults to blue.
|
110
|
+
*
|
111
|
+
* @slot - Alert content.
|
112
|
+
* @slot title - Alert title.
|
113
|
+
* @slot icon - Alert icon.
|
114
|
+
* @category feedback
|
115
|
+
*/
|
116
|
+
@godown(protoName)
|
117
|
+
@styles(
|
118
|
+
css`
|
119
|
+
:host,
|
120
|
+
:where(:host([contents]) [part=root]) {
|
121
|
+
border-radius: var(${cssScope}--border-radius);
|
122
|
+
${cssScope}--border-radius: .25em;
|
123
|
+
${cssScope}--border-width: .075em;
|
124
|
+
${cssScope}--blockquote-width: .2em;
|
125
|
+
${cssScope}--padding: .5em;
|
126
|
+
display: block;
|
127
|
+
width: 100%;
|
128
|
+
}
|
129
|
+
|
130
|
+
[part=root] {
|
131
|
+
--color: var(${cssScope}--color);
|
132
|
+
color: var(--color);
|
133
|
+
width: 100%;
|
134
|
+
transition: 0.25s;
|
135
|
+
display: flex;
|
136
|
+
justify-content: space-between;
|
137
|
+
padding: var(${cssScope}--padding);
|
138
|
+
border-radius: inherit;
|
139
|
+
border: var(${cssScope}--border-width) solid var(--color);
|
140
|
+
background: var(${cssScope}--background);
|
141
|
+
}
|
142
|
+
|
143
|
+
[variant=blockquote] {
|
144
|
+
border-radius: 0;
|
145
|
+
border-left: var(${cssScope}--blockquote-width) solid var(--color);
|
146
|
+
border-bottom: none;
|
147
|
+
border-right: none;
|
148
|
+
border-top: none;
|
149
|
+
background: transparent;
|
150
|
+
}
|
151
|
+
|
152
|
+
[part=content] {
|
153
|
+
color: var(--color);
|
154
|
+
}
|
155
|
+
|
156
|
+
[part=root] {
|
157
|
+
display: grid;
|
158
|
+
align-items: center;
|
159
|
+
grid-template-columns: auto 1fr auto;
|
160
|
+
grid-template-rows: auto 1fr;
|
161
|
+
}
|
162
|
+
|
163
|
+
[part=title] {
|
164
|
+
line-height: 2em;
|
165
|
+
}
|
166
|
+
|
167
|
+
[part=icon] {
|
168
|
+
display: inline-grid;
|
169
|
+
align-items: center;
|
170
|
+
height: 2em;
|
171
|
+
}
|
172
|
+
|
173
|
+
[part=icon] svg {
|
174
|
+
margin-right: .5em;
|
175
|
+
width: 1.25em;
|
176
|
+
height: 1.25em;
|
177
|
+
}
|
178
|
+
|
179
|
+
[part=content] {
|
180
|
+
grid-row: span 2 / span 2;
|
181
|
+
line-height: 1.5em;
|
182
|
+
}
|
183
|
+
`,
|
184
|
+
)
|
185
|
+
class Alert extends GlobalStyle {
|
186
|
+
/**
|
187
|
+
* If it is a legal value, the icon and preset color will be rendered.
|
188
|
+
*/
|
189
|
+
@property()
|
190
|
+
call: "tip" | "success" | "info" | "warning" | "danger" | "error" | "help" | "deprecated";
|
191
|
+
|
192
|
+
/**
|
193
|
+
* The tone of the component.
|
194
|
+
* Overrides the color of the call.
|
195
|
+
*/
|
196
|
+
@property()
|
197
|
+
color:
|
198
|
+
| "white"
|
199
|
+
| "black"
|
200
|
+
| "gray"
|
201
|
+
| "green"
|
202
|
+
| "teal"
|
203
|
+
| "blue"
|
204
|
+
| "red"
|
205
|
+
| "purple"
|
206
|
+
| "orange"
|
207
|
+
| "yellow"
|
208
|
+
| "pink"
|
209
|
+
| "none" = "blue";
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Close delay, if 0, it will not be closed automatically.
|
213
|
+
*/
|
214
|
+
@property({ type: Number })
|
215
|
+
autoclose = 0;
|
216
|
+
|
217
|
+
/**
|
218
|
+
* The title is bold and the icon height is the same as it.
|
219
|
+
*/
|
220
|
+
@property()
|
221
|
+
title: string;
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Content, if zero value, will be rendered as an unnamed slot.
|
225
|
+
*/
|
226
|
+
@property()
|
227
|
+
content: string;
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Set true to hide the close button.
|
231
|
+
*
|
232
|
+
* The behavior may change due to the {@linkcode variant} property.
|
233
|
+
*/
|
234
|
+
@property({ type: Boolean })
|
235
|
+
hideClose = false;
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Alert variant, if set to `blockquote`, the alert will be rendered as a blockquote.
|
239
|
+
*
|
240
|
+
* If variant is `"blockquote"`, hide the close button.
|
241
|
+
*/
|
242
|
+
@property()
|
243
|
+
variant: "blockquote" | "dark" | "light" = "dark";
|
244
|
+
|
245
|
+
protected render(): TemplateResult<1> {
|
246
|
+
const color = calls[this.call]?.color || this.color;
|
247
|
+
const icon = this.call ? calls[this.call].icon() : htmlSlot("icon");
|
248
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
249
|
+
<div part="icon">${icon}</div>
|
250
|
+
<div part="content">
|
251
|
+
<strong part="title">
|
252
|
+
${this.title || htmlSlot("title")}
|
253
|
+
</strong>
|
254
|
+
${this.content || htmlSlot()}
|
255
|
+
</div>
|
256
|
+
${
|
257
|
+
!this.hideClose && this.variant !== "blockquote"
|
258
|
+
? html`<div part="close" tabindex=0 @click="${this.close}">${iconXmark()}</div>`
|
259
|
+
: ""
|
260
|
+
}
|
261
|
+
${htmlStyle(this.variant === "light" ? lightStyles[color] : darkStyles[color])}
|
262
|
+
</div>`;
|
263
|
+
}
|
264
|
+
|
265
|
+
close(): void {
|
266
|
+
this.remove();
|
267
|
+
this.dispatchEvent(new CustomEvent("close", { bubbles: true, composed: true }));
|
268
|
+
}
|
269
|
+
|
270
|
+
protected firstUpdated(): void {
|
271
|
+
if (this.autoclose) {
|
272
|
+
setTimeout(() => this.close(), this.autoclose);
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
static alert(root: HTMLElement, option: Partial<Alert>): Alert {
|
277
|
+
const ai = new this();
|
278
|
+
Object.assign(ai, option);
|
279
|
+
root.appendChild(ai);
|
280
|
+
return ai;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
|
284
|
+
export default Alert;
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { omit } from "@godown/element/tools/lib.js";
|
6
|
+
import { css, html, type TemplateResult } from "lit";
|
7
|
+
import { property } from "lit/decorators.js";
|
8
|
+
|
9
|
+
import { GlobalStyle, scopePrefix } from "../core/global-style.js";
|
10
|
+
|
11
|
+
const protoName = "avatar";
|
12
|
+
const cssScope = scopePrefix(protoName);
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Avatar} renders a avatar.
|
16
|
+
*
|
17
|
+
* Renders as an image if it has a src property,
|
18
|
+
* otherwise falls back to name or nameless slot.
|
19
|
+
*
|
20
|
+
* @slot - Display content if no `src` or `name` provided.
|
21
|
+
* @category display
|
22
|
+
*/
|
23
|
+
@godown(protoName)
|
24
|
+
@styles(
|
25
|
+
css`
|
26
|
+
:host{
|
27
|
+
${cssScope}--size: 2em;
|
28
|
+
width: var(${cssScope}--size);
|
29
|
+
height: var(${cssScope}--size);
|
30
|
+
vertical-align: bottom;
|
31
|
+
}
|
32
|
+
|
33
|
+
:host,
|
34
|
+
[part=root] {
|
35
|
+
display: inline-flex;
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([contents]) [part=root] {
|
39
|
+
display: inline-flex;
|
40
|
+
width: inherit;
|
41
|
+
height: inherit;
|
42
|
+
}
|
43
|
+
|
44
|
+
:host([round]) {
|
45
|
+
border-radius:50%;
|
46
|
+
}
|
47
|
+
|
48
|
+
[part=image] {
|
49
|
+
width: 100%;
|
50
|
+
height: 100%;
|
51
|
+
object-fit: cover;
|
52
|
+
}
|
53
|
+
|
54
|
+
[part=root] {
|
55
|
+
overflow: hidden;
|
56
|
+
position: relative;
|
57
|
+
border-radius: inherit;
|
58
|
+
width: 100%;
|
59
|
+
height: 100%;
|
60
|
+
align-items: center;
|
61
|
+
justify-content: center;
|
62
|
+
}
|
63
|
+
`,
|
64
|
+
)
|
65
|
+
class Avatar extends GlobalStyle {
|
66
|
+
/**
|
67
|
+
* Image src.
|
68
|
+
*/
|
69
|
+
@property()
|
70
|
+
src: string | undefined | null;
|
71
|
+
|
72
|
+
/**
|
73
|
+
* If the image is not available, display name (call {@linkcode Avatar.format}).
|
74
|
+
*/
|
75
|
+
@property()
|
76
|
+
name = "";
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Display rounded.
|
80
|
+
*/
|
81
|
+
@property({ type: Boolean })
|
82
|
+
round = false;
|
83
|
+
|
84
|
+
protected render(): TemplateResult<1> {
|
85
|
+
return html`<div part="root" ${attr(omit(this.observedRecord, "src"))}>
|
86
|
+
${this._renderAvatar()}
|
87
|
+
</div>`;
|
88
|
+
}
|
89
|
+
|
90
|
+
private _renderAvatar() {
|
91
|
+
if (this.src) {
|
92
|
+
return html`<img part="image" src="${this.src}" @error=${this._handleError} alt="${this.name}">`;
|
93
|
+
}
|
94
|
+
if (this.name) {
|
95
|
+
return html`<span part="name">${this.format()}</span>`;
|
96
|
+
}
|
97
|
+
return htmlSlot();
|
98
|
+
}
|
99
|
+
|
100
|
+
format(): string {
|
101
|
+
return this.name;
|
102
|
+
}
|
103
|
+
|
104
|
+
_handleError(): void {
|
105
|
+
this.src = undefined;
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
export default Avatar;
|