@c2n/kbd 0.0.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Nguyen Thai Vinh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Kbd
2
+
3
+ `@c2n/kbd` provides `c2-kbd`, a semantic and themeable keyboard-key label for shortcuts and command hints.
4
+
5
+ ```html
6
+ <script type="module">
7
+ import '@c2n/kbd'
8
+ </script>
9
+
10
+ Press <c2-kbd>Ctrl + K</c2-kbd> to search.
11
+ ```
package/dist/kbd.js ADDED
@@ -0,0 +1,25 @@
1
+ import { LitElement, html, unsafeCSS } from "lit";
2
+ import { customElement } from "@c2n/core/element-helper.js";
3
+ //#region src/kbd.scss?inline
4
+ var kbd_default = "/* ex : var((width: 24px), width, c2-checkbox) returns var(--c2-checkbox-width, 24px) */\n:host {\n display: inline-flex;\n flex: none;\n vertical-align: middle;\n}\n\n:host([hidden]) {\n display: none;\n}\n\n.c2-kbd {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n min-width: var(--c2-kbd--min-width,24px);\n height: var(--c2-kbd--height,24px);\n margin: 0;\n padding-left: var(--c2-kbd--padding-left,6px);\n padding-right: var(--c2-kbd--padding-right,6px);\n gap: var(--c2-kbd--gap,4px);\n background-color: var(--c2-kbd--background-color,#f4f4f5);\n color: var(--c2-kbd--color,#52525b);\n border: var(--c2-kbd--border,1px solid #d4d4d8);\n border-radius: var(--c2-kbd--border-radius,5px);\n box-shadow: var(--c2-kbd--box-shadow,0 1px 0 #a1a1aa);\n font-family: var(--c2-kbd--font-family,ui-monospace SFMono-Regular Menlo Monaco Consolas monospace);\n font-size: var(--c2-kbd--font-size,12px);\n font-weight: var(--c2-kbd--font-weight,500);\n line-height: var(--c2-kbd--line-height,1);\n letter-spacing: var(--c2-kbd--letter-spacing,0.01em);\n text-transform: var(--c2-kbd--text-transform,none);\n white-space: nowrap;\n user-select: none;\n}";
5
+ //#endregion
6
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/decorate.js
7
+ function __decorate(decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ }
13
+ //#endregion
14
+ //#region src/kbd.ts
15
+ var Kbd = class Kbd extends LitElement {
16
+ static {
17
+ this.styles = unsafeCSS(kbd_default);
18
+ }
19
+ render() {
20
+ return html`<kbd class="c2-kbd" part="kbd"><slot></slot></kbd>`;
21
+ }
22
+ };
23
+ Kbd = __decorate([customElement("c2-kbd")], Kbd);
24
+ //#endregion
25
+ export { Kbd };
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@c2n/kbd",
3
+ "version": "0.0.7",
4
+ "type": "module",
5
+ "main": "dist/kbd.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./types/src/kbd.d.ts",
9
+ "default": "./dist/kbd.js"
10
+ },
11
+ "./react": {
12
+ "types": "./react.d.ts",
13
+ "default": "./react.js"
14
+ },
15
+ "./vue": {
16
+ "types": "./vue.d.ts",
17
+ "default": "./vue.js"
18
+ },
19
+ "./custom-elements.json": "./custom-elements.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "react.d.ts",
25
+ "react.js",
26
+ "vue.d.ts",
27
+ "vue.js"
28
+ ],
29
+ "keywords": [
30
+ "kbd",
31
+ "web component",
32
+ "lit"
33
+ ],
34
+ "license": "MIT",
35
+ "author": "code2nguyen@gmail.com",
36
+ "publishConfig": {
37
+ "registry": "https://registry.npmjs.org",
38
+ "access": "public"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/code2nguyen/web-components.git"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "wireit",
47
+ "build:only": "vite build",
48
+ "type-check": "wireit"
49
+ },
50
+ "wireit": {
51
+ "type-check": {
52
+ "dependencies": [
53
+ "../../core:build"
54
+ ],
55
+ "command": "tsc -p tsconfig.lib.json --composite false"
56
+ },
57
+ "build": {
58
+ "dependencies": [
59
+ "type-check"
60
+ ],
61
+ "command": "vite build"
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "@c2n/core": "0.0.7",
66
+ "lit": "3.3.3"
67
+ },
68
+ "devDependencies": {
69
+ "@c2n/config": "*"
70
+ },
71
+ "customElements": "custom-elements.json",
72
+ "gitHead": "c8db398a27f7cd417d665fdf5da455fee2d4e910"
73
+ }
package/react.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // JSX types for the custom elements of @c2n/kbd. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/kbd/react'
6
+ //
7
+ // Register the elements at module scope before React renders, or React writes an object prop as an
8
+ // attribute and it stringifies.
9
+
10
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react'
11
+ import type { Kbd } from '@c2n/kbd'
12
+
13
+ /** Standard React host-element attributes plus the element's own public properties. */
14
+ type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
15
+
16
+ declare module 'react' {
17
+ namespace JSX {
18
+ interface IntrinsicElements {
19
+ 'c2-kbd': C2Props<Kbd>
20
+ }
21
+ }
22
+ }
23
+
24
+ export {}
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}
@@ -0,0 +1,38 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * Displays a keyboard key or shortcut with the semantics of the native `kbd` element. Use one element for a complete
4
+ * shortcut (`Ctrl + K`) or place several beside descriptive text. The component is presentational and never enters the
5
+ * tab order; when it repeats a shortcut already announced by a surrounding control, set `aria-hidden="true"` on the
6
+ * host.
7
+ *
8
+ * @tag c2-kbd
9
+ *
10
+ * @slot - Key name or shortcut to display.
11
+ *
12
+ * @cssproperty {pixel} [--c2-kbd--min-width=24px]
13
+ * @cssproperty {pixel} [--c2-kbd--height=24px]
14
+ * @cssproperty {padding} [--c2-kbd--padding-left=6px]
15
+ * @cssproperty {padding} [--c2-kbd--padding-right=6px]
16
+ * @cssproperty {pixel} [--c2-kbd--gap=4px] - Space between multiple slotted nodes.
17
+ * @cssproperty {color} [--c2-kbd--background-color=#f4f4f5]
18
+ * @cssproperty {color} [--c2-kbd--color=#52525b]
19
+ * @cssproperty {border} [--c2-kbd--border=1px solid #d4d4d8]
20
+ * @cssproperty {border-radius} [--c2-kbd--border-radius=5px]
21
+ * @cssproperty {box-shadow} [--c2-kbd--box-shadow=0 1px 0 #a1a1aa]
22
+ * @cssproperty {font-family} [--c2-kbd--font-family=ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace]
23
+ * @cssproperty {font-size} [--c2-kbd--font-size=12px]
24
+ * @cssproperty {font-weight} [--c2-kbd--font-weight=500]
25
+ * @cssproperty {line-height} [--c2-kbd--line-height=1]
26
+ * @cssproperty {pixel} [--c2-kbd--letter-spacing=0.01em]
27
+ * @cssproperty {text-transform} [--c2-kbd--text-transform=none]
28
+ */
29
+ export declare class Kbd extends LitElement {
30
+ static styles: import("lit").CSSResult;
31
+ render(): import("lit-html").TemplateResult<1>;
32
+ }
33
+ declare global {
34
+ interface HTMLElementTagNameMap {
35
+ 'c2-kbd': Kbd;
36
+ }
37
+ }
38
+ //# sourceMappingURL=kbd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../../src/kbd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAA;AAIjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBACa,GAAI,SAAQ,UAAU;IACjC,OAAgB,MAAM,0BAAoB;IAEjC,MAAM;CAGhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,QAAQ,EAAE,GAAG,CAAA;KACd;CACF"}
package/vue.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ //
3
+ // Vue template types for the custom elements of @c2n/kbd. Import once, anywhere in the program:
4
+ //
5
+ // import '@c2n/kbd/vue'
6
+ //
7
+ // Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
8
+ // nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
9
+
10
+ import type { DefineComponent, HTMLAttributes } from 'vue'
11
+ import type { Kbd } from '@c2n/kbd'
12
+
13
+ /** The element's own public properties, plus every attribute Vue understands on a host element. */
14
+ type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
15
+
16
+ declare module 'vue' {
17
+ interface GlobalComponents {
18
+ 'c2-kbd': DefineComponent<C2Props<Kbd>>
19
+ }
20
+ }
21
+
22
+ declare module '@vue/runtime-dom' {
23
+ interface HTMLAttributes {
24
+ /** Vue's own definition omits it, and slotting a plain element into a component needs it. */
25
+ slot?: string
26
+ }
27
+ }
28
+
29
+ export {}
package/vue.js ADDED
@@ -0,0 +1,3 @@
1
+ // GENERATED by @c2n/framework-types. Do not edit by hand.
2
+ // Types only — see the matching .d.ts.
3
+ export {}