@pikacss/core 0.0.6 → 0.0.8
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/dist/index.cjs +37 -16
- package/dist/index.d.cts +6 -6
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +37 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const ATOMIC_STYLE_NAME_PLACEHOLDER = "
|
|
4
|
-
const ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL =
|
|
5
|
-
const TEMP_ATOMIC_STYLE_NAME_PLACEHOLDER = "@@";
|
|
6
|
-
const TEMP_ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL = /@@/g;
|
|
7
|
-
const DEFAULT_SELECTOR_PLACEHOLDER = "&";
|
|
8
|
-
const DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL = /&/g;
|
|
3
|
+
const ATOMIC_STYLE_NAME_PLACEHOLDER = "$$";
|
|
4
|
+
const ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL = /\$\$/g;
|
|
9
5
|
|
|
10
6
|
const chars = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"];
|
|
11
7
|
const numOfChars = chars.length;
|
|
@@ -66,21 +62,46 @@ function appendAutocompleteCssPropertyValues(config, property, ...values) {
|
|
|
66
62
|
config.autocomplete.cssProperties.set(property, [...current, ...values]);
|
|
67
63
|
}
|
|
68
64
|
|
|
69
|
-
|
|
65
|
+
function replaceBySplitAndJoin(str, split, mapFn, join) {
|
|
66
|
+
let splitted = str.split(split);
|
|
67
|
+
if (mapFn != null)
|
|
68
|
+
splitted = splitted.map(mapFn);
|
|
69
|
+
return splitted.join(join);
|
|
70
|
+
}
|
|
71
|
+
const RE_SPLIT = /\s*,\s*/g;
|
|
72
|
+
const DEFAULT_SELECTOR_PLACEHOLDER = "$";
|
|
73
|
+
const DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL = /\$/g;
|
|
74
|
+
const ATTRIBUTE_SUFFIX_MATCH = "$=";
|
|
75
|
+
const ATTRIBUTE_SUFFIX_MATCH_RE_GLOBAL = /\$=/g;
|
|
70
76
|
function normalizeSelectors({
|
|
71
77
|
selectors,
|
|
72
78
|
defaultSelector
|
|
73
79
|
}) {
|
|
74
|
-
|
|
80
|
+
if (selectors.length === 0)
|
|
81
|
+
return [defaultSelector];
|
|
82
|
+
const normalized = selectors.map((s) => s.replace(RE_SPLIT, ","));
|
|
75
83
|
const lastSelector = selectors[selectors.length - 1];
|
|
76
|
-
if (
|
|
77
|
-
normalized
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
if (lastSelector.includes(ATOMIC_STYLE_NAME_PLACEHOLDER) === false && lastSelector.includes(DEFAULT_SELECTOR_PLACEHOLDER) === false) {
|
|
85
|
+
normalized.push(DEFAULT_SELECTOR_PLACEHOLDER);
|
|
86
|
+
}
|
|
87
|
+
return normalized.map(
|
|
88
|
+
(s) => replaceBySplitAndJoin(
|
|
89
|
+
s,
|
|
90
|
+
ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL,
|
|
91
|
+
(a) => replaceBySplitAndJoin(
|
|
92
|
+
a,
|
|
93
|
+
ATTRIBUTE_SUFFIX_MATCH_RE_GLOBAL,
|
|
94
|
+
(b) => replaceBySplitAndJoin(
|
|
95
|
+
b,
|
|
96
|
+
DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL,
|
|
97
|
+
null,
|
|
98
|
+
defaultSelector
|
|
99
|
+
),
|
|
100
|
+
ATTRIBUTE_SUFFIX_MATCH
|
|
101
|
+
),
|
|
102
|
+
ATOMIC_STYLE_NAME_PLACEHOLDER
|
|
103
|
+
)
|
|
104
|
+
);
|
|
84
105
|
}
|
|
85
106
|
function normalizeValue(value) {
|
|
86
107
|
if (value == null)
|
package/dist/index.d.cts
CHANGED
|
@@ -190,15 +190,15 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
190
190
|
*/
|
|
191
191
|
prefix?: string;
|
|
192
192
|
/**
|
|
193
|
-
* Set the default selector format. '
|
|
193
|
+
* Set the default selector format. '$$' will be replaced with the atomic style name.
|
|
194
194
|
*
|
|
195
|
-
* @default '
|
|
195
|
+
* @default '.$$'
|
|
196
196
|
* @example
|
|
197
197
|
* ```ts
|
|
198
198
|
* {
|
|
199
|
-
* defaultSelector: '
|
|
199
|
+
* defaultSelector: '.$$' // Use class attribute: <div class="a b c">
|
|
200
200
|
* // or
|
|
201
|
-
* defaultSelector: '[data-pika~="
|
|
201
|
+
* defaultSelector: '[data-pika~="$$"]' // Use attribute selector: <div data-pika="a b c">
|
|
202
202
|
* }
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
@@ -317,7 +317,7 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
317
317
|
* {
|
|
318
318
|
* selectors: [
|
|
319
319
|
* // Static selector
|
|
320
|
-
* ['hover', '
|
|
320
|
+
* ['hover', '$:hover'],
|
|
321
321
|
* // Dynamic selector
|
|
322
322
|
* [/^screen-(\d+)$/, m => `@media (min-width: ${m[1]}px)`,
|
|
323
323
|
* ['screen-768', 'screen-1024']], // Autocomplete suggestions
|
|
@@ -385,7 +385,7 @@ type MakePropertyValue<T> = T | [value: T, fallback: T[]] | null | undefined;
|
|
|
385
385
|
type Properties<Autocomplete_ extends Autocomplete = EmptyAutocomplete> = {
|
|
386
386
|
[Key in keyof CSSProperties | Autocomplete_['ExtraCssProperty'] | Autocomplete_['ExtraProperty']]?: Key extends Autocomplete_['ExtraProperty'] ? GetValue<Autocomplete_['PropertiesValue'], Key> : MakePropertyValue<Exclude<UnionString | UnionNumber | GetValue<CSSProperties, Key> | GetValue<Autocomplete_['CssPropertiesValue'], ToKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], FromKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], '*'>, undefined | null>>;
|
|
387
387
|
};
|
|
388
|
-
type CSSPseudos = `${'
|
|
388
|
+
type CSSPseudos = `${'$'}${CSS.Pseudos}`;
|
|
389
389
|
type CSSBlockAtRules = Exclude<CSS.AtRules, '@charset' | 'import' | '@namespace'>;
|
|
390
390
|
type CSSSelectors = CSSBlockAtRules | CSSPseudos;
|
|
391
391
|
type WrapWithSelector<Autocomplete_ extends Autocomplete, T> = {
|
package/dist/index.d.mts
CHANGED
|
@@ -190,15 +190,15 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
190
190
|
*/
|
|
191
191
|
prefix?: string;
|
|
192
192
|
/**
|
|
193
|
-
* Set the default selector format. '
|
|
193
|
+
* Set the default selector format. '$$' will be replaced with the atomic style name.
|
|
194
194
|
*
|
|
195
|
-
* @default '
|
|
195
|
+
* @default '.$$'
|
|
196
196
|
* @example
|
|
197
197
|
* ```ts
|
|
198
198
|
* {
|
|
199
|
-
* defaultSelector: '
|
|
199
|
+
* defaultSelector: '.$$' // Use class attribute: <div class="a b c">
|
|
200
200
|
* // or
|
|
201
|
-
* defaultSelector: '[data-pika~="
|
|
201
|
+
* defaultSelector: '[data-pika~="$$"]' // Use attribute selector: <div data-pika="a b c">
|
|
202
202
|
* }
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
@@ -317,7 +317,7 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
317
317
|
* {
|
|
318
318
|
* selectors: [
|
|
319
319
|
* // Static selector
|
|
320
|
-
* ['hover', '
|
|
320
|
+
* ['hover', '$:hover'],
|
|
321
321
|
* // Dynamic selector
|
|
322
322
|
* [/^screen-(\d+)$/, m => `@media (min-width: ${m[1]}px)`,
|
|
323
323
|
* ['screen-768', 'screen-1024']], // Autocomplete suggestions
|
|
@@ -385,7 +385,7 @@ type MakePropertyValue<T> = T | [value: T, fallback: T[]] | null | undefined;
|
|
|
385
385
|
type Properties<Autocomplete_ extends Autocomplete = EmptyAutocomplete> = {
|
|
386
386
|
[Key in keyof CSSProperties | Autocomplete_['ExtraCssProperty'] | Autocomplete_['ExtraProperty']]?: Key extends Autocomplete_['ExtraProperty'] ? GetValue<Autocomplete_['PropertiesValue'], Key> : MakePropertyValue<Exclude<UnionString | UnionNumber | GetValue<CSSProperties, Key> | GetValue<Autocomplete_['CssPropertiesValue'], ToKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], FromKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], '*'>, undefined | null>>;
|
|
387
387
|
};
|
|
388
|
-
type CSSPseudos = `${'
|
|
388
|
+
type CSSPseudos = `${'$'}${CSS.Pseudos}`;
|
|
389
389
|
type CSSBlockAtRules = Exclude<CSS.AtRules, '@charset' | 'import' | '@namespace'>;
|
|
390
390
|
type CSSSelectors = CSSBlockAtRules | CSSPseudos;
|
|
391
391
|
type WrapWithSelector<Autocomplete_ extends Autocomplete, T> = {
|
package/dist/index.d.ts
CHANGED
|
@@ -190,15 +190,15 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
190
190
|
*/
|
|
191
191
|
prefix?: string;
|
|
192
192
|
/**
|
|
193
|
-
* Set the default selector format. '
|
|
193
|
+
* Set the default selector format. '$$' will be replaced with the atomic style name.
|
|
194
194
|
*
|
|
195
|
-
* @default '
|
|
195
|
+
* @default '.$$'
|
|
196
196
|
* @example
|
|
197
197
|
* ```ts
|
|
198
198
|
* {
|
|
199
|
-
* defaultSelector: '
|
|
199
|
+
* defaultSelector: '.$$' // Use class attribute: <div class="a b c">
|
|
200
200
|
* // or
|
|
201
|
-
* defaultSelector: '[data-pika~="
|
|
201
|
+
* defaultSelector: '[data-pika~="$$"]' // Use attribute selector: <div data-pika="a b c">
|
|
202
202
|
* }
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
@@ -317,7 +317,7 @@ interface EngineConfig<_Plugins extends EnginePlugin[] = EnginePlugin[], _Select
|
|
|
317
317
|
* {
|
|
318
318
|
* selectors: [
|
|
319
319
|
* // Static selector
|
|
320
|
-
* ['hover', '
|
|
320
|
+
* ['hover', '$:hover'],
|
|
321
321
|
* // Dynamic selector
|
|
322
322
|
* [/^screen-(\d+)$/, m => `@media (min-width: ${m[1]}px)`,
|
|
323
323
|
* ['screen-768', 'screen-1024']], // Autocomplete suggestions
|
|
@@ -385,7 +385,7 @@ type MakePropertyValue<T> = T | [value: T, fallback: T[]] | null | undefined;
|
|
|
385
385
|
type Properties<Autocomplete_ extends Autocomplete = EmptyAutocomplete> = {
|
|
386
386
|
[Key in keyof CSSProperties | Autocomplete_['ExtraCssProperty'] | Autocomplete_['ExtraProperty']]?: Key extends Autocomplete_['ExtraProperty'] ? GetValue<Autocomplete_['PropertiesValue'], Key> : MakePropertyValue<Exclude<UnionString | UnionNumber | GetValue<CSSProperties, Key> | GetValue<Autocomplete_['CssPropertiesValue'], ToKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], FromKebab<Key>> | GetValue<Autocomplete_['CssPropertiesValue'], '*'>, undefined | null>>;
|
|
387
387
|
};
|
|
388
|
-
type CSSPseudos = `${'
|
|
388
|
+
type CSSPseudos = `${'$'}${CSS.Pseudos}`;
|
|
389
389
|
type CSSBlockAtRules = Exclude<CSS.AtRules, '@charset' | 'import' | '@namespace'>;
|
|
390
390
|
type CSSSelectors = CSSBlockAtRules | CSSPseudos;
|
|
391
391
|
type WrapWithSelector<Autocomplete_ extends Autocomplete, T> = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
const ATOMIC_STYLE_NAME_PLACEHOLDER = "
|
|
2
|
-
const ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL =
|
|
3
|
-
const TEMP_ATOMIC_STYLE_NAME_PLACEHOLDER = "@@";
|
|
4
|
-
const TEMP_ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL = /@@/g;
|
|
5
|
-
const DEFAULT_SELECTOR_PLACEHOLDER = "&";
|
|
6
|
-
const DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL = /&/g;
|
|
1
|
+
const ATOMIC_STYLE_NAME_PLACEHOLDER = "$$";
|
|
2
|
+
const ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL = /\$\$/g;
|
|
7
3
|
|
|
8
4
|
const chars = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"];
|
|
9
5
|
const numOfChars = chars.length;
|
|
@@ -64,21 +60,46 @@ function appendAutocompleteCssPropertyValues(config, property, ...values) {
|
|
|
64
60
|
config.autocomplete.cssProperties.set(property, [...current, ...values]);
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
function replaceBySplitAndJoin(str, split, mapFn, join) {
|
|
64
|
+
let splitted = str.split(split);
|
|
65
|
+
if (mapFn != null)
|
|
66
|
+
splitted = splitted.map(mapFn);
|
|
67
|
+
return splitted.join(join);
|
|
68
|
+
}
|
|
69
|
+
const RE_SPLIT = /\s*,\s*/g;
|
|
70
|
+
const DEFAULT_SELECTOR_PLACEHOLDER = "$";
|
|
71
|
+
const DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL = /\$/g;
|
|
72
|
+
const ATTRIBUTE_SUFFIX_MATCH = "$=";
|
|
73
|
+
const ATTRIBUTE_SUFFIX_MATCH_RE_GLOBAL = /\$=/g;
|
|
68
74
|
function normalizeSelectors({
|
|
69
75
|
selectors,
|
|
70
76
|
defaultSelector
|
|
71
77
|
}) {
|
|
72
|
-
|
|
78
|
+
if (selectors.length === 0)
|
|
79
|
+
return [defaultSelector];
|
|
80
|
+
const normalized = selectors.map((s) => s.replace(RE_SPLIT, ","));
|
|
73
81
|
const lastSelector = selectors[selectors.length - 1];
|
|
74
|
-
if (
|
|
75
|
-
normalized
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
if (lastSelector.includes(ATOMIC_STYLE_NAME_PLACEHOLDER) === false && lastSelector.includes(DEFAULT_SELECTOR_PLACEHOLDER) === false) {
|
|
83
|
+
normalized.push(DEFAULT_SELECTOR_PLACEHOLDER);
|
|
84
|
+
}
|
|
85
|
+
return normalized.map(
|
|
86
|
+
(s) => replaceBySplitAndJoin(
|
|
87
|
+
s,
|
|
88
|
+
ATOMIC_STYLE_NAME_PLACEHOLDER_RE_GLOBAL,
|
|
89
|
+
(a) => replaceBySplitAndJoin(
|
|
90
|
+
a,
|
|
91
|
+
ATTRIBUTE_SUFFIX_MATCH_RE_GLOBAL,
|
|
92
|
+
(b) => replaceBySplitAndJoin(
|
|
93
|
+
b,
|
|
94
|
+
DEFAULT_SELECTOR_PLACEHOLDER_RE_GLOBAL,
|
|
95
|
+
null,
|
|
96
|
+
defaultSelector
|
|
97
|
+
),
|
|
98
|
+
ATTRIBUTE_SUFFIX_MATCH
|
|
99
|
+
),
|
|
100
|
+
ATOMIC_STYLE_NAME_PLACEHOLDER
|
|
101
|
+
)
|
|
102
|
+
);
|
|
82
103
|
}
|
|
83
104
|
function normalizeValue(value) {
|
|
84
105
|
if (value == null)
|