native-document 1.0.69 → 1.0.72

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 (131) hide show
  1. package/.npmrc.example +0 -0
  2. package/components.js +2 -0
  3. package/dist/native-document.components.min.js +5636 -0
  4. package/dist/native-document.dev.js +384 -323
  5. package/dist/native-document.dev.js.map +1 -1
  6. package/dist/native-document.devtools.min.js +1 -1
  7. package/dist/native-document.min.js +1 -1
  8. package/elements.js +3 -3
  9. package/hrm.js +0 -0
  10. package/index.js +17 -17
  11. package/package.json +1 -1
  12. package/rollup.config.js +17 -1
  13. package/src/components/fom-control/FormControl.js +247 -0
  14. package/src/components/fom-control/default/DefaultLayout.js +8 -0
  15. package/src/components/fom-control/default/collection/DefaultCollectionLayout.js +12 -0
  16. package/src/components/fom-control/default/collection/DefaultCollectionTemplate.js +6 -0
  17. package/src/components/fom-control/field/DefaultRender.js +91 -0
  18. package/src/components/fom-control/field/Field.js +396 -0
  19. package/src/components/fom-control/field/FieldCollection.js +260 -0
  20. package/src/components/fom-control/field/FieldFactory.js +107 -0
  21. package/src/components/fom-control/field/types/AutocompleteField.js +46 -0
  22. package/src/components/fom-control/field/types/CheckboxField.js +17 -0
  23. package/src/components/fom-control/field/types/CheckboxGroupField.js +78 -0
  24. package/src/components/fom-control/field/types/ColorField.js +39 -0
  25. package/src/components/fom-control/field/types/DateField.js +62 -0
  26. package/src/components/fom-control/field/types/EmailField.js +44 -0
  27. package/src/components/fom-control/field/types/FileField.js +66 -0
  28. package/src/components/fom-control/field/types/HiddenField.js +8 -0
  29. package/src/components/fom-control/field/types/ImageField.js +49 -0
  30. package/src/components/fom-control/field/types/NumberField.js +74 -0
  31. package/src/components/fom-control/field/types/PasswordField.js +72 -0
  32. package/src/components/fom-control/field/types/RadioField.js +44 -0
  33. package/src/components/fom-control/field/types/RangeField.js +17 -0
  34. package/src/components/fom-control/field/types/SearchField.js +17 -0
  35. package/src/components/fom-control/field/types/SelectField.js +41 -0
  36. package/src/components/fom-control/field/types/StringField.js +49 -0
  37. package/src/components/fom-control/field/types/TelField.js +38 -0
  38. package/src/components/fom-control/field/types/TextAreaField.js +56 -0
  39. package/src/components/fom-control/field/types/TimeField.js +45 -0
  40. package/src/components/fom-control/field/types/UrlField.js +53 -0
  41. package/src/components/fom-control/index.js +8 -0
  42. package/src/components/fom-control/merge +0 -0
  43. package/src/components/fom-control/utils.js +17 -0
  44. package/src/components/fom-control/validation/Validation.js +556 -0
  45. package/src/components/table/Column.js +106 -0
  46. package/src/components/table/ColumnGroup.js +54 -0
  47. package/src/components/table/DataTable.js +195 -0
  48. package/src/components/table/SimpleTable.js +184 -0
  49. package/src/components/table/index.js +9 -0
  50. package/src/{data → core/data}/ObservableArray.js +2 -0
  51. package/src/{data → core/data}/ObservableItem.js +49 -3
  52. package/src/{data → core/data}/ObservableWhen.js +0 -0
  53. package/src/{data → core/data}/observable-helpers/computed.js +2 -1
  54. package/src/{elements → core/elements}/anchor.js +32 -32
  55. package/src/{elements → core/elements}/control/for-each-array.js +4 -2
  56. package/src/{elements → core/elements}/control/show-when.js +0 -0
  57. package/src/core/utils/EventEmitter.js +46 -0
  58. package/src/{utils → core/utils}/filters/date.js +2 -0
  59. package/src/{utils → core/utils}/filters/index.js +0 -0
  60. package/src/{utils → core/utils}/filters/standard.js +1 -1
  61. package/src/{utils → core/utils}/filters/strings.js +0 -0
  62. package/src/{utils → core/utils}/filters/utils.js +0 -0
  63. package/src/{utils → core/utils}/helpers.js +12 -0
  64. package/src/{utils → core/utils}/memoize.js +0 -0
  65. package/src/{utils → core/utils}/service.js +0 -0
  66. package/src/{utils → core/utils}/validator.js +7 -0
  67. package/src/{wrappers → core/wrappers}/ElementCreator.js +10 -33
  68. package/src/{wrappers → core/wrappers}/NDElement.js +0 -127
  69. package/src/core/wrappers/NdPrototype.js +147 -0
  70. package/src/core/wrappers/TemplateBinding.js +7 -0
  71. package/src/{wrappers → core/wrappers}/TemplateCloner.js +5 -6
  72. package/src/core/wrappers/prototype-extensions.js +56 -0
  73. package/src/devtools/hrm/ComponentRegistry.js +1 -1
  74. package/src/devtools/hrm/hrm.hook.template.js +0 -0
  75. package/src/devtools/hrm/hrm.orbservable.hook.template.js +0 -0
  76. package/src/devtools/hrm/nd-vite-hot-reload.js +0 -0
  77. package/src/devtools/hrm/transformComponent.js +0 -0
  78. package/src/router/Route.js +1 -1
  79. package/src/router/RouteGroupHelper.js +1 -1
  80. package/src/router/Router.js +4 -4
  81. package/src/router/RouterComponent.js +13 -2
  82. package/src/router/link.js +2 -2
  83. package/src/router/modes/HistoryRouter.js +2 -2
  84. package/types/filters/dates.d.ts +43 -0
  85. package/types/filters/standard.d.ts +71 -0
  86. package/types/filters/strings.d.ts +21 -0
  87. package/types/filters/types.d.ts +20 -0
  88. package/types/forms.d.ts +2 -1
  89. package/types/memoize.d.ts +0 -0
  90. package/types/native-fetch.d.ts +0 -0
  91. package/types/observable.d.ts +6 -0
  92. package/types/service.d.ts +0 -0
  93. package/types/validator.ts +2 -1
  94. package/utils.js +3 -3
  95. package/src/wrappers/NdPrototype.js +0 -71
  96. /package/src/{data → core/data}/MemoryManager.js +0 -0
  97. /package/src/{data → core/data}/Observable.js +0 -0
  98. /package/src/{data → core/data}/ObservableChecker.js +0 -0
  99. /package/src/{data → core/data}/Store.js +0 -0
  100. /package/src/{data → core/data}/observable-helpers/array.js +0 -0
  101. /package/src/{data → core/data}/observable-helpers/batch.js +0 -0
  102. /package/src/{data → core/data}/observable-helpers/object.js +0 -0
  103. /package/src/{elements → core/elements}/content-formatter.js +0 -0
  104. /package/src/{elements → core/elements}/control/for-each.js +0 -0
  105. /package/src/{elements → core/elements}/control/show-if.js +0 -0
  106. /package/src/{elements → core/elements}/control/switch.js +0 -0
  107. /package/src/{elements → core/elements}/description-list.js +0 -0
  108. /package/src/{elements → core/elements}/form.js +0 -0
  109. /package/src/{elements → core/elements}/html5-semantics.js +0 -0
  110. /package/src/{elements → core/elements}/img.js +0 -0
  111. /package/src/{elements → core/elements}/index.js +0 -0
  112. /package/src/{elements → core/elements}/interactive.js +0 -0
  113. /package/src/{elements → core/elements}/list.js +0 -0
  114. /package/src/{elements → core/elements}/medias.js +0 -0
  115. /package/src/{elements → core/elements}/meta-data.js +0 -0
  116. /package/src/{elements → core/elements}/table.js +0 -0
  117. /package/src/{errors → core/errors}/ArgTypesError.js +0 -0
  118. /package/src/{errors → core/errors}/NativeDocumentError.js +0 -0
  119. /package/src/{errors → core/errors}/RouterError.js +0 -0
  120. /package/src/{utils → core/utils}/args-types.js +0 -0
  121. /package/src/{utils → core/utils}/debug-manager.js +0 -0
  122. /package/src/{utils → core/utils}/events.js +0 -0
  123. /package/src/{utils → core/utils}/plugins-manager.js +0 -0
  124. /package/src/{utils → core/utils}/property-accumulator.js +0 -0
  125. /package/src/{utils → core/utils}/prototypes.js +0 -0
  126. /package/src/{wrappers → core/wrappers}/AttributesWrapper.js +0 -0
  127. /package/src/{wrappers → core/wrappers}/DocumentObserver.js +0 -0
  128. /package/src/{wrappers → core/wrappers}/HtmlElementWrapper.js +0 -0
  129. /package/src/{wrappers → core/wrappers}/SingletonView.js +0 -0
  130. /package/src/{wrappers → core/wrappers}/constants.js +0 -0
  131. /package/src/{utils/fetch → fetch}/NativeFetch.js +0 -0
