native-document 1.0.290 → 1.0.291

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.290",
3
+ "version": "1.0.291",
4
4
  "description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
5
5
  "author": "AfroCodeur <https://github.com/afrocodeur>",
6
6
  "license": "MIT",
@@ -33,10 +33,8 @@ export interface BreadCrumbInterface extends BaseComponent {
33
33
  export declare function BreadCrumb(props?: Record<string, unknown>): BreadCrumbInterface;
34
34
  export declare namespace BreadCrumb {
35
35
 
36
-
37
36
  function use(template: (description: BreadCrumbDescription, instance: BreadCrumbInterface) => ValidChild): void;
38
37
  function preset(name: string, callback: (instance: BreadCrumbInterface) => BreadCrumbInterface): void;
39
38
  function presets(presets: Record<string, (instance: BreadCrumbInterface) => BreadCrumbInterface>): void;
40
39
 
41
-
42
40
  }
@@ -319,3 +319,21 @@ Button.prototype.block = function() {
319
319
  this.$description.block = true;
320
320
  return this;
321
321
  };
322
+
323
+
324
+ // /**
325
+ // * @param {{name: string, params?: *}} route
326
+ // */
327
+ // Button.prototype.linkTo = function(route) {
328
+ // this.$description.linkTo = route;
329
+ // return this;
330
+ // };
331
+ //
332
+ // /**
333
+ // * @param {string} url
334
+ // */
335
+ // Button.prototype.link = function(url, target = null) {
336
+ // this.$description.link = url;
337
+ // this.$description.linkTarget = target;
338
+ // return this;
339
+ // };
@@ -47,6 +47,8 @@ export interface ButtonInterface extends BaseComponent {
47
47
  circle(): this;
48
48
  smooth(): this;
49
49
  block(): this;
50
+ // linkTo(route: {name: string, params?: object}): this;
51
+ // link(url: string, target?: string): this;
50
52
  }
51
53
 
52
54
 
@@ -35,11 +35,11 @@ export default function Field(name, type, props) {
35
35
  type: type,
36
36
  key: name,
37
37
  label: null,
38
- placeholder: null,
38
+ placeholder: props?.placeholder ?? null,
39
39
  help: null,
40
40
  defaultValue: null,
41
- disabled: false,
42
- readonly: false,
41
+ disabled: props?.disabled ?? null,
42
+ readonly: props?.readonly ?? null,
43
43
  rules: [],
44
44
  clearErrorOn: 'focus',
45
45
  validateOn: 'blur',
@@ -205,6 +205,8 @@ export default function Router($options = {}) {
205
205
  $currentState.query = query;
206
206
  $currentState.path = path;
207
207
 
208
+ console.log({ builded: true })
209
+
208
210
  const middlewares = [...route.middlewares(), trigger];
209
211
  let currentIndex = 0;
210
212
  const request = { ...$currentState };
@@ -219,6 +221,10 @@ export default function Router($options = {}) {
219
221
  return middlewares[currentIndex](request, next);
220
222
  };
221
223
 
224
+ this.currentRouteName = function() {
225
+ return $currentState.route.name();
226
+ }
227
+
222
228
  }
223
229
 
224
230
  Router.routers = {};
@@ -267,6 +273,10 @@ Router.create = function(options, callback) {
267
273
  return router;
268
274
  };
269
275
 
276
+ Router.currentRouteName = function(name = null) {
277
+ return Router.get(name).currentRouteName();
278
+ };
279
+
270
280
  Router.get = function(name) {
271
281
  const router = Router.routers[name || DEFAULT_ROUTER_NAME];
272
282
  if(!router) {
@@ -275,6 +285,10 @@ Router.get = function(name) {
275
285
  return router;
276
286
  };
277
287
 
288
+ Router.currentRoute = function(name = null) {
289
+ return Router.get(name).currentState().route;
290
+ }
291
+
278
292
  Router.push = function(target, name = null) {
279
293
  return Router.get(name).push(target);
280
294
  };
@@ -1,5 +1,6 @@
1
1
  import {Button as NativeButton, ShowIf, Span} from '../../../core/elements';
2
2
  import {Spinner} from '../../../components/spinner';
3
+ import {Router} from '../../../../router';
3
4
 
4
5
  import './button.css';
5
6
 
@@ -32,7 +33,7 @@ export default function ButtonRender($desc, instance) {
32
33
 
33
34
  const content = buildContent($desc);
34
35
 
35
- return NativeButton({
36
+ const button = NativeButton({
36
37
  ...instance.resolveProps(),
37
38
  type: $desc.type || 'button',
38
39
  disabled: $desc.disabled,
@@ -40,6 +41,8 @@ export default function ButtonRender($desc, instance) {
40
41
  ...($desc.loading ? { 'aria-busy': $desc.loading } : {}),
41
42
  ...($desc.disabled ? { 'aria-disabled': $desc.disabled } : {}),
42
43
  }, content);
44
+
45
+ return button;
43
46
  }
44
47
 
45
48
  function buildContent($desc) {
@@ -35,7 +35,6 @@
35
35
  border-radius: var(--dropdown-radius);
36
36
  box-shadow: var(--dropdown-shadow);
37
37
  min-width: var(--dropdown-min-width);
38
- max-width: var(--dropdown-max-width);
39
38
  font-size: var(--dropdown-font-size);
40
39
  box-sizing: border-box;
41
40
  margin: 0;
@@ -47,6 +46,10 @@
47
46
  animation: dropdown-in var(--dropdown-animation-duration) ease forwards;
48
47
  }
49
48
 
49
+ &.has-max-width {
50
+ max-width: var(--dropdown-max-width);
51
+ }
52
+
50
53
  &.has-max-height {
51
54
  overflow-y: auto;
52
55
  }
@@ -41,9 +41,12 @@ export default function PopoverRender($desc, instance, classPrefix = 'popover')
41
41
  const $x = Observable(10).intercept(toUnit);
42
42
  const $y = Observable(0).intercept(toUnit);
43
43
 
44
- const popoverArrow = $desc.arrow ? Span({class: classPrefix+'-arrow'}) : null;
44
+ const popoverArrow = $desc.arrow ? Span({class: classPrefix+'-arrow popover-arrow'}) : null;
45
45
 
46
- editableProps.class.add(classPrefix);
46
+ editableProps.class.add('popover');
47
+ if(classPrefix !== 'popover') {
48
+ editableProps.class.add(classPrefix);
49
+ }
47
50
  editableProps.class.add('is-'+$desc.variant);
48
51
  editableProps.style.add({left: $x, top: $y});
49
52
 
@@ -62,12 +65,23 @@ export default function PopoverRender($desc, instance, classPrefix = 'popover')
62
65
 
63
66
  let position;
64
67
  const isSupportsPopover = supportsPopover();
68
+
69
+ let targetElement = trigger;
70
+ if($desc.matchTargetWidth) {
71
+ if($desc.matchTargetWidth.$element) {
72
+ targetElement = $desc.matchTargetWidth.$element;
73
+ }
74
+ else if($desc.matchTargetWidth.tagName) {
75
+ targetElement = $desc.matchTargetWidth;
76
+ }
77
+ }
78
+
65
79
  const updatePosition = (state) => {
66
80
  if(!state) {
67
81
  return;
68
82
  }
69
83
 
70
- let targetElement = trigger;
84
+ targetElement = trigger;
71
85
  if($desc.matchTargetWidth) {
72
86
  if($desc.matchTargetWidth.$element) {
73
87
  targetElement = $desc.matchTargetWidth.$element;
@@ -111,16 +125,17 @@ export default function PopoverRender($desc, instance, classPrefix = 'popover')
111
125
  }
112
126
 
113
127
  const arrowData = middlewareData.arrow;
128
+ const side = placement.split('-')[0];
114
129
  const staticSide = {
115
130
  top: 'bottom',
116
131
  right: 'left',
117
132
  bottom: 'top',
118
133
  left: 'right',
119
- }[placement.split('-')[0]];
134
+ }[side];
120
135
 
121
136
  Object.assign(popoverArrow.style, {
122
- left: arrowData.x != null ? arrowData.x + 'px' : '',
123
- top: arrowData.y != null ? arrowData.y + 'px' : '',
137
+ left: arrowData.x != null ? 'calc('+arrowData.x + 'px - var(--popover-left-offset))' : '',
138
+ top: arrowData.y != null ? 'calc('+arrowData.y + 'px - var(--popover-top-offset))' : '',
124
139
  [staticSide]: '-4px',
125
140
  });
126
141
 
@@ -148,7 +163,7 @@ export default function PopoverRender($desc, instance, classPrefix = 'popover')
148
163
 
149
164
  const observer = new ResizeObserver(updatePositionHandler);
150
165
 
151
- observer.observe(trigger);
166
+ observer.observe(targetElement);
152
167
  window.addEventListener('resize', updatePositionHandler);
153
168
  window.addEventListener('scroll', updatePositionHandler);
154
169
 
@@ -1,5 +1,6 @@
1
1
  :root {
2
2
  --popover-bg: var(--background);
3
+ --popover-color: var(--text-color, black);
3
4
  --popover-border: var(--gray-lite-3);
4
5
  --popover-radius: var(--radius-card);
5
6
  --popover-shadow: var(--shadow-lg);
@@ -12,6 +13,21 @@
12
13
  --popover-header-weight: 600;
13
14
  --popover-arrow-size: 8px;
14
15
  --popover-animation-duration: 0.15s;
16
+
17
+ --popover-left-offset: 0;
18
+ --popover-top-offset: 0;
19
+ }
20
+
21
+
22
+ .popover-arrow {
23
+ position: absolute;
24
+ width: var(--popover-arrow-size);
25
+ height: var(--popover-arrow-size);
26
+ background: var(--popover-bg);
27
+ color: var(--popover-color);
28
+ transform: rotate(45deg);
29
+ pointer-events: none;
30
+ z-index: -1;
15
31
  }
16
32
 
17
33
  .popover {
@@ -68,37 +68,6 @@
68
68
  width: var(--tooltip-arrow-size);
69
69
  height: var(--tooltip-arrow-size);
70
70
  background: var(--tooltip-bg);
71
- transform: rotate(45deg);
72
- pointer-events: none;
73
- z-index: -1;
74
- }
75
-
76
- .tooltip[data-placement^='top'] {
77
- .tooltip-arrow {
78
- border-top: none;
79
- border-left: none;
80
- }
81
- }
82
-
83
- .tooltip[data-placement^='bottom'] {
84
- .tooltip-arrow {
85
- border-bottom: none;
86
- border-right: none;
87
- }
88
- }
89
-
90
- .tooltip[data-placement^='left'] {
91
- .tooltip-arrow {
92
- border-left: none;
93
- border-bottom: none;
94
- }
95
- }
96
-
97
- .tooltip[data-placement^='right'] {
98
- .tooltip-arrow {
99
- border-right: none;
100
- border-top: none;
101
- }
102
71
  }
103
72
 
104
73
  @keyframes tooltip-in {