lupine.web 1.0.14 → 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.
Files changed (37) hide show
  1. package/README.md +2 -2
  2. package/jsx-runtime/package.json +2 -2
  3. package/package.json +1 -1
  4. package/src/components/button-push-animation.tsx +1 -1
  5. package/src/components/button.tsx +1 -1
  6. package/src/components/menu-bar.tsx +1 -1
  7. package/src/components/menu-sidebar.tsx +1 -1
  8. package/src/components/meta-data.tsx +6 -24
  9. package/src/components/meta-description.tsx +3 -10
  10. package/src/components/page-title.tsx +6 -0
  11. package/src/components/panel.tsx +1 -4
  12. package/src/components/popup-menu.tsx +1 -1
  13. package/src/components/tabs.tsx +1 -1
  14. package/src/components/theme-selector.tsx +0 -3
  15. package/src/components/toggle-base.tsx +1 -1
  16. package/src/components/toggle-switch.tsx +1 -1
  17. package/src/core/bind-meta.tsx +52 -0
  18. package/src/core/bind-theme.ts +5 -4
  19. package/src/core/core.ts +4 -13
  20. package/src/core/index.ts +1 -0
  21. package/src/index.ts +2 -2
  22. package/src/jsx.ts +1 -1
  23. package/src/models/index.ts +2 -0
  24. package/src/models/json-props.ts +8 -0
  25. package/src/models/theme-props.ts +7 -0
  26. package/src/{assets/themes → styles}/base-themes.ts +2 -1
  27. package/src/{assets/themes → styles}/dark-themes.ts +2 -1
  28. package/src/styles/index.ts +9 -0
  29. package/src/{assets/themes → styles}/light-themes.ts +2 -1
  30. package/src/{assets/themes → styles}/shared-themes.ts +3 -1
  31. package/tsconfig.json +2 -2
  32. package/src/assets/themes/index.ts +0 -4
  33. package/src/components/meta-title.tsx +0 -19
  34. package/src/types/css-types.ts +0 -17
  35. package/src/types/index.ts +0 -6
  36. /package/src/{types → styles}/css-styles.ts +0 -0
  37. /package/src/{types → styles}/media-query.ts +0 -0
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # lupine.js
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.
@@ -3,7 +3,7 @@
3
3
  "amdName": "jsxRuntime",
4
4
  "version": "1.0.0",
5
5
  "private": true,
6
- "description": "Lupine.js JSX runtime",
6
+ "description": "lupine.web JSX runtime",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "umd:main": "index.js",
@@ -11,6 +11,6 @@
11
11
  "types": "src/index.d.ts",
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
- "lupine.js": "^1.0.0"
14
+ "lupine.web": "^1.0.0"
15
15
  }
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lupine.web",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "license": "MIT",
5
5
  "author": "uuware.com",
6
6
  "homepage": "https://uuware.com/",
@@ -1,4 +1,4 @@
1
- import { CssProps, RefProps } from 'lupine.js';
1
+ import { CssProps, RefProps } from 'lupine.web';
2
2
 
3
3
  export enum ButtonPushAnimationSize {
4
4
  SmallSmall = 'button-ss',
@@ -1,4 +1,4 @@
1
- import { CssProps, RefProps } from 'lupine.js';
1
+ import { CssProps, RefProps } from 'lupine.web';
2
2
 
3
3
  export enum ButtonSize {
4
4
  SmallLarge = 'button-ss',
@@ -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 { RefProps, stopPropagation } from 'lupine.js';
1
+ import { RefProps, stopPropagation } from 'lupine.web';
2
2
 
3
3
  export type PopupMenuOpenMenuProps = { handle?: Function };
4
4
 
@@ -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
 
@@ -1,4 +1,4 @@
1
- import { CssProps, RefProps, VNode } from 'lupine.js';
1
+ import { CssProps, RefProps, VNode } from 'lupine.web';
2
2
 
3
3
  export const PlayButtonSize = {
4
4
  Small: { w: 50, h: 50 },
@@ -1,4 +1,4 @@
1
- import { bindGlobalStyles, CssProps } from 'lupine.js';
1
+ import { bindGlobalStyles, CssProps } from 'lupine.web';
2
2
  import { ToggleBase, ToggleBaseHookProps } from './toggle-base';
3
3
 
4
4
  export enum ToggleSwitchSize {
@@ -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 {
package/src/jsx.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Users who only use Preact for SSR might not specify "dom" in their lib in tsconfig.json
3
3
  /// <reference lib="dom" />
4
4
 
5
- // used by lupine.js
5
+ // used by lupine.web
6
6
  export type CssProps = {
7
7
  [key: string]: string | number | null | undefined | CssProps;
8
8
  };
@@ -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',
package/tsconfig.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */,
24
24
  // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
25
25
  // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
26
- "jsxImportSource": "lupine.js" /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */,
26
+ "jsxImportSource": "lupine.web" /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */,
27
27
  // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
28
28
  // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
29
29
  // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
@@ -39,7 +39,7 @@
39
39
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
40
40
  // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
41
41
  // "types": [], /* Specify type package names to be included without being referenced in a source file. */
42
- "types": ["node", "lupine.js"],
42
+ "types": ["node", "lupine.web"],
43
43
  // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
44
44
  // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
45
45
  // "resolveJsonModule": true /* Enable importing .json files. */,
@@ -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