@@ -0,0 +1,44 @@
1
+ import Field from "../Field";
2
+
3
+ export default function RadioField(name, options, defaultConfig) {
4
+ Field.call(this, name, 'radio', defaultConfig);
5
+
6
+ Object.assign(this.$description, {
7
+ options: options || [],
8
+ layout: 'vertical'
9
+ });
10
+ }
11
+
12
+ RadioField.prototype = Object.create(Field.prototype);
13
+ RadioField.prototype.constructor = RadioField;
14
+
15
+ RadioField.prototype.options = function(opts) {
16
+ this.$description.options = opts;
17
+ return this;
18
+ };
19
+
20
+ RadioField.prototype.layout = function(value) {
21
+ const allowedLayouts = ['vertical', 'horizontal', 'grid'];
22
+
23
+ if (!allowedLayouts.includes(value)) {
24
+ throw new Error(`Invalid layout "${value}". Must be one of: ${allowedLayouts.join(', ')}`);
25
+ }
26
+
27
+ this.$description.layout = value;
28
+ return this;
29
+ };
30
+
31
+ RadioField.prototype.horizontal = function() {
32
+ this.$description.layout = 'horizontal';
33
+ return this;
34
+ };
35
+
36
+ RadioField.prototype.vertical = function() {
37
+ this.$description.layout = 'vertical';
38
+ return this;
39
+ };
40
+
41
+ RadioField.prototype.grid = function() {
42
+ this.$description.layout = 'grid';
43
+ return this;
44
+ };
@@ -0,0 +1,17 @@
1
+ import NumberField from "./NumberField";
2
+
3
+ export default function RangeField(name, defaultConfig) {
4
+ NumberField.call(this, name, 'range', defaultConfig);
5
+
6
+ Object.assign(this.$description, {
7
+ showValue: true
8
+ });
9
+ }
10
+
11
+ RangeField.prototype = Object.create(NumberField.prototype);
12
+ RangeField.prototype.constructor = RangeField;
13
+
14
+ RangeField.prototype.showValue = function(enabled = true) {
15
+ this.$description.showValue = enabled;
16
+ return this;
17
+ };
@@ -0,0 +1,17 @@
1
+ import StringField from "./StringField";
2
+
3
+ export default function SearchField(name, defaultConfig) {
4
+ StringField.call(this, name, 'search', defaultConfig);
5
+
6
+ Object.assign(this.$description, {
7
+ debounce: 300
8
+ });
9
+ }
10
+
11
+ SearchField.prototype = Object.create(StringField.prototype);
12
+ SearchField.prototype.constructor = SearchField;
13
+
14
+ SearchField.prototype.debounce = function(ms) {
15
+ this.$description.debounce = ms;
16
+ return this;
17
+ };
@@ -0,0 +1,41 @@
1
+ import Field from "../Field";
2
+
3
+ export default function SelectField(name, options, defaultConfig) {
4
+ Field.call(this, name, 'select', defaultConfig);
5
+
6
+ Object.assign(this.$description, {
7
+ options: options || [],
8
+ multiple: false,
9
+ searchable: false,
10
+ clearable: false,
11
+ groups: null
12
+ });
13
+ }
14
+
15
+ SelectField.prototype = Object.create(Field.prototype);
16
+ SelectField.prototype.constructor = SelectField;
17
+
18
+ SelectField.prototype.options = function(opts) {
19
+ this.$description.options = opts;
20
+ return this;
21
+ };
22
+
23
+ SelectField.prototype.multiple = function(enabled = true) {
24
+ this.$description.multiple = enabled;
25
+ return this;
26
+ };
27
+
28
+ SelectField.prototype.searchable = function(enabled = true) {
29
+ this.$description.searchable = enabled;
30
+ return this;
31
+ };
32
+
33
+ SelectField.prototype.clearable = function(enabled = true) {
34
+ this.$description.clearable = enabled;
35
+ return this;
36
+ };
37
+
38
+ SelectField.prototype.groups = function(groupsConfig) {
39
+ this.$description.groups = groupsConfig;
40
+ return this;
41
+ };
@@ -0,0 +1,49 @@
1
+ import Field from "../Field";
2
+ import {Validation} from "../../validation/Validation";
3
+
4
+ export default function StringField(name, type = 'text', defaultConfig = {}) {
5
+ Field.call(this, name, type, defaultConfig);
6
+ }
7
+
8
+ StringField.prototype = Object.create(Field.prototype);
9
+ StringField.prototype.constructor = StringField;
10
+
11
+ StringField.prototype.minLength = function(min, message) {
12
+ return this.addRule(Validation.minLength, [min], message);
13
+ };
14
+
15
+ StringField.prototype.maxLength = function(max, message) {
16
+ return this.addRule(Validation.maxLength, [max], message);
17
+ };
18
+
19
+ StringField.prototype.length = function(length, message) {
20
+ return this.addRule(Validation.length, [length], message);
21
+ };
22
+
23
+ StringField.prototype.pattern = function(regex, message) {
24
+ return this.addRule(Validation.pattern, [regex], message);
25
+ };
26
+
27
+ StringField.prototype.alphaOnly = function(message) {
28
+ return this.addRule(Validation.alphaOnly, [], message);
29
+ };
30
+
31
+ StringField.prototype.numericOnly = function(message) {
32
+ return this.addRule(Validation.numericOnly, [], message);
33
+ };
34
+
35
+ StringField.prototype.alphaNumeric = function(message) {
36
+ return this.addRule(Validation.alphaNumeric, [], message);
37
+ };
38
+
39
+ StringField.prototype.noSpaces = function(message) {
40
+ return this.addRule(Validation.noSpaces, [], message);
41
+ };
42
+
43
+ StringField.prototype.lowercase = function(message) {
44
+ return this.addRule(Validation.lowercase, [], message);
45
+ };
46
+
47
+ StringField.prototype.uppercase = function(message) {
48
+ return this.addRule(Validation.uppercase, [], message);
49
+ };
@@ -0,0 +1,38 @@
1
+ // TelField.js
2
+ import StringField from "./StringField";
3
+ import {Validation} from "../../validation/Validation";
4
+
5
+ export default function TelField(name, defaultConfig) {
6
+ StringField.call(this, name, 'tel', defaultConfig);
7
+
8
+ Object.assign(this.$description, {
9
+ countryCode: false,
10
+ mask: null
11
+ });
12
+ }
13
+
14
+ TelField.prototype = Object.create(StringField.prototype);
15
+ TelField.prototype.constructor = TelField;
16
+
17
+ TelField.prototype.phone = function(message) {
18
+ return this.addRule(Validation.phone, [], message);
19
+ };
20
+
21
+ TelField.prototype.countryCode = function(enabled = true) {
22
+ this.$description.countryCode = enabled;
23
+ return this;
24
+ };
25
+
26
+ TelField.prototype.mask = function(pattern) {
27
+ this.$description.mask = pattern;
28
+
29
+ const regex = pattern
30
+ .replace(/[().\-\s+]/g, '\\$&')
31
+ .replace(/#/g, '\\d');
32
+
33
+ this.addRule(Validation.pattern, [new RegExp(`^${regex}$`)],
34
+ `Invalid phone format. Expected: ${pattern}`
35
+ );
36
+
37
+ return this;
38
+ };
@@ -0,0 +1,56 @@
1
+ import StringField from "./StringField";
2
+
3
+ export default function TextAreaField(name, defaultConfig) {
4
+ StringField.call(this, name, 'textarea', defaultConfig);
5
+
6
+ Object.assign(this.$description, {
7
+ ...this.$description,
8
+ rows: 4,
9
+ cols: null,
10
+ resize: 'vertical',
11
+ autoGrow: false,
12
+ characterCounter: false,
13
+ });
14
+ }
15
+
16
+ TextAreaField.prototype = Object.create(StringField.prototype);
17
+ TextAreaField.prototype.constructor = TextAreaField;
18
+
19
+ TextAreaField.prototype.rows = function(value) {
20
+ this.$description.rows = value;
21
+ return this;
22
+ };
23
+
24
+ TextAreaField.prototype.cols = function(value) {
25
+ this.$description.cols = value;
26
+ return this;
27
+ };
28
+
29
+ TextAreaField.prototype.resize = function(value) {
30
+ this.$description.resize = value;
31
+ return this;
32
+ };
33
+
34
+ TextAreaField.prototype.autoGrow = function(enabled = true) {
35
+ this.$description.autoGrow = enabled;
36
+ return this;
37
+ };
38
+
39
+ TextAreaField.prototype.characterCounter = function(enabled = true) {
40
+ this.$description.characterCounter = enabled;
41
+ return this;
42
+ };
43
+
44
+ TextAreaField.prototype.wordCount = function(min, max, message) {
45
+ this.$description.rules.push({
46
+ validate: (value) => {
47
+ if (!value) return true;
48
+ const words = value.trim().split(/\s+/).length;
49
+ if (min && words < min) return false;
50
+ if (max && words > max) return false;
51
+ return true;
52
+ },
53
+ message: message || `Word count must be between ${min || 0} and ${max || '∞'}`
54
+ });
55
+ return this;
56
+ };
@@ -0,0 +1,45 @@
1
+ // TimeField.js
2
+ import Field from "../Field";
3
+ import {Validation} from "../../validation/Validation";
4
+
5
+ export default function TimeField(name, defaultConfig) {
6
+ Field.call(this, name, 'time', defaultConfig);
7
+
8
+ Object.assign(this.$description, {
9
+ format: 'HH:mm',
10
+ step: null
11
+ });
12
+ }
13
+
14
+ TimeField.prototype = Object.create(Field.prototype);
15
+ TimeField.prototype.constructor = TimeField;
16
+
17
+ TimeField.prototype.format = function(formatString) {
18
+ this.$description.format = formatString;
19
+ return this;
20
+ };
21
+
22
+ TimeField.prototype.step = function(seconds) {
23
+ this.$description.step = seconds;
24
+ return this;
25
+ };
26
+
27
+ TimeField.prototype.min = function(time, message) {
28
+ return this.addRule(Validation.afterTime, [time], message);
29
+ };
30
+
31
+ TimeField.prototype.max = function(time, message) {
32
+ return this.addRule(Validation.beforeTime, [time], message);
33
+ };
34
+
35
+ TimeField.prototype.between = function(startTime, endTime, message) {
36
+ return this.addRule(Validation.betweenTimes, [startTime, endTime], message);
37
+ };
38
+
39
+ TimeField.prototype.after = function(time, message) {
40
+ return this.addRule(Validation.afterTime, [time], message);
41
+ };
42
+
43
+ TimeField.prototype.before = function(time, message) {
44
+ return this.addRule(Validation.beforeTime, [time], message);
45
+ };
@@ -0,0 +1,53 @@
1
+ // UrlField.js
2
+ import StringField from "./StringField";
3
+ import {Validation} from "../../validation/Validation";
4
+
5
+ export default function UrlField(name, defaultConfig) {
6
+ StringField.call(this, name, 'url', defaultConfig);
7
+
8
+ // Auto-apply url validation
9
+ this.addRule(Validation.url, []);
10
+ }
11
+
12
+ UrlField.prototype = Object.create(StringField.prototype);
13
+ UrlField.prototype.constructor = UrlField;
14
+
15
+ UrlField.prototype.url = function(message) {
16
+ const existingRule = this.$description.rules.find(r => r.fn === Validation.url);
17
+ if (existingRule && message) {
18
+ existingRule.message = message;
19
+ }
20
+ return this;
21
+ };
22
+
23
+ UrlField.prototype.protocol = function(allowedProtocols, message) {
24
+ this.$description.rules.push({
25
+ validate: (value) => {
26
+ if (!value) return true;
27
+ try {
28
+ const url = new URL(value);
29
+ return allowedProtocols.includes(url.protocol.replace(':', ''));
30
+ } catch {
31
+ return false;
32
+ }
33
+ },
34
+ message: message || `Allowed protocols: ${allowedProtocols.join(', ')}`
35
+ });
36
+ return this;
37
+ };
38
+
39
+ UrlField.prototype.domain = function(allowedDomains, message) {
40
+ this.$description.rules.push({
41
+ validate: (value) => {
42
+ if (!value) return true;
43
+ try {
44
+ const url = new URL(value);
45
+ return allowedDomains.includes(url.hostname);
46
+ } catch {
47
+ return false;
48
+ }
49
+ },
50
+ message: message || `Allowed domains: ${allowedDomains.join(', ')}`
51
+ });
52
+ return this;
53
+ };
@@ -0,0 +1,8 @@
1
+ import Field from "./field/Field";
2
+ import FormControl from "./FormControl";
3
+ import './field/FieldFactory';
4
+
5
+ export {
6
+ Field,
7
+ FormControl,
8
+ }
File without changes
@@ -0,0 +1,17 @@
1
+
2
+ export function resolveParams(rule, values) {
3
+ return rule.params ?rule.params.map(param => {
4
+ if (typeof param === 'string') {
5
+ if(values.$parent && param.startsWith('@')) {
6
+ const paramName = param.substring(1);
7
+ if(values.$parent[paramName] !== undefined) {
8
+ return values.$parent[paramName];
9
+ }
10
+ }
11
+ if(values[param] !== undefined) {
12
+ return values[param];
13
+ }
14
+ }
15
+ return param;
16
+ }): [];
17
+ }