lupine.components 1.0.24 → 1.0.26

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": "lupine.components",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "license": "MIT",
5
5
  "author": "uuware.com",
6
6
  "homepage": "https://github.com/uuware/lupine.js",
@@ -46,7 +46,7 @@ export class FloatWindow {
46
46
  handleClicked,
47
47
  closeWhenClickOutside = false,
48
48
  zIndex,
49
- contentOverflowY = 'auto',
49
+ contentOverflowY = 'auto', // set to unset for having popup menu inside
50
50
  }: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
51
51
  const onClickContainer = (event: any) => {
52
52
  if (closeWhenClickOutside !== false && event.target.className === 'fwin-box') {
@@ -1,35 +1,56 @@
1
1
  import { RefProps, VNode } from 'lupine.web';
2
2
 
3
3
  export type HtmlVarResult = { value: string | VNode<any>; ref: RefProps; node: VNode<any> };
4
- export const HtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
5
- let _value: string | VNode<any> = initial || '';
6
- let _dirty = false;
7
- const waitUpdate = async (value: string | VNode<any>) => {
8
- if (!ref.current) return;
9
- await ref.mountInnerComponent!(value);
10
- _dirty = false;
11
- };
12
- const ref: RefProps = {
13
- onLoad: async (el: Element) => {
14
- _dirty && waitUpdate(_value);
15
- },
16
- };
17
- return {
18
- set value(value: string | VNode<any>) {
19
- _value = value;
20
- _dirty = true;
21
- waitUpdate(value);
22
- },
23
- get value() {
24
- return ref.current ? ref.current.innerHTML : _value;
25
- },
26
- get ref() {
27
- return ref;
28
- },
29
- get node() {
30
- _dirty = false;
31
- // the Fragment Tag will be present in the html if ref is assigned
32
- return { type: 'Fragment', props: { ref, children: _value }, html: [] };
33
- },
34
- };
4
+
5
+ export class HtmlVar implements HtmlVarResult {
6
+ private _value: string | VNode<any>;
7
+ private _dirty = false;
8
+ private _ref: RefProps;
9
+
10
+ constructor(initial?: string | VNode<any>) {
11
+ this._value = initial || '';
12
+ this._ref = {
13
+ onLoad: async (el: Element) => {
14
+ this._dirty && this.waitUpdate(this._value);
15
+ },
16
+ };
17
+ }
18
+
19
+ private async waitUpdate(value: string | VNode<any>): Promise<void> {
20
+ if (!this._ref.current) return;
21
+ await this._ref.mountInnerComponent!(value);
22
+ this._dirty = false;
23
+ }
24
+
25
+ set value(value: string | VNode<any>) {
26
+ this._value = value;
27
+ this._dirty = true;
28
+ this.waitUpdate(value);
29
+ }
30
+
31
+ get value(): string | VNode<any> {
32
+ return this._ref.current ? this._ref.current.innerHTML : this._value;
33
+ }
34
+
35
+ get ref(): RefProps {
36
+ return this._ref;
37
+ }
38
+
39
+ get node(): VNode<any> {
40
+ this._dirty = false;
41
+ // the Fragment Tag will be present in the html if ref is assigned
42
+ return {
43
+ type: 'Fragment',
44
+ props: {
45
+ ref: this._ref,
46
+ children: this._value
47
+ },
48
+ html: []
49
+ };
50
+ }
51
+ }
52
+
53
+ // For backward compatibility
54
+ export const createHtmlVar = (initial?: string | VNode<any>): HtmlVarResult => {
55
+ return new HtmlVar(initial);
35
56
  };
@@ -1,6 +1,6 @@
1
1
  export * from './icon-menu-item-props';
2
2
  export * from './mobile-footer-menu';
3
- export * from './mobile-frame-with-header';
3
+ export * from './mobile-header-with-back';
4
4
  export * from './mobile-header-component';
5
5
  export * from './mobile-header-title-icon';
6
6
  export * from './mobile-side-menu';
@@ -15,9 +15,9 @@ import { CssProps, HtmlVar, VNode } from 'lupine.components';
15
15
  export class MobileHeaderHelper {
16
16
  private static instance: MobileHeaderHelper;
17
17
 
18
- private leftContent = HtmlVar('');
19
- private centerContent = HtmlVar('');
20
- private rightContent = HtmlVar('');
18
+ private leftContent = new HtmlVar('');
19
+ private centerContent = new HtmlVar('');
20
+ private rightContent = new HtmlVar('');
21
21
  private constructor() {}
22
22
 
23
23
  public static getInstance(): MobileHeaderHelper {
@@ -17,20 +17,14 @@ export const MobileHeaderEmptyIcon = () => {
17
17
  return <div class='mhti-empty-icon' style={{ width: '28px' }}></div>;
18
18
  };
19
19
 
20
- export interface MobileHeaderTitleIconHookProps {
21
- updateTitle?: (title: VNode<any> | string) => void;
22
- updateLeft?: (left: VNode<any>) => void;
23
- updateRight?: (right: VNode<any>) => void;
24
- }
25
20
  export interface MobileHeaderTitleIconProps {
26
- title: VNode<any> | string;
21
+ title: VNode<any> | string | HtmlVar;
27
22
  onBack?: (event: Event) => void;
28
- left?: VNode<any>;
29
- right?: VNode<any>;
30
- hook?: MobileHeaderTitleIconHookProps;
23
+ left?: VNode<any> | HtmlVar;
24
+ right?: VNode<any> | HtmlVar;
31
25
  }
32
26
  // there may have a few MobileHeaderTitleIcon for different pages
33
- export const MobileHeaderTitleIcon = ({ title, onBack, left, right, hook }: MobileHeaderTitleIconProps) => {
27
+ export const MobileHeaderTitleIcon = ({ title, onBack, left, right }: MobileHeaderTitleIconProps) => {
34
28
  // const processBack = (event: Event) => {
35
29
  // if (onBack) {
36
30
  // onBack(event);
@@ -81,20 +75,9 @@ export const MobileHeaderTitleIcon = ({ title, onBack, left, right, hook }: Mobi
81
75
  },
82
76
  };
83
77
 
84
- if (hook) {
85
- hook.updateTitle = (title: VNode<any> | string) => {
86
- domCenter.value = title;
87
- };
88
- hook.updateLeft = (left: VNode<any>) => {
89
- domLeft.value = left;
90
- };
91
- hook.updateRight = (right: VNode<any>) => {
92
- domRight.value = right;
93
- };
94
- }
95
- const domLeft = HtmlVar(left);
96
- const domCenter = HtmlVar(title);
97
- const domRight = HtmlVar(right);
78
+ const domLeft = left instanceof HtmlVar ? left : new HtmlVar(left);
79
+ const domCenter = title instanceof HtmlVar ? title : new HtmlVar(title);
80
+ const domRight = right instanceof HtmlVar ? right : new HtmlVar(right);
98
81
  return (
99
82
  <div css={css} class='mobile-header-title-icon-top'>
100
83
  <div class='mhti-left'>{domLeft.node}</div>
@@ -20,11 +20,6 @@ export const HeaderWithBackFrameEmpty = () => {
20
20
  return <div class='header-back-top-empty'></div>;
21
21
  };
22
22
 
23
- export interface HeaderWithBackFrameHookProps {
24
- updateTitle?: (title: VNode<any> | string) => void;
25
- updateLeft?: (left: VNode<any>) => void;
26
- updateRight?: (right: VNode<any>) => void;
27
- }
28
23
  // there may have a few HeaderWithBackFrame one over another at the same time
29
24
  export const HeaderWithBackFrame = ({
30
25
  children,
@@ -32,15 +27,13 @@ export const HeaderWithBackFrame = ({
32
27
  onBack,
33
28
  left,
34
29
  right,
35
- hook,
36
30
  noHeader = false,
37
31
  }: {
38
32
  children: VNode<any>;
39
- title: VNode<any> | string;
33
+ title: VNode<any> | string | HtmlVar;
40
34
  onBack: (event: Event) => void;
41
- left?: VNode<any>;
42
- right?: VNode<any>;
43
- hook?: HeaderWithBackFrameHookProps;
35
+ left?: VNode<any> | HtmlVar;
36
+ right?: VNode<any> | HtmlVar;
44
37
  noHeader?: boolean;
45
38
  }) => {
46
39
  left = left || <HeaderWithBackFrameLeft onClick={onBack} />;
@@ -94,32 +87,13 @@ export const HeaderWithBackFrame = ({
94
87
  },
95
88
  };
96
89
 
97
- if (hook) {
98
- hook.updateTitle = (title: VNode<any> | string) => {
99
- domCenter.value = title;
100
- };
101
- hook.updateLeft = (left: VNode<any>) => {
102
- domLeft.value = left;
103
- };
104
- hook.updateRight = (right: VNode<any>) => {
105
- domRight.value = right;
106
- };
107
- }
108
- const domLeft = HtmlVar(left);
109
- const domCenter = HtmlVar(title);
110
- const domRight = HtmlVar(right);
90
+ const domLeft = left instanceof HtmlVar ? left : new HtmlVar(left);
91
+ const domCenter = title instanceof HtmlVar ? title : new HtmlVar(title);
92
+ const domRight = right instanceof HtmlVar ? right : new HtmlVar(right);
111
93
  const ref: RefProps = {};
112
94
  return (
113
95
  <div ref={ref} css={css} class='header-back-frame'>
114
- {!noHeader && (
115
- <MobileHeaderTitleIcon
116
- onBack={onBack}
117
- left={domLeft.node}
118
- title={domCenter.node}
119
- right={domRight.node}
120
- hook={hook}
121
- />
122
- )}
96
+ {!noHeader && <MobileHeaderTitleIcon onBack={onBack} left={domLeft} title={domCenter} right={domRight} />}
123
97
  <div class='header-back-content'>{children}</div>
124
98
  </div>
125
99
  );
@@ -13,6 +13,7 @@ export class ModalWindow {
13
13
  handleClicked,
14
14
  closeWhenClickOutside = true,
15
15
  zIndex,
16
+ contentOverflowY,
16
17
  }: FloatWindowShowProps): Promise<FloatWindowCloseProps> {
17
18
  return FloatWindow.show({
18
19
  title,
@@ -26,6 +27,7 @@ export class ModalWindow {
26
27
  handleClicked,
27
28
  closeWhenClickOutside,
28
29
  zIndex,
30
+ contentOverflowY,
29
31
  });
30
32
  }
31
33
  }
@@ -74,8 +74,8 @@ export const Progress = (props: ProgressProps) => {
74
74
  };
75
75
 
76
76
  const ref: RefProps = {};
77
- const domTitle = HtmlVar('Progress');
78
- const dom = HtmlVar('0 %');
77
+ const domTitle = new HtmlVar('Progress');
78
+ const dom = new HtmlVar('0 %');
79
79
  return (
80
80
  <div ref={ref} css={css} class='progress-top d-none'>
81
81
  <div class='progress-box'>
@@ -51,7 +51,7 @@ export const SliderFrame = (props: SliderFrameProps) => {
51
51
  ref.current?.classList.add(className);
52
52
  };
53
53
  }
54
- const dom = HtmlVar(<div class='slider-frame-default'>{props.defaultContent || '(No Content)'}</div>);
54
+ const dom = new HtmlVar(<div class='slider-frame-default'>{props.defaultContent || '(No Content)'}</div>);
55
55
  const ref: RefProps = {};
56
56
  const css: CssProps = {
57
57
  display: 'flex',