@dile/crud 0.0.9

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.
Files changed (79) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +5 -0
  3. package/components/action/crud-actions.js +2 -0
  4. package/components/action/crud-delete-action.js +2 -0
  5. package/components/action/crud-single-actions.js +2 -0
  6. package/components/action/src/DileCrudActions.js +181 -0
  7. package/components/action/src/DileCrudDeleteAction.js +18 -0
  8. package/components/action/src/DileCrudSingleActions.js +77 -0
  9. package/components/ajax/ajax.js +2 -0
  10. package/components/ajax/index.js +1 -0
  11. package/components/ajax/src/DileAjax.js +108 -0
  12. package/components/ajax-form/ajax-form.js +2 -0
  13. package/components/ajax-form/index.js +1 -0
  14. package/components/ajax-form/src/DileAjaxForm.js +216 -0
  15. package/components/ajax-select-crud/ajax-select-crud.js +3 -0
  16. package/components/ajax-select-crud/index.js +1 -0
  17. package/components/ajax-select-crud/src/DileAjaxSelectCrud.js +75 -0
  18. package/components/crud/crud-single.js +2 -0
  19. package/components/crud/crud.js +2 -0
  20. package/components/crud/delete-action.js +2 -0
  21. package/components/crud/src/DileCrud.js +352 -0
  22. package/components/detail/crud-detail.js +2 -0
  23. package/components/detail/src/DileCrudDetail.js +166 -0
  24. package/components/insert/crud-insert.js +2 -0
  25. package/components/insert/index.js +1 -0
  26. package/components/insert/src/DileCrudInsert.js +78 -0
  27. package/components/item-delete/crud-item-delete.js +2 -0
  28. package/components/item-delete/index.js +1 -0
  29. package/components/item-delete/src/DileCrudItemDelete.js +106 -0
  30. package/components/list/crud-list-item.js +2 -0
  31. package/components/list/crud-list-pagination-links.js +2 -0
  32. package/components/list/crud-list-service.js +2 -0
  33. package/components/list/crud-list.js +2 -0
  34. package/components/list/crud-select-all.js +2 -0
  35. package/components/list/index.js +5 -0
  36. package/components/list/src/DileCrudList.js +332 -0
  37. package/components/list/src/DileCrudListItem.js +129 -0
  38. package/components/list/src/DileCrudListPaginationLinks.js +89 -0
  39. package/components/list/src/DileCrudListService.js +163 -0
  40. package/components/list/src/DileCrudSelectAll.js +158 -0
  41. package/components/single/crud-single.js +2 -0
  42. package/components/single/index.js +1 -0
  43. package/components/single/src/DileCrudSingle.js +142 -0
  44. package/components/ui/crud-filters-form.js +3 -0
  45. package/components/ui/crud-filters-list-item.js +2 -0
  46. package/components/ui/crud-filters-list.js +2 -0
  47. package/components/ui/crud-filters.js +2 -0
  48. package/components/ui/crud-list-options.js +2 -0
  49. package/components/ui/crud-page-size-select.js +2 -0
  50. package/components/ui/crud-page-size.js +2 -0
  51. package/components/ui/crud-pagination-nav-button.js +2 -0
  52. package/components/ui/crud-sort-form.js +2 -0
  53. package/components/ui/index.js +4 -0
  54. package/components/ui/src/DileCrudFilters.js +62 -0
  55. package/components/ui/src/DileCrudFiltersForm.js +58 -0
  56. package/components/ui/src/DileCrudFiltersList.js +70 -0
  57. package/components/ui/src/DileCrudFiltersListItem.js +28 -0
  58. package/components/ui/src/DileCrudListOptions.js +64 -0
  59. package/components/ui/src/DileCrudPageSize.js +27 -0
  60. package/components/ui/src/DileCrudPageSizeSelect.js +44 -0
  61. package/components/ui/src/DileCrudPaginationNavButton.js +44 -0
  62. package/components/ui/src/DileCrudSortForm.js +105 -0
  63. package/components/update/crud-update.js +2 -0
  64. package/components/update/index.js +1 -0
  65. package/components/update/src/DileCrudUpdate.js +81 -0
  66. package/lib/AxiosInstanceBuilder.js +21 -0
  67. package/lib/CrudConfigBuilder.js +13 -0
  68. package/lib/DileAxios.js +14 -0
  69. package/lib/DileConfig.js +0 -0
  70. package/lib/DileCrudMixin.js +72 -0
  71. package/lib/DileLoading.js +31 -0
  72. package/lib/RequestApiAdapter.js +15 -0
  73. package/lib/ResponseApiAdapter.js +37 -0
  74. package/lib/capitalizeString.js +3 -0
  75. package/lib/deepMerge.js +38 -0
  76. package/lib/defaultConfig.js +67 -0
  77. package/package.json +35 -0
  78. package/styles/crud-styles.js +6 -0
  79. package/styles/form-styles.js +24 -0
