@xenknight/framework7 0.0.5 → 0.0.6

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 (73) hide show
  1. package/components/block/block-vars.less +6 -6
  2. package/components/button/button-vars.less +11 -10
  3. package/components/dialog/dialog-class.js +6 -3
  4. package/components/dialog/dialog-ios.less +10 -34
  5. package/components/dialog/dialog-md.less +2 -22
  6. package/components/dialog/dialog-rtl.css +1 -1
  7. package/components/dialog/dialog-vars.less +8 -10
  8. package/components/dialog/dialog.css +1 -1
  9. package/components/dialog/dialog.js +3 -3
  10. package/components/dialog/dialog.less +6 -25
  11. package/components/list/list-vars.less +7 -5
  12. package/components/list/list.less +1 -1
  13. package/components/notification/notification-class.js +6 -6
  14. package/components/notification/notification-ios.less +3 -8
  15. package/components/notification/notification-md.less +1 -20
  16. package/components/notification/notification-rtl.css +1 -1
  17. package/components/notification/notification-vars.less +13 -16
  18. package/components/notification/notification.css +1 -1
  19. package/components/notification/notification.less +13 -1
  20. package/components/popover/popover-class.js +21 -58
  21. package/components/popover/popover-ios.less +66 -2
  22. package/components/popover/popover-md.less +2 -27
  23. package/components/popover/popover-rtl.css +1 -1
  24. package/components/popover/popover-vars.less +2 -3
  25. package/components/popover/popover.css +1 -1
  26. package/components/popover/popover.d.ts +0 -2
  27. package/components/popover/popover.js +0 -1
  28. package/components/popover/popover.less +28 -50
  29. package/components/range/range-class.js +34 -27
  30. package/components/range/range-ios.less +60 -0
  31. package/components/range/range-md.less +67 -4
  32. package/components/range/range-rtl.css +1 -1
  33. package/components/range/range-vars.less +18 -13
  34. package/components/range/range.css +1 -1
  35. package/components/range/range.d.ts +3 -1
  36. package/components/range/range.less +11 -24
  37. package/components/swipeout/swipeout-ios.less +37 -0
  38. package/components/swipeout/swipeout-md.less +56 -0
  39. package/components/swipeout/swipeout-rtl.css +1 -1
  40. package/components/swipeout/swipeout-vars.less +13 -2
  41. package/components/swipeout/swipeout.css +1 -1
  42. package/components/swipeout/swipeout.js +99 -23
  43. package/components/swipeout/swipeout.less +20 -44
  44. package/components/toast/toast-class.js +2 -2
  45. package/components/toast/toast-ios.less +2 -0
  46. package/components/toast/toast-rtl.css +1 -1
  47. package/components/toast/toast-vars.less +2 -4
  48. package/components/toast/toast.css +1 -1
  49. package/components/toast/toast.less +1 -1
  50. package/framework7-bundle-rtl.css +417 -368
  51. package/framework7-bundle-rtl.min.css +4 -4
  52. package/framework7-bundle.css +417 -368
  53. package/framework7-bundle.esm.js +2 -2
  54. package/framework7-bundle.js +2446 -849
  55. package/framework7-bundle.js.map +1 -1
  56. package/framework7-bundle.less +2 -2
  57. package/framework7-bundle.min.css +4 -4
  58. package/framework7-bundle.min.js +3 -3
  59. package/framework7-bundle.min.js.map +1 -1
  60. package/framework7-lite-bundle.esm.js +2 -2
  61. package/framework7-lite.esm.js +2 -2
  62. package/framework7-rtl.css +27 -25
  63. package/framework7-rtl.min.css +3 -3
  64. package/framework7.css +27 -25
  65. package/framework7.esm.js +2 -2
  66. package/framework7.less +2 -2
  67. package/framework7.min.css +3 -3
  68. package/package.json +1 -1
  69. package/shared/get-support.d.ts +0 -6
  70. package/shared/get-support.js +1 -20
  71. package/shared/material-color-utils.js +2153 -679
  72. package/shared/material-colors.js +97 -17
  73. package/shared/utils.js +18 -6
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line
2
- import { argbFromHex, hexFromArgb, themeFromSourceColor } from './material-color-utils.js';
2
+ import { argbFromHex, hexFromArgb, Hct, SchemeTonalSpot, SchemeVibrant, SchemeMonochrome } from './material-color-utils.js';
3
3
 
4
4
  /* eslint-disable */
5
5
  // prettier-ignore
@@ -42,34 +42,114 @@ function blend(from, to, p) {
42
42
  }
43
43
  /* eslint-enable */
44
44
 
