@startupjs-ui/array-input 0.1.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## [0.1.3](https://github.com/startupjs/startupjs-ui/compare/v0.1.2...v0.1.3) (2025-12-29)
7
+
8
+ **Note:** Version bump only for package @startupjs-ui/array-input
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.1.2](https://github.com/startupjs/startupjs-ui/compare/v0.1.1...v0.1.2) (2025-12-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * add mdx and docs packages. Refactor docs to get rid of any @startupjs/ui usage and use startupjs-ui instead ([703c926](https://github.com/startupjs/startupjs-ui/commit/703c92636efb0421ffd11783f692fc892b74018f))
20
+ * **array-input:** refactor ArrayInput component. Fix circular dependency issue in Input/inputs (wrapInput). ([14e7204](https://github.com/startupjs/startupjs-ui/commit/14e720423874cbbae8220160e3f5f0713a44b67a))
21
+ * **object-input:** refactor ObjectInput component ([f21693c](https://github.com/startupjs/startupjs-ui/commit/f21693c7f2a31198f445ec3656fb780feb2269bd))
package/README.mdx ADDED
@@ -0,0 +1,47 @@
1
+ import { $ } from 'startupjs'
2
+ import ArrayInput, { _PropsJsonSchema as ArrayInputPropsJsonSchema } from './index'
3
+ import { Sandbox } from '@startupjs-ui/docs'
4
+
5
+ # ArrayInput
6
+
7
+ ArrayInput lets you build dynamic forms using its declarative API.
8
+
9
+ ArrayInput accepts an input metadata object with a required `input` key to specify what type of input to display in the `items` property.
10
+
11
+ Possible types are: [array](/docs/forms/Array), [checkbox](/docs/forms/Checkbox), [date](/docs/forms/DateTimePicker), [datetime](/docs/forms/DateTimePicker), [multiselect](/docs/forms/Multiselect), [number](/docs/forms/NumberInput), [object](/docs/forms/ObjectInput), [password](/docs/forms/PasswordInput), [radio](/docs/forms/Radio), [select](/docs/forms/Select), [time](/docs/forms/DateTimePicker), [text](/docs/forms/TextInput).
12
+
13
+ ```jsx
14
+ import { ArrayInput } from 'startupjs-ui'
15
+ ```
16
+
17
+ ## Simple example
18
+
19
+ ```jsx example
20
+ const $value = $(['Green', 'Blue'])
21
+ return (
22
+ <ArrayInput
23
+ $value={$value}
24
+ items={{ type: 'text' }}
25
+ />
26
+ )
27
+ ```
28
+
29
+ ## Sandbox
30
+
31
+ export function SandboxWrapper () {
32
+ const $value = $(['Green', 'Blue'])
33
+
34
+ return (
35
+ <Sandbox
36
+ Component={ArrayInput}
37
+ propsJsonSchema={ArrayInputPropsJsonSchema}
38
+ props={{
39
+ $value,
40
+ items: { type: 'text' }
41
+ }}
42
+ block
43
+ />
44
+ )
45
+ }
46
+
47
+ <SandboxWrapper />
@@ -0,0 +1,17 @@
1
+ $button = var(--color-text-placeholder)
2
+
3
+ .item
4
+ flex-direction row
5
+
6
+ .input
7
+ flex 1
8
+
9
+ .add
10
+ &:part(icon)
11
+ color: $button
12
+
13
+ .actions
14
+ width 4u
15
+
16
+ .pushTop
17
+ margin-top 1u
package/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /* eslint-disable */
2
+ // DO NOT MODIFY THIS FILE - IT IS AUTOMATICALLY GENERATED ON COMMITS.
3
+
4
+ import { type ReactNode } from 'react';
5
+ import { type StyleProp, type ViewStyle } from 'react-native';
6
+ import './index.cssx.styl';
7
+ declare const _default: import("react").ComponentType<ArrayInputProps>;
8
+ export default _default;
9
+ export declare const _PropsJsonSchema: {};
10
+ export interface ArrayInputProps {
11
+ /** Custom styles for the wrapper */
12
+ style?: StyleProp<ViewStyle>;
13
+ /** Custom styles for the inner input container */
14
+ inputStyle?: StyleProp<ViewStyle>;
15
+ /** Model binding for array values */
16
+ $value: any;
17
+ /** Input metadata for array items (must include `input` or `type`) */
18
+ items: Record<string, any>;
19
+ /** Custom wrapper renderer (used by Input layout wrappers) */
20
+ _renderWrapper?: (style: any, children: ReactNode) => ReactNode;
21
+ [key: string]: any;
22
+ }
package/index.tsx ADDED
@@ -0,0 +1,85 @@
1
+ import { type ReactNode } from 'react'
2
+ import { type StyleProp, type ViewStyle } from 'react-native'
3
+ import { pug, observer } from 'startupjs'
4
+ import { themed } from '@startupjs-ui/core'
5
+ import Div from '@startupjs-ui/div'
6
+ import Button from '@startupjs-ui/button'
7
+ import Input from '@startupjs-ui/input'
8
+ import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes'
9
+ import './index.cssx.styl'
10
+
11
+ export default observer(
12
+ themed('ArrayInput', ArrayInput)
13
+ )
14
+
15
+ export const _PropsJsonSchema = {/* ArrayInputProps */}
16
+
17
+ export interface ArrayInputProps {
18
+ /** Custom styles for the wrapper */
19
+ style?: StyleProp<ViewStyle>
20
+ /** Custom styles for the inner input container */
21
+ inputStyle?: StyleProp<ViewStyle>
22
+ /** Model binding for array values */
23
+ $value: any
24
+ /** Input metadata for array items (must include `input` or `type`) */
25
+ items: Record<string, any>
26
+ /** Custom wrapper renderer (used by Input layout wrappers) */
27
+ _renderWrapper?: (style: any, children: ReactNode) => ReactNode
28
+ [key: string]: any
29
+ }
30
+
31
+ function ArrayInput ({
32
+ style,
33
+ inputStyle,
34
+ $value,
35
+ items,
36
+ _renderWrapper
37
+ }: ArrayInputProps): ReactNode {
38
+ if (!$value || !items) return null
39
+
40
+ const arrayLength = $value.get()?.length || 0
41
+
42
+ function getInputs () {
43
+ return Array(arrayLength + 1).fill(null).map((_, index) => {
44
+ return {
45
+ ...items,
46
+ $value: $value[index]
47
+ }
48
+ })
49
+ }
50
+
51
+ const inputs = getInputs()
52
+
53
+ if (!_renderWrapper) {
54
+ _renderWrapper = (style, children): ReactNode => {
55
+ return pug`
56
+ Div(style=style)= children
57
+ `
58
+ }
59
+ }
60
+
61
+ // TODO: Instead of just a delete icon, make a three dots menu with things like:
62
+ // - delete
63
+ // - move up
64
+ // - move down
65
+ // - add new item before
66
+ // - add new item after
67
+ return _renderWrapper({
68
+ style: [style, inputStyle]
69
+ }, pug`
70
+ each inputProps, index in inputs
71
+ Div.item(key=index styleName={ pushTop: index !== 0 })
72
+ Div.input
73
+ Input(...inputProps)
74
+ Div.actions(vAlign='center' align='right')
75
+ if index < arrayLength
76
+ Button.remove(
77
+ tabIndex=-1
78
+ size='s'
79
+ variant='text'
80
+ icon=faTimes
81
+ onPress=() => $value[index].del()
82
+ color='text-subtle'
83
+ )
84
+ `)
85
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@startupjs-ui/array-input",
3
+ "version": "0.1.3",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "main": "index.tsx",
8
+ "types": "index.d.ts",
9
+ "type": "module",
10
+ "dependencies": {
11
+ "@startupjs-ui/button": "^0.1.3",
12
+ "@startupjs-ui/core": "^0.1.3",
13
+ "@startupjs-ui/div": "^0.1.3",
14
+ "@startupjs-ui/input": "^0.1.3"
15
+ },
16
+ "peerDependencies": {
17
+ "react": "*",
18
+ "react-native": "*",
19
+ "startupjs": "*"
20
+ },
21
+ "gitHead": "fd964ebc3892d3dd0a6c85438c0af619cc50c3f0"
22
+ }