mountain-ui 1.0.0
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 +21 -0
- package/README.md +139 -0
- package/index.js +36 -0
- package/package.json +79 -0
- package/src/app.html +12 -0
- package/src/lib/assets/favicon.svg +1 -0
- package/src/lib/registry/entityRegistry/components/EntityButton.svelte +14 -0
- package/src/lib/registry/entityRegistry/components/EntityCard.svelte +64 -0
- package/src/lib/registry/entityRegistry/components/EntityForm.svelte +98 -0
- package/src/lib/registry/entityRegistry/components/FieldButton copy.svelte +41 -0
- package/src/lib/registry/entityRegistry/components/FieldButton.svelte +41 -0
- package/src/lib/registry/entityRegistry/components/FieldCard.svelte +60 -0
- package/src/lib/registry/entityRegistry/components/FieldIcon.svelte +21 -0
- package/src/lib/registry/entityRegistry/components/FieldInput.svelte +23 -0
- package/src/lib/registry/entityRegistry/components/FieldIsRequiredIcon.svelte +22 -0
- package/src/lib/registry/entityRegistry/components/FieldIsSecretIcon.svelte +19 -0
- package/src/lib/registry/entityRegistry/components/FieldIsUniqueIcon.svelte +21 -0
- package/src/lib/registry/entityRegistry/components/FormCtx.svelte +7 -0
- package/src/lib/registry/entityRegistry/components/LinkIcon.svelte +20 -0
- package/src/lib/registry/entityRegistry/createEntity.js +40 -0
- package/src/lib/registry/entityRegistry/registry.svelte.js +140 -0
- package/src/lib/registry/fieldTypeRegistry/components/FieldTypeButton.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/components/FieldTypeCard.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/components/FieldTypeIcon.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/components/FieldTypeInput.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/components/Label.svelte +28 -0
- package/src/lib/registry/fieldTypeRegistry/components/Line.svelte +31 -0
- package/src/lib/registry/fieldTypeRegistry/createFieldType.js +34 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/FieldTypeButton.svelte +10 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/FieldTypeCard.svelte +41 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Button.svelte +10 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Icon.svelte +5 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/Input.svelte +150 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Lines/index.js +37 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Button.svelte +10 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Icon.svelte +4 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/Input.svelte +106 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/LinkCard.svelte +49 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/LinkCardSelection.svelte +65 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/Input/utils.js +25 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Link/index.js +37 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/Button.svelte +10 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/Icon.svelte +5 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/Primary/index.js +36 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/Icon.svelte +9 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/Input.svelte +153 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/calculation/CalculationColumn/index.js +37 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/Icon.svelte +4 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/Input.svelte +88 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListCheckbox/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/Icon.svelte +4 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/Input.svelte +95 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/list/ListRadio/index.js +44 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/Icon.svelte +5 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/Input.svelte +16 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/NumberInt/index.js +41 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/FieldTypeInputFloat.svelte +55 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/Icon.svelte +7 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/Input.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatDefault/index.js +41 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/Icon.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPercent/index.js +41 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/Icon.svelte +5 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/number/float/NumberFloatPrice/index.js +41 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/Icon.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/Input.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/TextTextarea/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/FieldTypeInputText.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/Icon.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharDefault/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/Icon.svelte +4 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/Input.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharEmail/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/Icon.svelte +7 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/Input.svelte +37 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPassword/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/Icon.svelte +3 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/Input.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharPhone/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/Icon.svelte +7 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/Input.svelte +14 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/text/varchar/TextVarcharUrl/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/Icon.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeCreatedAt/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/Icon.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDate/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/Icon.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDatetime/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/Icon.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeDay/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/Icon.svelte +4 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeHour/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/Icon.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonth/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/Icon.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeMonthOfYear/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/Icon.svelte +11 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeUpdatedAt/index.js +38 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/Button.svelte +8 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/Card.svelte +6 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/Icon.svelte +12 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/Input.svelte +15 -0
- package/src/lib/registry/fieldTypeRegistry/fieldTypes/time/TimeYear/index.js +39 -0
- package/src/lib/registry/fieldTypeRegistry/registerDefaultFieldTypes.js +66 -0
- package/src/lib/registry/fieldTypeRegistry/registry.svelte.js +72 -0
- package/src/routes/+layout.svelte +623 -0
- package/src/routes/+page.svelte +196 -0
- package/src/routes/global.css +197 -0
- package/src/routes/login/+page.svelte +112 -0
- package/src/routes/registry/fieldRegistry.svelte.js +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mountain Team
|
|
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,139 @@
|
|
|
1
|
+
# Mountain UI
|
|
2
|
+
|
|
3
|
+
A comprehensive UI component library for ERP systems built with Svelte. Features an extensive registry system for managing field types, entities, and custom UI components.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Field Type Registry**: Manage and display different field types (text, numbers, dates, links, calculations, lists, etc.)
|
|
8
|
+
- 📦 **Entity Registry**: Create and manage entity models with automatic form generation
|
|
9
|
+
- 🔧 **Component System**: Pre-built components for forms, cards, buttons, and icons
|
|
10
|
+
- 🎯 **Type-Safe**: Built with Svelte 5 and full runes support
|
|
11
|
+
- 📝 **Form Context**: Advanced form state management with context system
|
|
12
|
+
- 🔗 **Relationships**: Support for linked entities and relational data
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install mountain-ui
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### Basic Usage
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import {
|
|
26
|
+
fieldTypeRegistry,
|
|
27
|
+
entityRegistry,
|
|
28
|
+
registerDefaultFieldTypes,
|
|
29
|
+
EntityForm
|
|
30
|
+
} from 'mountain-ui';
|
|
31
|
+
|
|
32
|
+
// Register default field types
|
|
33
|
+
registerDefaultFieldTypes();
|
|
34
|
+
|
|
35
|
+
// Use entity form component
|
|
36
|
+
import EntityForm from 'mountain-ui/EntityForm.svelte';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Components
|
|
40
|
+
|
|
41
|
+
### Field Type Components
|
|
42
|
+
- `FieldTypeIcon` - Icon for field types
|
|
43
|
+
- `FieldTypeButton` - Button component for field types
|
|
44
|
+
- `FieldTypeCard` - Card display for field types
|
|
45
|
+
- `FieldTypeInput` - Input component for field types
|
|
46
|
+
- `Label` - Label component
|
|
47
|
+
- `Line` - Line separator component
|
|
48
|
+
|
|
49
|
+
### Entity Components
|
|
50
|
+
- `EntityButton` - Button for entity actions
|
|
51
|
+
- `EntityCard` - Card display for entities
|
|
52
|
+
- `EntityForm` - Complete form for entity data
|
|
53
|
+
- `FieldButton` - Button for field actions
|
|
54
|
+
- `FieldCard` - Card for field display
|
|
55
|
+
- `FieldIcon` - Icon for fields
|
|
56
|
+
- `FieldInput` - Input for field values
|
|
57
|
+
- `FieldIsRequiredIcon` - Indicator for required fields
|
|
58
|
+
- `FieldIsSecretIcon` - Indicator for secret fields
|
|
59
|
+
- `FieldIsUniqueIcon` - Indicator for unique fields
|
|
60
|
+
- `FormCtx` - Form context provider
|
|
61
|
+
- `LinkIcon` - Icon for linked fields
|
|
62
|
+
|
|
63
|
+
## Registries
|
|
64
|
+
|
|
65
|
+
### Field Type Registry
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { fieldTypeRegistry, createFieldType } from 'mountain-ui';
|
|
69
|
+
|
|
70
|
+
// Create custom field type
|
|
71
|
+
const customFieldType = createFieldType({
|
|
72
|
+
id: 'custom',
|
|
73
|
+
name: 'Custom Field',
|
|
74
|
+
icon: 'icon-path'
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Register it
|
|
78
|
+
fieldTypeRegistry.register(customFieldType);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Entity Registry
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
import { entityRegistry, createEntity } from 'mountain-ui';
|
|
85
|
+
|
|
86
|
+
// Create entity
|
|
87
|
+
const entity = createEntity({
|
|
88
|
+
id: 'user',
|
|
89
|
+
name: 'User',
|
|
90
|
+
fields: [...]
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Register it
|
|
94
|
+
entityRegistry.register(entity);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Dependencies
|
|
98
|
+
|
|
99
|
+
- Svelte ^5.56.1
|
|
100
|
+
- hamzus-ui ^0.0.255
|
|
101
|
+
|
|
102
|
+
## Requirements
|
|
103
|
+
|
|
104
|
+
- Node.js >= 18.0.0
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT
|
|
109
|
+
|
|
110
|
+
## Author
|
|
111
|
+
|
|
112
|
+
Mountain Team
|
|
113
|
+
|
|
114
|
+
## Repository
|
|
115
|
+
|
|
116
|
+
[GitHub Repository](https://github.com/yourusername/mountain-ui)
|
|
117
|
+
|
|
118
|
+
## Developing
|
|
119
|
+
|
|
120
|
+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
npm run dev
|
|
124
|
+
|
|
125
|
+
# or start the server and open the app in a new browser tab
|
|
126
|
+
npm run dev -- --open
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Building
|
|
130
|
+
|
|
131
|
+
To create a production version of your app:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm run build
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can preview the production build with `npm run preview`.
|
|
138
|
+
|
|
139
|
+
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// Field Type Registry
|
|
3
|
+
// ============================================
|
|
4
|
+
export { fieldTypeRegistry } from "./src/lib/registry/fieldTypeRegistry/registry.svelte.js"
|
|
5
|
+
export { createFieldType } from "./src/lib/registry/fieldTypeRegistry/createFieldType.js"
|
|
6
|
+
export { registerDefaultFieldTypes } from "./src/lib/registry/fieldTypeRegistry/registerDefaultFieldTypes.js"
|
|
7
|
+
|
|
8
|
+
// Field Type Registry Components
|
|
9
|
+
export { default as FieldTypeIcon } from "./src/lib/registry/fieldTypeRegistry/components/FieldTypeIcon.svelte"
|
|
10
|
+
export { default as FieldTypeButton } from "./src/lib/registry/fieldTypeRegistry/components/FieldTypeButton.svelte"
|
|
11
|
+
export { default as FieldTypeCard } from "./src/lib/registry/fieldTypeRegistry/components/FieldTypeCard.svelte"
|
|
12
|
+
export { default as FieldTypeInput } from "./src/lib/registry/fieldTypeRegistry/components/FieldTypeInput.svelte"
|
|
13
|
+
export { default as Label } from "./src/lib/registry/fieldTypeRegistry/components/Label.svelte"
|
|
14
|
+
export { default as Line } from "./src/lib/registry/fieldTypeRegistry/components/Line.svelte"
|
|
15
|
+
|
|
16
|
+
// ============================================
|
|
17
|
+
// Entity Registry
|
|
18
|
+
// ============================================
|
|
19
|
+
export { entityRegistry } from "./src/lib/registry/entityRegistry/registry.svelte.js"
|
|
20
|
+
export { createEntity } from "./src/lib/registry/entityRegistry/createEntity.js"
|
|
21
|
+
|
|
22
|
+
// Entity Registry Components
|
|
23
|
+
export { default as EntityButton } from "./src/lib/registry/entityRegistry/components/EntityButton.svelte"
|
|
24
|
+
export { default as EntityCard } from "./src/lib/registry/entityRegistry/components/EntityCard.svelte"
|
|
25
|
+
export { default as EntityForm } from "./src/lib/registry/entityRegistry/components/EntityForm.svelte"
|
|
26
|
+
export { default as FieldButton } from "./src/lib/registry/entityRegistry/components/FieldButton.svelte"
|
|
27
|
+
export { default as FieldCard } from "./src/lib/registry/entityRegistry/components/FieldCard.svelte"
|
|
28
|
+
export { default as FieldIcon } from "./src/lib/registry/entityRegistry/components/FieldIcon.svelte"
|
|
29
|
+
export { default as FieldInput } from "./src/lib/registry/entityRegistry/components/FieldInput.svelte"
|
|
30
|
+
export { default as FieldIsRequiredIcon } from "./src/lib/registry/entityRegistry/components/FieldIsRequiredIcon.svelte"
|
|
31
|
+
export { default as FieldIsSecretIcon } from "./src/lib/registry/entityRegistry/components/FieldIsSecretIcon.svelte"
|
|
32
|
+
export { default as FieldIsUniqueIcon } from "./src/lib/registry/entityRegistry/components/FieldIsUniqueIcon.svelte"
|
|
33
|
+
export { default as FormCtx } from "./src/lib/registry/entityRegistry/components/FormCtx.svelte"
|
|
34
|
+
export { default as LinkIcon } from "./src/lib/registry/entityRegistry/components/LinkIcon.svelte"
|
|
35
|
+
|
|
36
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mountain-ui",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "A comprehensive UI component library for ERP systems with field types, entities, and registry management built with Svelte",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"src",
|
|
19
|
+
"index.js",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"svelte",
|
|
25
|
+
"ui",
|
|
26
|
+
"components",
|
|
27
|
+
"erp",
|
|
28
|
+
"forms",
|
|
29
|
+
"fields",
|
|
30
|
+
"entities",
|
|
31
|
+
"registry"
|
|
32
|
+
],
|
|
33
|
+
"author": "Mountain Team",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/yourusername/mountain-ui.git"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/yourusername/mountain-ui/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/yourusername/mountain-ui#readme",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"dev": "vite dev",
|
|
45
|
+
"build": "vite build",
|
|
46
|
+
"build:lib": "vite build --mode lib",
|
|
47
|
+
"preview": "vite preview",
|
|
48
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
49
|
+
"lint": "prettier --check . && eslint .",
|
|
50
|
+
"format": "prettier --write .",
|
|
51
|
+
"test:unit": "vitest",
|
|
52
|
+
"test": "npm run test:unit -- --run"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@eslint/js": "^10.0.1",
|
|
56
|
+
"@sveltejs/adapter-auto": "^7.0.1",
|
|
57
|
+
"@sveltejs/kit": "^2.63.0",
|
|
58
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
59
|
+
"@types/node": "^24",
|
|
60
|
+
"@vitest/browser-playwright": "^4.1.8",
|
|
61
|
+
"eslint": "^10.4.1",
|
|
62
|
+
"eslint-config-prettier": "^10.1.8",
|
|
63
|
+
"eslint-plugin-svelte": "^3.19.0",
|
|
64
|
+
"globals": "^17.6.0",
|
|
65
|
+
"playwright": "^1.60.0",
|
|
66
|
+
"prettier": "^3.8.3",
|
|
67
|
+
"prettier-plugin-svelte": "^4.1.0",
|
|
68
|
+
"svelte": "^5.56.1",
|
|
69
|
+
"vite": "^8.0.16",
|
|
70
|
+
"vitest": "^4.1.8",
|
|
71
|
+
"vitest-browser-svelte": "^2.1.1"
|
|
72
|
+
},
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"hamzus-ui": "^0.0.255"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=18.0.0"
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/app.html
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="text-scale" content="scale" />
|
|
7
|
+
%sveltekit.head%
|
|
8
|
+
</head>
|
|
9
|
+
<body data-sveltekit-preload-data="hover">
|
|
10
|
+
<div style="display: contents">%sveltekit.body%</div>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button } from "hamzus-ui";
|
|
3
|
+
import { entityRegistry } from "../registry.svelte";
|
|
4
|
+
|
|
5
|
+
let {id, variant="ghost",...props} = $props()
|
|
6
|
+
|
|
7
|
+
const entity = entityRegistry.get(id)
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if entity}
|
|
11
|
+
<Button {...props} {variant}>
|
|
12
|
+
<h5>{entity.plural_name}</h5>
|
|
13
|
+
</Button>
|
|
14
|
+
{/if}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button } from 'hamzus-ui';
|
|
3
|
+
import { entityRegistry } from '../registry.svelte';
|
|
4
|
+
import FieldIcon from './FieldIcon.svelte';
|
|
5
|
+
import LinkIcon from './LinkIcon.svelte';
|
|
6
|
+
|
|
7
|
+
let { id, variant = 'ghost', ...props } = $props();
|
|
8
|
+
|
|
9
|
+
const entity = entityRegistry.get(id);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if entity}
|
|
13
|
+
<Button {...props} {variant} style="border-radius:var(--radius-xl);">
|
|
14
|
+
<div class="card">
|
|
15
|
+
<div class="top">
|
|
16
|
+
<h3>{entity.plural_name}</h3>
|
|
17
|
+
<div class="field">
|
|
18
|
+
<h5>{entity.fields.length}</h5>
|
|
19
|
+
<FieldIcon color="var(--font-2)" size="16px"></FieldIcon>
|
|
20
|
+
</div>
|
|
21
|
+
{#if entity.fields.find(f=>f.type ==="link")}
|
|
22
|
+
<div class="field">
|
|
23
|
+
<h5>{entity.fields.filter(f=>f.type ==="link").length}</h5>
|
|
24
|
+
<LinkIcon color="var(--font-2)" size="16px"></LinkIcon>
|
|
25
|
+
</div>
|
|
26
|
+
{/if}
|
|
27
|
+
</div>
|
|
28
|
+
<h6>/{entity.slug}</h6>
|
|
29
|
+
</div>
|
|
30
|
+
</Button>
|
|
31
|
+
{/if}
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.card {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: baseline;
|
|
38
|
+
padding: var(--pad-m);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.card .top {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
column-gap: var(--pad-xxl);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.card .field {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
column-gap: var(--pad-xs);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.card h3 {
|
|
54
|
+
text-transform: capitalize;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card h5 {
|
|
58
|
+
color: var(--font-1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.card > h6 {
|
|
62
|
+
color: var(--font-2);
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Button, Form } from 'hamzus-ui';
|
|
3
|
+
import { entityRegistry } from '../registry.svelte';
|
|
4
|
+
import FieldInput from './FieldInput.svelte';
|
|
5
|
+
import FormCtx from './FormCtx.svelte';
|
|
6
|
+
|
|
7
|
+
let { entityId, type = 'create' } = $props();
|
|
8
|
+
|
|
9
|
+
let ctx = $state({});
|
|
10
|
+
let detailsCtx = $state({});
|
|
11
|
+
|
|
12
|
+
const entity = entityRegistry.select(entityId);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if $entity}
|
|
16
|
+
<Form style="width:100%">
|
|
17
|
+
<div class="form">
|
|
18
|
+
<FormCtx bind:ctx bind:detailsCtx>
|
|
19
|
+
{#each $entity.fields as field}
|
|
20
|
+
<FieldInput
|
|
21
|
+
{detailsCtx}
|
|
22
|
+
{ctx}
|
|
23
|
+
onChangeDetails={(value) => {
|
|
24
|
+
detailsCtx[field.id] = value;
|
|
25
|
+
detailsCtx={...detailsCtx}
|
|
26
|
+
}}
|
|
27
|
+
onChange={(value) => {
|
|
28
|
+
ctx[field.id] = value;
|
|
29
|
+
ctx={...ctx}
|
|
30
|
+
}}
|
|
31
|
+
id={field.id}
|
|
32
|
+
entityId={$entity.id}
|
|
33
|
+
></FieldInput>
|
|
34
|
+
{/each}
|
|
35
|
+
<div class="button">
|
|
36
|
+
<Button type="submit">
|
|
37
|
+
<h5>{type === 'create' ? 'créée' : 'éditer'}</h5>
|
|
38
|
+
{#if type === 'create'}
|
|
39
|
+
<svg
|
|
40
|
+
width="24"
|
|
41
|
+
height="24"
|
|
42
|
+
viewBox="0 0 24 24"
|
|
43
|
+
fill="none"
|
|
44
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
+
>
|
|
46
|
+
<path
|
|
47
|
+
d="M18 12.75H6C5.59 12.75 5.25 12.41 5.25 12C5.25 11.59 5.59 11.25 6 11.25H18C18.41 11.25 18.75 11.59 18.75 12C18.75 12.41 18.41 12.75 18 12.75Z"
|
|
48
|
+
fill="#292D32"
|
|
49
|
+
/>
|
|
50
|
+
<path
|
|
51
|
+
d="M12 18.75C11.59 18.75 11.25 18.41 11.25 18V6C11.25 5.59 11.59 5.25 12 5.25C12.41 5.25 12.75 5.59 12.75 6V18C12.75 18.41 12.41 18.75 12 18.75Z"
|
|
52
|
+
fill="#292D32"
|
|
53
|
+
/>
|
|
54
|
+
</svg>
|
|
55
|
+
{:else}
|
|
56
|
+
<svg
|
|
57
|
+
width="24"
|
|
58
|
+
height="24"
|
|
59
|
+
viewBox="0 0 24 24"
|
|
60
|
+
fill="none"
|
|
61
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
62
|
+
>
|
|
63
|
+
<path
|
|
64
|
+
d="M15 22.75H9C3.57 22.75 1.25 20.43 1.25 15V9C1.25 3.57 3.57 1.25 9 1.25H11C11.41 1.25 11.75 1.59 11.75 2C11.75 2.41 11.41 2.75 11 2.75H9C4.39 2.75 2.75 4.39 2.75 9V15C2.75 19.61 4.39 21.25 9 21.25H15C19.61 21.25 21.25 19.61 21.25 15V13C21.25 12.59 21.59 12.25 22 12.25C22.41 12.25 22.75 12.59 22.75 13V15C22.75 20.43 20.43 22.75 15 22.75Z"
|
|
65
|
+
fill="#292D32"
|
|
66
|
+
/>
|
|
67
|
+
<path
|
|
68
|
+
d="M8.49935 17.6901C7.88935 17.6901 7.32935 17.4701 6.91935 17.0701C6.42935 16.5801 6.21935 15.8701 6.32935 15.1201L6.75935 12.1101C6.83935 11.5301 7.21935 10.7801 7.62935 10.3701L15.5093 2.49006C17.4993 0.500059 19.5193 0.500059 21.5093 2.49006C22.5993 3.58006 23.0893 4.69006 22.9893 5.80006C22.8993 6.70006 22.4193 7.58006 21.5093 8.48006L13.6293 16.3601C13.2193 16.7701 12.4693 17.1501 11.8893 17.2301L8.87935 17.6601C8.74935 17.6901 8.61935 17.6901 8.49935 17.6901ZM16.5693 3.55006L8.68935 11.4301C8.49935 11.6201 8.27935 12.0601 8.23935 12.3201L7.80935 15.3301C7.76935 15.6201 7.82935 15.8601 7.97935 16.0101C8.12935 16.1601 8.36935 16.2201 8.65935 16.1801L11.6693 15.7501C11.9293 15.7101 12.3793 15.4901 12.5593 15.3001L20.4393 7.42006C21.0893 6.77006 21.4293 6.19006 21.4793 5.65006C21.5393 5.00006 21.1993 4.31006 20.4393 3.54006C18.8393 1.94006 17.7393 2.39006 16.5693 3.55006Z"
|
|
69
|
+
fill="#292D32"
|
|
70
|
+
/>
|
|
71
|
+
<path
|
|
72
|
+
d="M19.8496 9.82978C19.7796 9.82978 19.7096 9.81978 19.6496 9.79978C17.0196 9.05978 14.9296 6.96978 14.1896 4.33978C14.0796 3.93978 14.3096 3.52978 14.7096 3.40978C15.1096 3.29978 15.5196 3.52978 15.6296 3.92978C16.2296 6.05978 17.9196 7.74978 20.0496 8.34978C20.4496 8.45978 20.6796 8.87978 20.5696 9.27978C20.4796 9.61978 20.1796 9.82978 19.8496 9.82978Z"
|
|
73
|
+
fill="#292D32"
|
|
74
|
+
/>
|
|
75
|
+
</svg>
|
|
76
|
+
{/if}
|
|
77
|
+
</Button>
|
|
78
|
+
</div>
|
|
79
|
+
</FormCtx>
|
|
80
|
+
</div>
|
|
81
|
+
</Form>
|
|
82
|
+
{/if}
|
|
83
|
+
|
|
84
|
+
<style>
|
|
85
|
+
.form {
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
align-items: center;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.button {
|
|
92
|
+
width: min(100%, 900px);
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: end;
|
|
96
|
+
padding: var(--pad-m);
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import FieldTypeIcon from '$lib/registry/fieldTypeRegistry/components/FieldTypeIcon.svelte';
|
|
3
|
+
import { fieldTypeRegistry } from '$lib/registry/fieldTypeRegistry/registry.svelte';
|
|
4
|
+
import { Button } from 'hamzus-ui';
|
|
5
|
+
import { entityRegistry } from '../registry.svelte';
|
|
6
|
+
import FieldIsSecretIcon from './FieldIsSecretIcon.svelte';
|
|
7
|
+
import FieldIsUniqueIcon from './FieldIsUniqueIcon.svelte';
|
|
8
|
+
import FieldIsRequiredIcon from './FieldIsRequiredIcon.svelte';
|
|
9
|
+
|
|
10
|
+
let { id, variant = 'ghost', entityId = null, ...props } = $props();
|
|
11
|
+
|
|
12
|
+
const field = entityRegistry.selectField(id, entityId);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if $field}
|
|
16
|
+
<Button {variant} {...props}>
|
|
17
|
+
<FieldTypeIcon type={$field.type}></FieldTypeIcon>
|
|
18
|
+
<h4>{$field.name}</h4>
|
|
19
|
+
|
|
20
|
+
<div class="icons">
|
|
21
|
+
{#if $field.is_secret}
|
|
22
|
+
<FieldIsSecretIcon></FieldIsSecretIcon>
|
|
23
|
+
{/if}
|
|
24
|
+
{#if $field.is_unique}
|
|
25
|
+
<FieldIsUniqueIcon></FieldIsUniqueIcon>
|
|
26
|
+
{/if}
|
|
27
|
+
{#if $field.is_required}
|
|
28
|
+
<FieldIsRequiredIcon></FieldIsRequiredIcon>
|
|
29
|
+
{/if}
|
|
30
|
+
</div>
|
|
31
|
+
</Button>
|
|
32
|
+
{/if}
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.icons {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
column-gap: var(--pad-m);
|
|
39
|
+
margin-left: auto;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import FieldTypeIcon from '$lib/registry/fieldTypeRegistry/components/FieldTypeIcon.svelte';
|
|
3
|
+
import { fieldTypeRegistry } from '$lib/registry/fieldTypeRegistry/registry.svelte';
|
|
4
|
+
import { Button } from 'hamzus-ui';
|
|
5
|
+
import { entityRegistry } from '../registry.svelte';
|
|
6
|
+
import FieldIsSecretIcon from './FieldIsSecretIcon.svelte';
|
|
7
|
+
import FieldIsUniqueIcon from './FieldIsUniqueIcon.svelte';
|
|
8
|
+
import FieldIsRequiredIcon from './FieldIsRequiredIcon.svelte';
|
|
9
|
+
|
|
10
|
+
let { id, variant = 'ghost', entityId = null, ...props } = $props();
|
|
11
|
+
|
|
12
|
+
const field = entityRegistry.selectField(id, entityId);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if $field}
|
|
16
|
+
<Button {variant} {...props}>
|
|
17
|
+
<FieldTypeIcon type={$field.type}></FieldTypeIcon>
|
|
18
|
+
<h4>{$field.name}</h4>
|
|
19
|
+
|
|
20
|
+
<div class="icons">
|
|
21
|
+
{#if $field.is_secret}
|
|
22
|
+
<FieldIsSecretIcon></FieldIsSecretIcon>
|
|
23
|
+
{/if}
|
|
24
|
+
{#if $field.is_unique}
|
|
25
|
+
<FieldIsUniqueIcon></FieldIsUniqueIcon>
|
|
26
|
+
{/if}
|
|
27
|
+
{#if $field.is_required}
|
|
28
|
+
<FieldIsRequiredIcon></FieldIsRequiredIcon>
|
|
29
|
+
{/if}
|
|
30
|
+
</div>
|
|
31
|
+
</Button>
|
|
32
|
+
{/if}
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.icons {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
column-gap: var(--pad-m);
|
|
39
|
+
margin-left: auto;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import FieldTypeIcon from '$lib/registry/fieldTypeRegistry/components/FieldTypeIcon.svelte';
|
|
3
|
+
import { fieldTypeRegistry } from '$lib/registry/fieldTypeRegistry/registry.svelte';
|
|
4
|
+
import { Button } from 'hamzus-ui';
|
|
5
|
+
import { entityRegistry } from '../registry.svelte';
|
|
6
|
+
import FieldIsSecretIcon from './FieldIsSecretIcon.svelte';
|
|
7
|
+
import FieldIsUniqueIcon from './FieldIsUniqueIcon.svelte';
|
|
8
|
+
import FieldIsRequiredIcon from './FieldIsRequiredIcon.svelte';
|
|
9
|
+
|
|
10
|
+
let { id, variant = 'ghost', entityId = null, ...props } = $props();
|
|
11
|
+
|
|
12
|
+
const field = entityRegistry.selectField(id, entityId);
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#if $field}
|
|
16
|
+
<Button {variant} {...props}>
|
|
17
|
+
<div class="card">
|
|
18
|
+
<div class="top">
|
|
19
|
+
<FieldTypeIcon type={$field.type}></FieldTypeIcon>
|
|
20
|
+
<h4>{$field.name}</h4>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="icons">
|
|
23
|
+
{#if $field.is_secret}
|
|
24
|
+
<FieldIsSecretIcon></FieldIsSecretIcon>
|
|
25
|
+
<h5 style="color: var(--red);">secret</h5>
|
|
26
|
+
{/if}
|
|
27
|
+
{#if $field.is_unique}
|
|
28
|
+
<FieldIsUniqueIcon></FieldIsUniqueIcon>
|
|
29
|
+
<h5 style="color: var(--green);">unique</h5>
|
|
30
|
+
{/if}
|
|
31
|
+
{#if $field.is_required}
|
|
32
|
+
<FieldIsRequiredIcon></FieldIsRequiredIcon>
|
|
33
|
+
<h5 style="color: var(--red);">requis</h5>
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</Button>
|
|
38
|
+
{/if}
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
.card {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
row-gap: var(--pad-xs);
|
|
47
|
+
padding: var(--pad-m) var(--pad-m) var(--pad-m) 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.icons,
|
|
51
|
+
.top {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
column-gap: var(--pad-m);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.top :global(svg path) {
|
|
58
|
+
fill: var(--font-2);
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let {size = "24px", color="var(--font-1)"} = $props()
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg style="--size:{size};--color:{color};" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6
|
+
<path d="M11.02 20.25H7.5C6.75 20.25 6.2 20.22 5.73 20.15C2.4 19.78 1.75 17.8 1.75 14.5V9.5C1.75 6.2 2.41 4.21 5.76 3.84C6.2 3.78 6.75 3.75 7.5 3.75H10.96C11.37 3.75 11.71 4.09 11.71 4.5C11.71 4.91 11.37 5.25 10.96 5.25H7.5C6.82 5.25 6.34 5.28 5.95 5.33C3.92 5.55 3.25 6.19 3.25 9.5V14.5C3.25 17.81 3.92 18.44 5.92 18.67C6.34 18.73 6.82 18.75 7.5 18.75H11.02C11.43 18.75 11.77 19.09 11.77 19.5C11.77 19.91 11.43 20.25 11.02 20.25Z" fill="#292D32"/>
|
|
7
|
+
<path d="M16.4995 20.25H15.0195C14.6095 20.25 14.2695 19.91 14.2695 19.5C14.2695 19.09 14.6095 18.75 15.0195 18.75H16.4995C17.1795 18.75 17.6595 18.72 18.0495 18.67C20.0795 18.45 20.7495 17.81 20.7495 14.5V9.5C20.7495 6.19 20.0795 5.56 18.0795 5.33C17.6595 5.27 17.1795 5.25 16.4995 5.25H15.0195C14.6095 5.25 14.2695 4.91 14.2695 4.5C14.2695 4.09 14.6095 3.75 15.0195 3.75H16.4995C17.2495 3.75 17.7995 3.78 18.2695 3.85C21.5995 4.22 22.2495 6.2 22.2495 9.5V14.5C22.2495 17.8 21.5895 19.79 18.2395 20.16C17.7995 20.22 17.2495 20.25 16.4995 20.25Z" fill="#292D32"/>
|
|
8
|
+
<path d="M15 22.75C14.59 22.75 14.25 22.41 14.25 22V2C14.25 1.59 14.59 1.25 15 1.25C15.41 1.25 15.75 1.59 15.75 2V22C15.75 22.41 15.41 22.75 15 22.75Z" fill="#292D32"/>
|
|
9
|
+
<path d="M8 16.25C7.59 16.25 7.25 15.91 7.25 15.5V8.5C7.25 8.09 7.59 7.75 8 7.75C8.41 7.75 8.75 8.09 8.75 8.5V15.5C8.75 15.91 8.41 16.25 8 16.25Z" fill="#292D32"/>
|
|
10
|
+
</svg>
|
|
11
|
+
|
|
12
|
+
<style>
|
|
13
|
+
svg {
|
|
14
|
+
width: var(--size);
|
|
15
|
+
height: auto;
|
|
16
|
+
aspect-ratio: 1/1;
|
|
17
|
+
}
|
|
18
|
+
svg path {
|
|
19
|
+
fill: var(--color);
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import FieldTypeInput from "$lib/registry/fieldTypeRegistry/components/FieldTypeInput.svelte";
|
|
3
|
+
import { entityRegistry } from "../registry.svelte";
|
|
4
|
+
|
|
5
|
+
let { id, entityId = null, onChange=()=>{}, onChangeDetails=()=>{}, ...props } = $props();
|
|
6
|
+
|
|
7
|
+
const field = entityRegistry.selectField(id, entityId);
|
|
8
|
+
|
|
9
|
+
let value = $state("")
|
|
10
|
+
|
|
11
|
+
function handleChange(newVal) {
|
|
12
|
+
value = newVal
|
|
13
|
+
onChange(value)
|
|
14
|
+
}
|
|
15
|
+
function handleChangeDetails(newVal) {
|
|
16
|
+
onChangeDetails(newVal)
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
{#if $field}
|
|
22
|
+
<FieldTypeInput {...props} id={$field.id} entity_id={$field.entity_id} label={$field.name} {...$field.props} onChange={handleChange} onChangeDetails={handleChangeDetails} type={$field.type} required={$field.is_required} secret={$field.is_secret} unique={$field.is_unique}></FieldTypeInput>
|
|
23
|
+
{/if}
|