@pindoba/astro-select-native 0.0.0-alpha-20260617191010

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,7 @@
1
+ Copyright (c) 2024 Eduardo Lopes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Astro Starter Kit: Component Package
2
+
3
+ This is a template for an Astro component library. Use this template for writing components to use in multiple projects or publish to NPM.
4
+
5
+ ```sh
6
+ npm create astro@latest -- --template component
7
+ ```
8
+
9
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/non-html-pages)
10
+ [![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/non-html-pages)
11
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/component/devcontainer.json)
12
+
13
+ ## πŸš€ Project Structure
14
+
15
+ Inside of your Astro project, you'll see the following folders and files:
16
+
17
+ ```text
18
+ /
19
+ β”œβ”€β”€ index.ts
20
+ β”œβ”€β”€ src
21
+ β”‚ └── MyComponent.astro
22
+ β”œβ”€β”€ tsconfig.json
23
+ β”œβ”€β”€ package.json
24
+ ```
25
+
26
+ The `index.ts` file is the "entry point" for your package. Export your components in `index.ts` to make them importable from your package.
27
+
28
+ ## 🧞 Commands
29
+
30
+ All commands are run from the root of the project, from a terminal:
31
+
32
+ | Command | Action |
33
+ | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `npm link` | Registers this package locally. Run `npm link my-component-library` in an Astro project to install your components |
35
+ | `npm publish` | [Publishes](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages#publishing-unscoped-public-packages) this package to NPM. Requires you to be [logged in](https://docs.npmjs.com/cli/v8/commands/npm-adduser) |
package/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Do not write code directly here, instead use the `src` folder!
2
+ // Then, use this file to export everything you want your user to access.
3
+
4
+ import Component from "./src/select.astro";
5
+
6
+ export default Component;
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@pindoba/astro-select-native",
3
+ "version": "0.0.0-alpha-20260617191010",
4
+ "homepage": "https://github.com/EduardoLopes/pindoba/tree/main/packages/blocks/astro/select#README.md",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/EduardoLopes/pindoba.git",
8
+ "directory": "packages/ui/astro/select"
9
+ },
10
+ "sideEffects": false,
11
+ "license": "MIT",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": "./index.ts",
15
+ "./demos": "./src/demos/index.ts",
16
+ "./demos/feedback": "./src/demos/feedback.astro",
17
+ "./demos/size": "./src/demos/size.astro",
18
+ "./demos/custom": "./src/demos/custom.astro",
19
+ "./primitives/*": {
20
+ "types": "./src/primitives/*.ts",
21
+ "module": "./src/primitives/*.ts",
22
+ "import": {
23
+ "default": "./dist/primitives/*.mjs",
24
+ "types": "./dist/primitives/*.d.mts"
25
+ },
26
+ "require": {
27
+ "default": "./dist/primitives/*.js",
28
+ "types": "./dist/primitives/*.d.ts"
29
+ }
30
+ }
31
+ },
32
+ "files": [
33
+ "src",
34
+ "index.ts"
35
+ ],
36
+ "keywords": [
37
+ "astro-component"
38
+ ],
39
+ "devDependencies": {
40
+ "@astrojs/check": "^0.9.9",
41
+ "astro": "^6.4.7",
42
+ "typescript": "^6.0.3"
43
+ },
44
+ "peerDependencies": {
45
+ "astro": "^4.0.0"
46
+ },
47
+ "dependencies": {
48
+ "@pindoba/core-select-native": "0.0.0-alpha-20260617191010",
49
+ "@pindoba/styled-system": "0.0.0-alpha-20260617191010"
50
+ },
51
+ "scripts": {
52
+ "lint": "TIMING=1 eslint . --max-warnings 0",
53
+ "lint:fix": "TIMING=1 eslint . --fix --max-warnings 0",
54
+ "link": "pnpm link",
55
+ "unlink": "pnpm unlink",
56
+ "check": "astro check",
57
+ "dev": "astro check --watch",
58
+ "clean": "rm -rf .astro && rm -rf node_modules && rm -rf .turbo",
59
+ "format": "prettier --check . --ignore-path \"$PRETTIER_IGNORE_PATH\"",
60
+ "format:fix": "prettier --write . --ignore-path \"$PRETTIER_IGNORE_PATH\""
61
+ }
62
+ }
@@ -0,0 +1,25 @@
1
+ ---
2
+ import Select from "../select.astro";
3
+ import { stack } from "@pindoba/styled-system/patterns";
4
+
5
+ const items = [
6
+ { label: "Apple", value: "apple" },
7
+ { label: "Banana", value: "banana" },
8
+ { label: "Cherry", value: "cherry" },
9
+ ];
10
+ ---
11
+
12
+ <div class={stack({ gap: "md", direction: "column" })}>
13
+ <Select
14
+ items={items}
15
+ passThrough={{
16
+ root: { style: { borderRadius: "full" } },
17
+ }}
18
+ />
19
+ <Select
20
+ items={items}
21
+ passThrough={{
22
+ select: { style: { fontStyle: "italic" } },
23
+ }}
24
+ />
25
+ </div>
@@ -0,0 +1,18 @@
1
+ ---
2
+ import Select from "../select.astro";
3
+ import { stack } from "@pindoba/styled-system/patterns";
4
+
5
+ const items = [
6
+ { label: "Apple", value: "apple" },
7
+ { label: "Banana", value: "banana" },
8
+ { label: "Cherry", value: "cherry" },
9
+ ];
10
+ ---
11
+
12
+ <div class={stack({ gap: "md", direction: "column" })}>
13
+ <Select feedback="neutral" items={items} />
14
+ <Select feedback="primary" items={items} />
15
+ <Select feedback="success" items={items} />
16
+ <Select feedback="danger" items={items} />
17
+ <Select feedback="warning" items={items} />
18
+ </div>
@@ -0,0 +1,3 @@
1
+ export { default as Feedback } from "./feedback.astro";
2
+ export { default as Size } from "./size.astro";
3
+ export { default as Custom } from "./custom.astro";
@@ -0,0 +1,16 @@
1
+ ---
2
+ import Select from "../select.astro";
3
+ import { stack } from "@pindoba/styled-system/patterns";
4
+
5
+ const items = [
6
+ { label: "Apple", value: "apple" },
7
+ { label: "Banana", value: "banana" },
8
+ { label: "Cherry", value: "cherry" },
9
+ ];
10
+ ---
11
+
12
+ <div class={stack({ gap: "md", direction: "column" })}>
13
+ <Select size="sm" items={items} />
14
+ <Select size="md" items={items} />
15
+ <Select size="lg" items={items} />
16
+ </div>
package/src/env.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ // eslint-disable-next-line @typescript-eslint/triple-slash-reference
2
+ /// <reference path="../.astro/types.d.ts" />
@@ -0,0 +1,29 @@
1
+ ---
2
+ import {
3
+ connectSelectOption,
4
+ type SelectSlotPassThrough,
5
+ } from "@pindoba/core-select-native";
6
+ import type { HTMLAttributes } from "astro/types";
7
+
8
+ type DefaultOptionProps = HTMLAttributes<"option">;
9
+
10
+ export type PrimitiveOptionProps = DefaultOptionProps & {
11
+ passThrough?: {
12
+ option?: SelectSlotPassThrough;
13
+ };
14
+ };
15
+
16
+ type Props = PrimitiveOptionProps;
17
+
18
+ const { class: className, passThrough, ...rest }: Props = Astro.props;
19
+
20
+ const api = connectSelectOption({
21
+ class: typeof className === "string" ? className : undefined,
22
+ passThrough,
23
+ optionAttrs: rest,
24
+ });
25
+ ---
26
+
27
+ <option {...api.optionProps as HTMLAttributes<"option">}>
28
+ <slot />
29
+ </option>
@@ -0,0 +1,4 @@
1
+ import Component from "./option.astro";
2
+ export * from "./option.astro";
3
+
4
+ export default Component;
@@ -0,0 +1,49 @@
1
+ ---
2
+ import {
3
+ connectSelect,
4
+ type SelectBaseProps,
5
+ type SelectFeedback,
6
+ type SelectSize,
7
+ type SelectBackground,
8
+ type SelectBorder,
9
+ } from "@pindoba/core-select-native";
10
+ import type { HTMLAttributes } from "astro/types";
11
+
12
+ type DefaultSelectProps = Omit<HTMLAttributes<"select">, "size">;
13
+
14
+ export interface PrimitiveSelectProps
15
+ extends DefaultSelectProps, SelectBaseProps {
16
+ feedback?: SelectFeedback;
17
+ size?: SelectSize;
18
+ background?: SelectBackground;
19
+ border?: SelectBorder;
20
+ }
21
+
22
+ type Props = PrimitiveSelectProps;
23
+
24
+ const {
25
+ feedback,
26
+ size,
27
+ background,
28
+ border,
29
+ class: className,
30
+ passThrough,
31
+ ...rest
32
+ }: Props = Astro.props;
33
+
34
+ const api = connectSelect({
35
+ feedback,
36
+ size,
37
+ background,
38
+ border,
39
+ passThrough,
40
+ class: typeof className === "string" ? className : undefined,
41
+ selectAttrs: rest,
42
+ });
43
+ ---
44
+
45
+ <div {...api.rootProps}>
46
+ <select {...api.selectProps as HTMLAttributes<"select">}>
47
+ <slot />
48
+ </select>
49
+ </div>
@@ -0,0 +1,4 @@
1
+ import Component from "./select.astro";
2
+ export * from "./select.astro";
3
+
4
+ export default Component;
@@ -0,0 +1,28 @@
1
+ ---
2
+ import PrimitiveSelect, {
3
+ type PrimitiveSelectProps,
4
+ } from "./primitives/select.astro";
5
+ import PrimitiveOption from "./primitives/option.astro";
6
+
7
+ import type { PrimitiveOptionProps } from "./primitives/option.astro";
8
+
9
+ interface Item extends PrimitiveOptionProps {
10
+ label: string;
11
+ }
12
+
13
+ type Props = PrimitiveSelectProps & {
14
+ items: Item[];
15
+ };
16
+
17
+ const { items, ...rest } = Astro.props;
18
+ ---
19
+
20
+ <PrimitiveSelect {...rest}>
21
+ {
22
+ items.map((item) => (
23
+ <PrimitiveOption class={item.class} {...item}>
24
+ {item.label}
25
+ </PrimitiveOption>
26
+ ))
27
+ }
28
+ </PrimitiveSelect>