lupine.web 1.0.15 → 1.0.16

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # lupine.web
2
2
 
3
- LupineJs is a React-like, extremely fast, small size and lightweight frontend framework.
3
+ lupine.web is a React-like, extremely fast, small size and lightweight frontend framework.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lupine.web",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "license": "MIT",
5
5
  "author": "uuware.com",
6
6
  "homepage": "https://uuware.com/",
@@ -1,6 +1,6 @@
1
1
  import { getRenderPageProps } from '../core';
2
2
  import { RefProps } from '../jsx';
3
- import { MediaQueryMaxWidth } from '../types';
3
+ import { MediaQueryMaxWidth } from '../styles';
4
4
  import { LinkItem } from './link-item';
5
5
  import { NestMenuItemProps } from './menu-item-props';
6
6
 
@@ -1,7 +1,7 @@
1
1
  import { bindGlobalStyles, getRenderPageProps } from '../core';
2
2
  import { CssProps, RefProps } from '../jsx';
3
3
  import { stopPropagation } from '../lib';
4
- import { MediaQueryMaxWidth } from '../types';
4
+ import { MediaQueryMaxWidth } from '../styles';
5
5
  import { NestMenuItemProps } from './menu-item-props';
6
6
 
7
7
  const fetchMenu = async (menuId: string) => {
@@ -1,6 +1,5 @@
1
1
  // import { bindPageResetEvent } from '../core/page-reset-events';
2
- import { getMetaDescription } from './meta-description';
3
-
2
+ import { addMetaDataTags } from '../core/bind-meta';
4
3
  type NameMeta = { name: string; content: string };
5
4
  type PropertyMeta = { property: string; content: string };
6
5
  type HttpEquivMeta = { httpEquiv: string; content: string };
@@ -16,39 +15,22 @@ function isHttpEquivMeta(data: any): data is HttpEquivMeta {
16
15
  return !!(data.httpEquiv && data.content);
17
16
  }
18
17
 
19
- let _metaData: { [key: string]: string } = {};
20
- // Shouldn't include <meta name="description" content="...">
18
+ // should use description tag instead of meta tag ( <meta name="description" content="..."> )
21
19
  export const MetaData = (data: AllMeta) => {
22
20
  if (isNameMeta(data)) {
23
- _metaData[`name:${data.name}`] = `<meta name="${data.name}" content="${data.content}">`;
21
+ addMetaDataTags(`name:${data.name}`, `<meta name="${data.name}" content="${data.content}">`);
24
22
  } else if (isPropertyMeta(data)) {
25
- _metaData[`property:${data.property}`] = `<meta property="${data.property}" content="${data.content}">`;
23
+ addMetaDataTags(`property:${data.property}`, `<meta property="${data.property}" content="${data.content}">`);
26
24
  } else if (isHttpEquivMeta(data)) {
27
- _metaData[`http-equiv:${data.httpEquiv}`] = `<meta http-equiv="${data.httpEquiv}" content="${data.content}">`;
25
+ addMetaDataTags(`http-equiv:${data.httpEquiv}`, `<meta http-equiv="${data.httpEquiv}" content="${data.content}">`);
28
26
  } else if ((data as any).key && (data as any).string) {
29
- _metaData[`${(data as any).key}`] = `${(data as any).string}`;
27
+ addMetaDataTags(`${(data as any).key}`, `${(data as any).string}`);
30
28
  } else {
31
29
  console.warn('Unknown meta data:', data);
32
30
  }
33
31
  return <></>;
34
32
  };
35
33
 
36
- export const getMetaDataTags = () => {
37
- return Object.values(getMetaDataObject()).join('\n');
38
- };
39
-
40
- export const getMetaDataObject = () => {
41
- const metaDescription = getMetaDescription();
42
- return metaDescription
43
- ? Object.assign(
44
- {
45
- 'name:description': `<meta name="description" content="${metaDescription}">`,
46
- },
47
- _metaData
48
- )
49
- : _metaData;
50
- };
51
-
52
34
  // bindPageResetEvent(() => {
53
35
  // _metaData = {};
54
36
  // });
@@ -1,19 +1,12 @@
1
1
  // import { bindPageResetEvent } from '../core/page-reset-events';
2
2
 
3
- let _description = { value: '', defaultValue: '' };
3
+ import { addMetaDataTags } from "../core/bind-meta";
4
+
4
5
  export const MetaDescription = ({ children }: { children: string }) => {
5
- _description.value = children;
6
+ addMetaDataTags('name:description', `<meta name="description" content="${children}">`);
6
7
  return <></>;
7
8
  };
8
9
 
9
- export const getMetaDescription = () => {
10
- return _description.value || _description.defaultValue;
11
- };
12
-
13
- export const setDefaultMetaDescription = (children: string) => {
14
- _description.defaultValue = children;
15
- };
16
-
17
10
  // bindPageResetEvent(() => {
18
11
  // _description.value = '';
19
12
  // });
@@ -0,0 +1,6 @@
1
+ import { setPageTitle } from "../core/bind-meta";
2
+
3
+ export const PageTitle = ({ children }: { children: string }) => {
4
+ setPageTitle(children);
5
+ return <></>;
6
+ };
@@ -1,10 +1,8 @@
1
- import { CssProps, JSXInternal } from '../jsx';
2
- import { ContentPosition, Position } from '../types';
1
+ import { CssProps } from '../jsx';
3
2
 
4
3
  export type PanelProps = {
5
4
  children: any;
6
5
  className?: string;
7
- contentPosition?: ContentPosition;
8
6
  css?: CssProps;
9
7
  };
10
8
 
@@ -12,7 +10,6 @@ export const Panel = ({ children, className, css }: PanelProps) => {
12
10
  const newCss: CssProps = {
13
11
  display: 'flex',
14
12
  flexDirection: 'column',
15
- // justifyContent: ContentPosition.center,
16
13
  ...css,
17
14
  };
18
15
 
@@ -1,4 +1,4 @@
1
- import { mountComponents, mountSelfComponents } from '../core';
1
+ import { mountComponents } from '../core';
2
2
  import { RefProps, VNode } from '../jsx';
3
3
  import { stopPropagation } from '../lib';
4
4
 
@@ -1,11 +1,9 @@
1
1
  import { bindGlobalStyles, getCurrentTheme, updateTheme } from '../core';
2
2
  import { CssProps } from '../jsx';
3
- import { ContentPosition } from '../types';
4
3
  import { PopupMenu } from './popup-menu';
5
4
 
6
5
  export type ThemeSelectorProps = {
7
6
  className?: string;
8
- contentPosition?: ContentPosition;
9
7
  css?: CssProps;
10
8
  };
11
9
 
@@ -14,7 +12,6 @@ export const ThemeSelector = ({ className, css }: ThemeSelectorProps) => {
14
12
  display: 'flex',
15
13
  flexDirection: 'column',
16
14
  alignSelf: 'end',
17
- // justifyContent: ContentPosition.center,
18
15
  ...css,
19
16
  };
20
17
 
@@ -0,0 +1,52 @@
1
+ // import { bindPageResetEvent } from '../core/page-reset-events';
2
+
3
+ let _pageTitle = { value: '', defaultValue: '' };
4
+ export const setPageTitle = (title: string) => {
5
+ _pageTitle.value = title;
6
+ };
7
+
8
+ export const getPageTitle = () => {
9
+ return _pageTitle.value || _pageTitle.defaultValue;
10
+ };
11
+
12
+ export const setDefaultPageTitle = (title: string) => {
13
+ _pageTitle.defaultValue = title;
14
+ };
15
+
16
+ let _description = { value: '', defaultValue: '' };
17
+ export const setMetaDescription = (description: string) => {
18
+ _description.value = description;
19
+ };
20
+
21
+ export const getMetaDescription = () => {
22
+ return _description.value || _description.defaultValue;
23
+ };
24
+
25
+ export const setDefaultMetaDescription = (description: string) => {
26
+ _description.defaultValue = description;
27
+ };
28
+
29
+ let _metaData: { [key: string]: string } = {};
30
+ export const addMetaDataTags = (key: string, value: string) => {
31
+ if (typeof value === 'undefined') {
32
+ delete _metaData[key];
33
+ } else {
34
+ _metaData[key] = value;
35
+ }
36
+ };
37
+
38
+ export const getMetaDataTags = () => {
39
+ return Object.values(getMetaDataObject()).join('\n');
40
+ };
41
+
42
+ export const getMetaDataObject = () => {
43
+ const metaDescription = getMetaDescription();
44
+ return metaDescription
45
+ ? Object.assign(
46
+ {
47
+ 'name:description': `<meta name="description" content="${metaDescription}">`,
48
+ },
49
+ _metaData
50
+ )
51
+ : _metaData;
52
+ };
@@ -1,5 +1,5 @@
1
- import { CssProps } from '../jsx';
2
1
  import { DomUtils } from '../lib';
2
+ import { ThemesProps } from '../models';
3
3
  import { getEitherCookie } from './server-cookie';
4
4
 
5
5
  // theme doesn't need to reset, theme name is stored in cookie
@@ -8,8 +8,8 @@ export const defaultThemeName = 'light';
8
8
  export const themeCookieName = 'theme';
9
9
  export const updateThemeEventName = 'updateTheme';
10
10
  export const themeAttributeName = 'data-theme';
11
- const _themeCfg: any = { defaultTheme: defaultThemeName, themes: {} };
12
- export const bindTheme = (defaultTheme: string, themes: { [key: string]: CssProps }) => {
11
+ const _themeCfg: { defaultTheme: string; themes: ThemesProps } = { defaultTheme: defaultThemeName, themes: {} };
12
+ export const bindTheme = (defaultTheme: string, themes: ThemesProps) => {
13
13
  _themeCfg.defaultTheme = defaultTheme;
14
14
  _themeCfg.themes = themes;
15
15
 
@@ -25,7 +25,7 @@ export const getCurrentTheme = () => {
25
25
  DomUtils.setCookie(themeCookieName, _themeCfg.defaultTheme);
26
26
  }
27
27
  }
28
- return { themeName, themes: _themeCfg.themes as { [key: string]: CssProps } };
28
+ return { themeName, themes: _themeCfg.themes };
29
29
  };
30
30
 
31
31
  export const updateTheme = (themeName: string) => {
@@ -39,6 +39,7 @@ export const updateTheme = (themeName: string) => {
39
39
  document.documentElement.setAttribute(themeAttributeName, themeName);
40
40
 
41
41
  // update theme for all iframe
42
+ // TODO: third-party domains?
42
43
  const allIframe = document.querySelectorAll('iframe');
43
44
  for (let i = 0; i < allIframe.length; i++) {
44
45
  if (allIframe[i].contentWindow && allIframe[i].contentWindow!.top === window) {
package/src/core/core.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { getMetaDataObject, getMetaDataTags, getMetaTitle } from '../components';
2
1
  import { VNode } from '../jsx';
3
2
  import { initWebEnv, initWebSetting } from '../lib';
4
3
  import { Logger } from '../lib/logger';
@@ -9,16 +8,8 @@ import { mountComponents } from './mount-components';
9
8
  import { PageRouter } from './page-router';
10
9
  import { callPageLoadedEvent } from './page-loaded-events';
11
10
  import { initServerCookies } from './server-cookie';
12
- import { IToClientDelivery } from '../models/to-client-delivery-props';
13
-
14
- export type JsonKeyValue = {
15
- [key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
16
- };
17
- export type JsonObject =
18
- | JsonKeyValue[]
19
- | {
20
- [key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
21
- };
11
+ import { IToClientDelivery, JsonObject } from '../models';
12
+ import { getMetaDataObject, getMetaDataTags, getPageTitle } from './bind-meta';
22
13
 
23
14
  export type RenderPageFunctionsType = {
24
15
  fetchData: (url: string, postBody?: string | JsonObject, returnRawResponse?: boolean) => Promise<any>;
@@ -118,7 +109,7 @@ export const generatePage = async (props: PageProps, toClientDelivery: IToClient
118
109
 
119
110
  return {
120
111
  content,
121
- title: getMetaTitle(),
112
+ title: getPageTitle(),
122
113
  metaData: getMetaDataTags(),
123
114
  globalCss: cssText,
124
115
  themeName: currentTheme.themeName,
@@ -165,7 +156,7 @@ export const initializePage = async (newUrl?: string) => {
165
156
  updateTheme(getCurrentTheme().themeName);
166
157
 
167
158
  // title
168
- document.title = getMetaTitle();
159
+ document.title = getPageTitle();
169
160
  const metaData = getMetaDataObject();
170
161
  // meta data?
171
162
  };
package/src/core/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './bind-attributes';
2
2
  export * from './bind-lang';
3
3
  export * from './bind-links';
4
+ export * from './bind-meta';
4
5
  export * from './bind-ref';
5
6
  export * from './bind-styles';
6
7
  export * from './bind-theme';
package/src/index.ts CHANGED
@@ -5,8 +5,8 @@ export * from './jsx';
5
5
  export * from './core';
6
6
  export * from './lib';
7
7
  export * from './components';
8
- export * from './types';
9
- export * from './assets/themes';
8
+ export * from './models';
9
+ export * from './styles';
10
10
 
11
11
  declare global {
12
12
  namespace JSX {
@@ -1,2 +1,4 @@
1
+ export * from './json-props';
1
2
  export * from './simple-storage-props';
3
+ export * from './theme-props';
2
4
  export * from './to-client-delivery-props';
@@ -0,0 +1,8 @@
1
+ export type JsonKeyValue = {
2
+ [key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
3
+ };
4
+ export type JsonObject =
5
+ | JsonKeyValue[]
6
+ | {
7
+ [key: string]: string | number | boolean | null | undefined | JsonKeyValue | JsonKeyValue[];
8
+ };
@@ -0,0 +1,7 @@
1
+ export type ThemeProps = {
2
+ [key: string]: string | number;
3
+ };
4
+
5
+ export type ThemesProps = {
6
+ [key: string]: ThemeProps;
7
+ };
@@ -1,7 +1,8 @@
1
+ import { ThemesProps } from '../models';
1
2
  import { darkThemes } from './dark-themes';
2
3
  import { lightThemes } from './light-themes';
3
4
 
4
- export const baseThemes: { [key: string]: { [key: string]: string } } = {
5
+ export const baseThemes: ThemesProps = {
5
6
  light: lightThemes,
6
7
  dark: darkThemes,
7
8
  lightGreen: {
@@ -1,6 +1,7 @@
1
1
  import { sharedThemes } from './shared-themes';
2
+ import { ThemeProps } from '../models';
2
3
 
3
- export const darkThemes: { [key: string]: string } = {
4
+ export const darkThemes: ThemeProps = {
4
5
  ...sharedThemes,
5
6
  '--theme-name': 'dark',
6
7
 
@@ -0,0 +1,9 @@
1
+ import { CssProps } from '../jsx';
2
+ export { CssProps as CSS };
3
+
4
+ export * from './css-styles';
5
+ export * from './media-query';
6
+ export * from './shared-themes';
7
+ export * from './dark-themes';
8
+ export * from './light-themes';
9
+ export * from './base-themes';
@@ -1,6 +1,7 @@
1
1
  import { sharedThemes } from './shared-themes';
2
+ import { ThemeProps } from '../models';
2
3
 
3
- export const lightThemes: { [key: string]: string } = {
4
+ export const lightThemes: ThemeProps = {
4
5
  ...sharedThemes,
5
6
  '--theme-name': 'light',
6
7
 
@@ -1,4 +1,6 @@
1
- export const sharedThemes: { [key: string]: string } = {
1
+ import { ThemeProps } from "../models";
2
+
3
+ export const sharedThemes: ThemeProps = {
2
4
  // z-index
3
5
  '--layer-cover': '10',
4
6
  '--layer-sidebar': '100',
@@ -1,4 +0,0 @@
1
- export * from './shared-themes';
2
- export * from './dark-themes';
3
- export * from './light-themes';
4
- export * from './base-themes';
@@ -1,19 +0,0 @@
1
- // import { bindPageResetEvent } from '../core/page-reset-events';
2
-
3
- let _title = { value: '', defaultValue: '' };
4
- export const MetaTitle = ({ children }: { children: string }) => {
5
- _title.value = children;
6
- return <></>;
7
- };
8
-
9
- export const getMetaTitle = () => {
10
- return _title.value || _title.defaultValue;
11
- };
12
-
13
- export const setDefaultMetaTitle = (children: string) => {
14
- _title.defaultValue = children;
15
- };
16
-
17
- // bindPageResetEvent(() => {
18
- // _title.value = '';
19
- // });
@@ -1,17 +0,0 @@
1
- export enum ContentPosition {
2
- center = 'center',
3
- end = 'end',
4
- flexEnd = 'flex-end',
5
- flexStart = 'flex-start',
6
- start = 'start',
7
- }
8
-
9
- export type SelfPosition = 'center' | 'end' | 'flex-end' | 'flex-start' | 'self-end' | 'self-start' | 'start';
10
-
11
- export enum Position {
12
- absolute = 'absolute',
13
- fixed = 'fixed',
14
- relative = 'relative',
15
- static = 'static',
16
- sticky = 'sticky',
17
- }
@@ -1,6 +0,0 @@
1
- import { CssProps } from '../jsx';
2
- export { CssProps as CSS };
3
-
4
- export * from './css-styles';
5
- export * from './css-types';
6
- export * from './media-query';
File without changes
File without changes