lism-css 0.23.0 → 0.24.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.
@@ -2,6 +2,7 @@ import { TOKENS, PROPS } from '../../../config/index';
2
2
  import { WithArbitraryString, ArrayElement, ExtractArrayValues, ExtractObjectKeys, ExtractPropertyValue } from './utils';
3
3
  import { MakeResponsive } from './ResponsiveProps';
4
4
  import { FullModeRegistry } from './FullModeRegistry';
5
+ import { CustomPropValueRegistry } from './CustomPropValueRegistry';
5
6
  type PropsConfig = typeof PROPS;
6
7
  type TokensConfig = typeof TOKENS;
7
8
  /**
@@ -28,12 +29,19 @@ type ExtractTokenValues<T> = ExtractPropertyValue<T, 'token'> extends never ? ne
28
29
  * presets の値 + utils のキー + token の値
29
30
  */
30
31
  type ExtractPropValues<T> = ExtractArrayValues<T, 'presets'> | ExtractObjectKeys<T, 'utils'> | ExtractTokenValues<T>;
32
+ /**
33
+ * lism.config.js で既定 prop へ追加された値({@link CustomPropValueRegistry} の拡張分)を取得。
34
+ * 拡張が無い prop は never(defaults 由来の型のまま)。
35
+ */
36
+ type UserPropValues<K> = K extends keyof CustomPropValueRegistry ? Extract<CustomPropValueRegistry[K], string> : never;
31
37
  /**
32
38
  * プロパティの設定から値の型を決定
33
- * - presets/utils/token がある場合: 具体的な値 + 任意文字列 + number | boolean | null
39
+ * - presets/utils/token(+ user 追加分)がある場合: 具体的な値 + 任意文字列 + number | boolean | null
34
40
  * - ない場合: string | number(フォールバック)
41
+ *
42
+ * `[X] extends [never]` の tuple ラップで ExtraValues(naked 型パラメータ)の分配を防ぐ。
35
43
  */
36
- type PropValueType<T> = ExtractPropValues<T> extends never ? string | number | boolean : WithArbitraryString<ExtractPropValues<T>> | number | boolean | null;
44
+ type PropValueType<T, ExtraValues = never> = [ExtractPropValues<T> | ExtraValues] extends [never] ? string | number | boolean : WithArbitraryString<ExtractPropValues<T> | ExtraValues> | number | boolean | null;
37
45
  /**
38
46
  * bp プロパティでレスポンシブ(配列・オブジェクト形式)が有効かを判定
39
47
  * - bp 未設定 / bp: 0 → false
@@ -56,13 +64,13 @@ type PropsWithoutBreakpoint = Exclude<AllPropKeys, PropsWithBreakpoint>;
56
64
  * bp が有効なプロパティの型(レスポンシブ対応あり)
57
65
  */
58
66
  export type ResponsivePropValueTypes = {
59
- [K in PropsWithBreakpoint]?: PropValueType<PropsConfig[K]>;
67
+ [K in PropsWithBreakpoint]?: PropValueType<PropsConfig[K], UserPropValues<K>>;
60
68
  };
61
69
  /**
62
70
  * bp が無効なプロパティの型(レスポンシブ対応なし)
63
71
  */
64
72
  export type NonResponsivePropValueTypes = {
65
- [K in PropsWithoutBreakpoint]?: PropValueType<PropsConfig[K]>;
73
+ [K in PropsWithoutBreakpoint]?: PropValueType<PropsConfig[K], UserPropValues<K>>;
66
74
  };
67
75
  /** defaults 由来の Props 型(full モード未適用時のデフォルト) */
68
76
  type DefaultPropValueTypes = MakeResponsive<ResponsivePropValueTypes> & NonResponsivePropValueTypes;