45
- export const materialColors = function (hexColor) {
45
+ let monochromeCached = null;
46
+ const cachedColors = {};
47
+ export const materialColors = function (hexColor, colorScheme) {
46
48
  if (hexColor === void 0) {
47
49
  hexColor = '';
48
50
  }
49
- const theme = themeFromSourceColor(argbFromHex(`#${hexColor.replace('#', '')}`));
50
- [0.05, 0.08, 0.11, 0.12, 0.14].forEach((amount, index) => {
51
- theme.schemes.light.props[`surface${index + 1}`] = argbFromHex(blend(hexFromArgb(theme.schemes.light.props.surface), hexFromArgb(theme.schemes.light.props.primary), amount));
52
- theme.schemes.dark.props[`surface${index + 1}`] = argbFromHex(blend(hexFromArgb(theme.schemes.dark.props.surface), hexFromArgb(theme.schemes.dark.props.primary), amount));
51
+ if (colorScheme === void 0) {
52
+ colorScheme = 'default';
53
+ }
54
+ const cacheKey = `${hexColor}-${colorScheme}`;
55
+ if (cachedColors[cacheKey]) {
56
+ return cachedColors[cacheKey];
57
+ }
58
+ if (monochromeCached && colorScheme.includes('monochrome')) {
59
+ const defaultColors = materialColors(hexColor, colorScheme === 'monochrome' ? 'default' : 'vibrant');
60
+ cachedColors[cacheKey] = {
61
+ light: {
62
+ ...defaultColors.light,
63
+ ...monochromeCached.light
64
+ },
65
+ dark: {
66
+ ...defaultColors.dark,
67
+ ...monochromeCached.dark
68
+ }
69
+ };
70
+ return cachedColors[cacheKey];
71
+ }
72
+ const sourceColor = argbFromHex(`#${hexColor.replace('#', '')}`);
73
+ let lightScheme;
74
+ let darkScheme;
75
+ const hctColor = Hct.fromInt(sourceColor);
76
+ if (colorScheme === 'default') {
77
+ lightScheme = new SchemeTonalSpot(hctColor, false, 0, '2025');
78
+ darkScheme = new SchemeTonalSpot(hctColor, true, 0, '2025');
79
+ }
80
+ if (colorScheme === 'vibrant') {
81
+ lightScheme = new SchemeVibrant(hctColor, false, 0, '2025');
82
+ darkScheme = new SchemeVibrant(hctColor, true, 0, '2025');
83
+ }
84
+ if (colorScheme.includes('monochrome')) {
85
+ lightScheme = new SchemeMonochrome(hctColor, false, 0, '2025');
86
+ darkScheme = new SchemeMonochrome(hctColor, true, 0, '2025');
87
+ }
88
+ const getColorName = name => {
89
+ let newName = name;
90
+ if (name === 'surface_dim') newName = 'surface_variant';
91
+ if (name === 'surface_container_low') newName = 'surface_1';
92
+ if (name === 'surface_container') newName = 'surface_2';
93
+ if (name === 'surface_container_high') newName = 'surface_3';
94
+ if (name === 'surface_container_highest') newName = 'surface_4';
95
+ return newName;
96
+ };
97
+ const theme = {
98
+ light: {},
99
+ dark: {}
100
+ };
101
+ lightScheme.colors.allColors.forEach(color => {
102
+ const name = getColorName(color.name);
103
+ const argb = color.getArgb(lightScheme);
104
+ theme.light[name] = argb;
53
105
  });
106
+ darkScheme.colors.allColors.forEach(color => {
107
+ const name = getColorName(color.name);
108
+ const argb = color.getArgb(darkScheme);
109
+ theme.dark[name] = argb;
110
+ });
111
+ theme.light.surface_5 = argbFromHex(blend(hexFromArgb(theme.light.surface_4), hexFromArgb(theme.light.primary), 0.05));
112
+ theme.dark.surface_5 = argbFromHex(blend(hexFromArgb(theme.dark.surface_4), hexFromArgb(theme.dark.primary), 0.05));
54
113
  const name = n => {
55
- return n.split('').map(char => char.toUpperCase() === char && char !== '-' && char !== '7' ? `-${char.toLowerCase()}` : char).join('');
114
+ return n.replace(/_/g, '-');
56
115
  };
57
- const shouldSkip = prop => {
58
- const skip = ['tertiary', 'shadow', 'scrim', 'error', 'background'];
59
- return skip.filter(v => prop.toLowerCase().includes(v)).length > 0;
116
+ const shouldKeep = prop => {
117
+ const foreground = ['inverse_primary', 'primary', 'on_primary', 'primary_container', 'on_primary_container', 'secondary', 'on_secondary', 'secondary_container', 'on_secondary_container', 'outline', 'outline_variant'];
118
+ const background = ['on_surface', 'on_surface_variant', 'inverse_on_surface', 'inverse_surface', 'surface', 'surface_variant', 'surface_1', 'surface_2', 'surface_3', 'surface_4', 'surface_5'];
119
+ const keep = colorScheme === 'default' ? [...foreground, ...background] : colorScheme === 'vibrant' ? [...foreground, ...background] : background;
120
+ return keep.includes(prop);
60
121
  };
61
122
  const light = {};
62
123
  const dark = {};
63
- Object.keys(theme.schemes.light.props).forEach(prop => {
64
- if (shouldSkip(prop)) return;
65
- light[name(`--f7-md-${prop}`)] = hexFromArgb(theme.schemes.light.props[prop]);
124
+ Object.keys(theme.light).forEach(prop => {
125
+ if (!shouldKeep(prop)) return;
126
+ light[name(`--f7-md-${prop}`)] = hexFromArgb(theme.light[prop]);
66
127
  });
67
- Object.keys(theme.schemes.dark.props).forEach(prop => {
68
- if (shouldSkip(prop)) return;
69
- dark[name(`--f7-md-${prop}`)] = hexFromArgb(theme.schemes.dark.props[prop]);
128
+ Object.keys(theme.dark).forEach(prop => {
129
+ if (!shouldKeep(prop)) return;
130
+ dark[name(`--f7-md-${prop}`)] = hexFromArgb(theme.dark[prop]);
70
131
  });
71
- return {
132
+ if (colorScheme.includes('monochrome')) {
133
+ monochromeCached = {
134
+ light,
135
+ dark
136
+ };
137
+ const defaultColors = materialColors(hexColor, colorScheme === 'monochrome' ? 'default' : 'vibrant');
138
+ cachedColors[cacheKey] = {
139
+ light: {
140
+ ...defaultColors.light,
141
+ ...light
142
+ },
143
+ dark: {
144
+ ...defaultColors.dark,
145
+ ...dark
146
+ }
147
+ };
148
+ return cachedColors[cacheKey];
149
+ }
150
+ cachedColors[cacheKey] = {
72
151
  light,
73
152
  dark
74
153
  };
154
+ return cachedColors[cacheKey];
75
155
  };
package/shared/utils.js CHANGED
@@ -332,31 +332,40 @@ const getShadeTintColors = rgb => {
332
332
  export function colorThemeCSSProperties() {
333
333
  let hex;
334
334
  let rgb;
335
+ let mdColorScheme;
335
336
  for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
336
337
  args[_key3] = arguments[_key3];
337
338
  }
338
339
  if (args.length === 1) {
339
340
  hex = args[0];
340
341
  rgb = colorHexToRgb(hex);
342
+ } else if (args.length === 2) {
343
+ hex = args[0];
344
+ rgb = colorHexToRgb(hex);
345
+ mdColorScheme = args[1] || 'default';
341
346
  } else if (args.length === 3) {
342
347
  rgb = args;
343
348
  hex = colorRgbToHex(...rgb);
349
+ } else if (args.length === 4) {
350
+ rgb = args.slice(0, 3);
351
+ hex = colorRgbToHex(...rgb);
352
+ mdColorScheme = args[3] || 'default';
344
353
  }
345
354
  if (!rgb) return {};
346
355
  const {
347
356
  light,
348
357
  dark
349
- } = materialColors(hex);
358
+ } = materialColors(hex, mdColorScheme);
350
359
  const shadeTintIos = getShadeTintColors(rgb);
351
360
  const shadeTintMdLight = getShadeTintColors(colorHexToRgb(light['--f7-md-primary']));
352
361
  const shadeTintMdDark = getShadeTintColors(colorHexToRgb(dark['--f7-md-primary']));
353
362
  Object.keys(light).forEach(key => {
354
- if (key.includes('surface-')) {
363
+ if (key.includes('surface-') && !key.includes('-rgb')) {
355
364
  light[`${key}-rgb`] = colorHexToRgb(light[key]);
356
365
  }
357
366
  });
358
367
  Object.keys(dark).forEach(key => {
359
- if (key.includes('surface-')) {
368
+ if (key.includes('surface-') && !key.includes('-rgb')) {
360
369
  dark[`${key}-rgb`] = colorHexToRgb(dark[key]);
361
370
  }
362
371
  });
@@ -413,10 +422,13 @@ export function flattenArray() {
413
422
  });
414
423
  return arr;
415
424
  }
416
- export function colorThemeCSSStyles(colors) {
425
+ export function colorThemeCSSStyles(colors, mdColorScheme) {
417
426
  if (colors === void 0) {
418
427
  colors = {};
419
428
  }
429
+ if (mdColorScheme === void 0) {
430
+ mdColorScheme = 'default';
431
+ }
420
432
  const stringifyObject = obj => {
421
433
  let res = '';
422
434
  Object.keys(obj).forEach(key => {
@@ -424,12 +436,12 @@ export function colorThemeCSSStyles(colors) {
424
436
  });
425
437
  return res;
426
438
  };
427
- const colorVars = colorThemeCSSProperties(colors.primary);
439
+ const colorVars = colorThemeCSSProperties(colors.primary, mdColorScheme);
428
440
  const primary = [`:root{`, stringifyObject(colorVars.light), `--swiper-theme-color:var(--f7-theme-color);`, ...Object.keys(colors).map(colorName => `--f7-color-${colorName}: ${colors[colorName]};`), `}`, `.dark{`, stringifyObject(colorVars.dark), `}`, `.ios, .ios .dark{`, stringifyObject(colorVars.ios), '}', `.md, .md .dark{`, stringifyObject(colorVars.md), '}'].join('');
429
441
  const restVars = {};
430
442
  Object.keys(colors).forEach(colorName => {
431
443
  const colorValue = colors[colorName];
432
- restVars[colorName] = colorThemeCSSProperties(colorValue);
444
+ restVars[colorName] = colorThemeCSSProperties(colorValue, mdColorScheme);
433
445
  });
434
446
 
435
447
  // rest