@@ -0,0 +1,38 @@
1
+ export function deepMerge(target, source) {
2
+ // Definir propiedades que deben sobrescribirse tal cual, sin mergear
3
+ const overwriteProperties = ['responseAdapter', 'requestAdapter'];
4
+
5
+ // Creamos una copia profunda del target
6
+ let result = Array.isArray(target) ? [] : {};
7
+
8
+ // Copiamos las propiedades de target al result
9
+ for (let key in target) {
10
+ if (target.hasOwnProperty(key)) {
11
+ result[key] = Array.isArray(target[key]) ? target[key].slice() : target[key];
12
+ }
13
+ }
14
+
15
+ // Iteramos sobre las propiedades del source
16
+ for (let key in source) {
17
+ if (source.hasOwnProperty(key)) {
18
+ if (overwriteProperties.includes(key)) {
19
+ // Si la propiedad está en overwriteProperties, se sobrescribe tal cual
20
+ result[key] = source[key];
21
+ } else if (Array.isArray(source[key])) {
22
+ // Si la propiedad es un array, sobrescribimos el array en el result
23
+ result[key] = source[key].slice();
24
+ } else if (typeof source[key] === 'object' && source[key] !== null) {
25
+ // Si la propiedad es un objeto, llamamos recursivamente a deepMerge
26
+ if (!result[key] || typeof result[key] !== 'object') {
27
+ result[key] = {};
28
+ }
29
+ result[key] = deepMerge(result[key], source[key]);
30
+ } else {
31
+ // Si no es un objeto ni un array, simplemente copiamos el valor
32
+ result[key] = source[key];
33
+ }
34
+ }
35
+ }
36
+
37
+ return result;
38
+ }
@@ -0,0 +1,67 @@
1
+ import { html } from "lit";
2
+ import { ResponseApiAdapter } from "./ResponseApiAdapter";
3
+ import { RequestApiAdapter } from "./RequestApiAdapter";
4
+
5
+ const templatePlaceholder = (templateName) => `Please provide config.templates.${templateName}`
6
+
7
+ export const defaultConfig = {
8
+ endpoint: '',
9
+ availableFilters: [],
10
+ sort: {
11
+ options: [],
12
+ initialSortField: null,
13
+ },
14
+ pageSize: {
15
+ available: [10, 25, 50],
16
+ initial: 25,
17
+ },
18
+ customization: {
19
+ hideCountSummary: true,
20
+ hidePageReport: false,
21
+ hideCheckboxSelection: true,
22
+ hideEmptyInsertButton: false,
23
+ disableInsert: false,
24
+ disableEdit: false,
25
+ disablePagination: false,
26
+ disableSort: false,
27
+ disableFilter: false,
28
+ disableHelp: true,
29
+ },
30
+ responseAdapter: new ResponseApiAdapter(),
31
+ requestAdapter: new RequestApiAdapter(),
32
+ actions: {
33
+ list: [
34
+ {
35
+ label: 'Delete',
36
+ name: 'DeleteAction'
37
+ }
38
+ ],
39
+ single: [],
40
+ },
41
+ templates: {
42
+ item: () => templatePlaceholder('item'),
43
+ insertForm: (belongsTo, relationId) => templatePlaceholder('insertForm'),
44
+ updateForm: () => templatePlaceholder('updateForm'),
45
+ help: () => templatePlaceholder('help'),
46
+ detail: () => templatePlaceholder('detail'),
47
+ formActions: (actionName) => html`
48
+ <dile-pages attrForSelected="action" selected="${actionName}">
49
+ <dile-crud-delete-action action="DeleteAction"></dile-crud-delete-action>
50
+ </dile-pages>
51
+ `,
52
+ relations: () => '',
53
+ formSingleActions: () => '',
54
+ },
55
+ labels: {
56
+ insertAction: 'Create',
57
+ updateAction: 'Save',
58
+ insertWindowTitle: 'Insert an item',
59
+ updateWindowTitle: 'Update an item',
60
+ helpTitle: 'Help',
61
+ helpButtonLabel: 'Help',
62
+ },
63
+ formIds: {
64
+ insertForm: 'insertform',
65
+ updateForm: 'updateform',
66
+ },
67
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@dile/crud",
3
+ "version": "0.0.9",
4
+ "description": "Components to create a generic crud system based on Web Components and Lit",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Polydile/dile-components.git"
12
+ },
13
+ "keywords": [
14
+ "crud",
15
+ "components",
16
+ "web components",
17
+ "lit",
18
+ "dile components"
19
+ ],
20
+ "author": "Miguel Angel Alvarez",
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/Polydile/dile-components/issues"
24
+ },
25
+ "homepage": "https://dile-components.polydile.com/",
26
+ "dependencies": {
27
+ "@dile/ui": "^2.1.9",
28
+ "axios": "^1.7.2",
29
+ "lit": "^2.7.0 || ^3.0.0"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "gitHead": "9e039f83ab7aeb17be5fe949de18d7c428a34323"
35
+ }
@@ -0,0 +1,6 @@
1
+ import { css } from 'lit';
2
+
3
+ export const crudStyles = css`
4
+
5
+
6
+ `;
@@ -0,0 +1,24 @@
1
+ import { css } from 'lit';
2
+
3
+ export const formStyles = css`
4
+ :host {
5
+ display: block;
6
+ margin-bottom: 1rem;
7
+ --dile-modal-width: 100vw;
8
+ --dile-modal-height: 100vh;
9
+ --dile-modal-close-icon-top: 1rem;
10
+ --dile-modal-close-icon-color: #f66;
11
+ }
12
+ h1 {
13
+ font-size: 1.5rem;
14
+ margin-top: 0;
15
+ }
16
+ @media(min-width: 380px) {
17
+ :host {
18
+ --dile-modal-width: 90vw;
19
+ --dile-modal-height: auto;
20
+ --dile-modal-close-icon-top: 1rem;
21
+ --dile-modal-close-icon-color: #f66;
22
+ }
23
+ }
24
+ `