@@ -84,9 +92,9 @@ type FullPropsWithBreakpoint = {
84
92
  type FullPropsWithoutBreakpoint = Exclude<AllPropKeys, FullPropsWithBreakpoint>;
85
93
  /** full モード適用時の Props 型(isVar 系を除く全 props がレスポンシブ) */
86
94
  type FullPropValueTypes = MakeResponsive<{
87
- [K in FullPropsWithBreakpoint]?: PropValueType<PropsConfig[K]>;
95
+ [K in FullPropsWithBreakpoint]?: PropValueType<PropsConfig[K], UserPropValues<K>>;
88
96
  }> & {
89
- [K in FullPropsWithoutBreakpoint]?: PropValueType<PropsConfig[K]>;
97
+ [K in FullPropsWithoutBreakpoint]?: PropValueType<PropsConfig[K], UserPropValues<K>>;
90
98
  };
91
99
  /**
92
100
  * FullModeRegistry が module augmentation で拡張されている(= キーが1つ以上ある)か。
@@ -1,4 +1,5 @@
1
1
  import { LimitedArray } from './utils';
2
+ import { BreakpointSequence } from '../../../config/defaults/breakpoints';
2
3
  /**
3
4
  * 型が「広告する(補完・許可する)」ブレイクポイントのレジストリ。
4
5
  *
@@ -33,8 +34,9 @@ type AdvertisedBpKey = Extract<keyof BreakpointRegistry, string>;
33
34
  /**
34
35
  * 配列記法の位置順(`base` を除く)。位置は固定の契約(変更しない)。
35
36
  * `xs` はこの並びに含めない(= 配列記法では書けず、オブジェクト記法のみ)。
37
+ * 定義は `config/defaults/breakpoints` の `BREAK_POINTS` を single source とする。
36
38
  */
37
- type ArrayBpSequence = ['sm', 'md', 'lg', 'xl'];
39
+ type ArrayBpSequence = BreakpointSequence;
38
40
  /** タプルのうち `Keys` に含まれる要素だけを残す */
39
41
  type FilterByKeys<Tuple extends readonly unknown[], Keys, Acc extends unknown[] = []> = Tuple extends readonly [infer Head, ...infer Rest] ? FilterByKeys<Rest, Keys, Head extends Keys ? [...Acc, Head] : Acc> : Acc;
40
42
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-css",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Lism CSS is a layout-first CSS framework for websites.",
5
5
  "author": {
6
6
  "name": "ddryo",
@@ -36,6 +36,10 @@
36
36
  "import": "./dist/config/default-config.js",
37
37
  "types": "./dist/config/default-config.d.ts"
38
38
  },
39
+ "./config-types": {
40
+ "types": "./dist/config/types.d.ts",
41
+ "import": "./dist/config/types.js"
42
+ },
39
43
  "./config/helper": {
40
44
  "import": "./dist/config/helper.js",
41
45
  "types": "./dist/config/helper.d.ts"
@@ -85,8 +85,7 @@ blockquote {
85
85
  font-style: italic;
86
86
  }
87
87
 
88
- blockquote,
89
- pre {
88
+ blockquote {
90
89
  background-color: var(--base-2);
91
90
  padding: var(--s20);
92
91
  }
@@ -48,6 +48,9 @@
48
48
  }
49
49
 
50
50
  body {
51
+ /* BFCを作り、先頭子要素のmargin-topがbody外へ相殺されてmin-heightと合算スクロールが発生するのを防ぐ (#458) */
52
+ display: flow-root;
53
+
51
54
  /* htmlから継承する */
52
55
  overflow: inherit;
53
56
 
@@ -11,7 +11,8 @@
11
11
  }
12
12
 
13
13
  // リンクをクリック可能にするためにz-indexあげる
14
- .is--boxLink a {
14
+ // :where() で詳細度を 0 にし、no_layer ビルドでもユーティリティ等で上書きしやすくする。
15
+ .is--boxLink :where(a:not(.is--coverLink)) {
15
16
  position: relative;
16
17
  z-index: 2; // .is--coverLink::before + 1
17
18
  }