@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 +7 -0
- package/README.md +35 -0
- package/index.ts +6 -0
- package/package.json +62 -0
- package/src/demos/custom.astro +25 -0
- package/src/demos/feedback.astro +18 -0
- package/src/demos/index.ts +3 -0
- package/src/demos/size.astro +16 -0
- package/src/env.d.ts +2 -0
- package/src/primitives/option.astro +29 -0
- package/src/primitives/option.ts +4 -0
- package/src/primitives/select.astro +49 -0
- package/src/primitives/select.ts +4 -0
- package/src/select.astro +28 -0
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
|
+
[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/non-html-pages)
|
|
10
|
+
[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/non-html-pages)
|
|
11
|
+
[](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
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,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,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,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>
|
package/src/select.astro
ADDED
|
@@ -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>
|