@react-x11/components 0.16.1 → 0.17.0

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.
@@ -16,6 +16,7 @@ import { AUTO, alphaOf, fourSides, inkColor, isTransparent, keywordFontSize, par
16
16
  import { parseUrl, readIdent, startsIdent } from './parse.js';
17
17
  import { parseContent, parseCounterList, parseListStyleType, parseQuotes, } from './content.js';
18
18
  import { parseRotate, parseScale, parseTransform } from './transform.js';
19
+ import { ANIMATION_LONGHANDS, NO_ANIMATIONS, animationLonghand, parseAnimation, } from './animation.js';
19
20
  import { LIGHT_DARK, SYSTEM_COLOR, lightDark, systemColors, usedColorScheme, } from './color.js';
20
21
  import { svgPaint } from './shapes.js';
21
22
  /** Whether a length is one `padding` takes: not `auto`, not negative. A
@@ -339,6 +340,7 @@ export function initialStyle(look, scale = 1) {
339
340
  scale: null,
340
341
  transform: null,
341
342
  transformOrigin: [{ pct: 50 }, { pct: 50 }],
343
+ animations: NO_ANIMATIONS,
342
344
  zIndex: AUTO,
343
345
  verticalAlign: 'baseline',
344
346
  width: AUTO,
@@ -654,13 +656,23 @@ const BORDER_WIDTH_KEYWORDS = {
654
656
  medium: 3,
655
657
  thick: 5,
656
658
  };
657
- /** `-webkit-` names that are the multicol properties' own. */
658
- const MULTICOL_ALIASES = {
659
+ /** `-webkit-` names that are the multicol properties' own, and the
660
+ * animation's. */
661
+ const PREFIXED_ALIASES = {
659
662
  '-webkit-columns': 'columns',
660
663
  '-webkit-column-count': 'column-count',
661
664
  '-webkit-column-width': 'column-width',
662
665
  '-webkit-column-gap': 'column-gap',
663
666
  '-webkit-column-break-inside': 'break-inside',
667
+ '-webkit-animation': 'animation',
668
+ '-webkit-animation-name': 'animation-name',
669
+ '-webkit-animation-duration': 'animation-duration',
670
+ '-webkit-animation-timing-function': 'animation-timing-function',
671
+ '-webkit-animation-delay': 'animation-delay',
672
+ '-webkit-animation-iteration-count': 'animation-iteration-count',
673
+ '-webkit-animation-direction': 'animation-direction',
674
+ '-webkit-animation-fill-mode': 'animation-fill-mode',
675
+ '-webkit-animation-play-state': 'animation-play-state',
664
676
  };
665
677
  /**
666
678
  * Apply one declaration to a style, in place.
@@ -672,11 +684,11 @@ const MULTICOL_ALIASES = {
672
684
  */
673
685
  export function applyDeclaration(style, parent, prop, rawValue, ctx) {
674
686
  const written = prop.toLowerCase();
675
- // the multicol properties under the names WebKit had them by, which
676
- // Blink still reads, each an alias of the property (`-webkit-column-
677
- // count` in its `css_properties.json5`): a page written for it alone
678
- // names no other
679
- const name = MULTICOL_ALIASES[written] ?? written;
687
+ // the multicol and animation properties under the names WebKit had them
688
+ // by, which Blink still reads, each an alias of the property (`-webkit-
689
+ // column-count` in its `css_properties.json5`): a page written for it
690
+ // alone names no other
691
+ const name = PREFIXED_ALIASES[written] ?? written;
680
692
  let value = rawValue.trim();
681
693
  if (!value)
682
694
  return;
@@ -1165,6 +1177,25 @@ export function applyDeclaration(style, parent, prop, rawValue, ctx) {
1165
1177
  style.opacity = a;
1166
1178
  return;
1167
1179
  }
1180
+ case 'animation': {
1181
+ const animations = parseAnimation(value);
1182
+ if (animations)
1183
+ style.animations = animations;
1184
+ return;
1185
+ }
1186
+ case 'animation-name':
1187
+ case 'animation-duration':
1188
+ case 'animation-timing-function':
1189
+ case 'animation-delay':
1190
+ case 'animation-iteration-count':
1191
+ case 'animation-direction':
1192
+ case 'animation-fill-mode':
1193
+ case 'animation-play-state': {
1194
+ const animations = animationLonghand(style.animations, ANIMATION_LONGHANDS[name], value);
1195
+ if (animations)
1196
+ style.animations = animations;
1197
+ return;
1198
+ }
1168
1199
  case 'translate': {
1169
1200
  // `none`, or across, down, and a depth nothing here has
1170
1201
  if (value.trim().toLowerCase() === 'none') {
@@ -4884,6 +4915,14 @@ export function initialOne(style, initial, name) {
4884
4915
  style.mask = { ...style.mask, [list]: initial.mask[list] };
4885
4916
  return;
4886
4917
  }
4918
+ const animation = ANIMATION_LONGHANDS[PREFIXED_ALIASES[name] ?? name];
4919
+ if (animation) {
4920
+ style.animations = {
4921
+ ...style.animations,
4922
+ [animation]: initial.animations[animation],
4923
+ };
4924
+ return;
4925
+ }
4887
4926
  const keys = INHERIT_TARGETS[name];
4888
4927
  if (!keys)
4889
4928
  return;
@@ -4897,6 +4936,15 @@ function inheritOne(style, parent, name) {
4897
4936
  style.mask = { ...style.mask, [list]: parent.mask[list] };
4898
4937
  return;
4899
4938
  }
4939
+ // each longhand of the animation is a list of its own, as the mask's are
4940
+ const animation = ANIMATION_LONGHANDS[PREFIXED_ALIASES[name] ?? name];
4941
+ if (animation) {
4942
+ style.animations = {
4943
+ ...style.animations,
4944
+ [animation]: parent.animations[animation],
4945
+ };
4946
+ return;
4947
+ }
4900
4948
  const keys = INHERIT_TARGETS[name];
4901
4949
  if (!keys)
4902
4950
  return;
@@ -4947,6 +4995,8 @@ const INHERIT_TARGETS = {
4947
4995
  'border-image': ['borderImage'],
4948
4996
  mask: ['mask'],
4949
4997
  '-webkit-mask': ['mask'],
4998
+ animation: ['animations'],
4999
+ '-webkit-animation': ['animations'],
4950
5000
  'border-image-source': ['borderImage'],
4951
5001
  'border-image-slice': ['borderImage'],
4952
5002
  'border-image-width': ['borderImage'],