@charcoal-ui/styled 2.5.0 → 2.7.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.
- package/dist/SetThemeScript.d.ts +20 -20
- package/dist/TokenInjector.d.ts +12 -12
- package/dist/TokenInjector.d.ts.map +1 -1
- package/dist/builders/border.d.ts +9 -9
- package/dist/builders/border.d.ts.map +1 -1
- package/dist/builders/borderRadius.d.ts +6 -6
- package/dist/builders/colors.d.ts +12 -12
- package/dist/builders/colors.d.ts.map +1 -1
- package/dist/builders/elementEffect.d.ts +6 -6
- package/dist/builders/o.d.ts +113 -114
- package/dist/builders/o.d.ts.map +1 -1
- package/dist/builders/outline.d.ts +9 -9
- package/dist/builders/outline.d.ts.map +1 -1
- package/dist/builders/size.d.ts +22 -22
- package/dist/builders/size.d.ts.map +1 -1
- package/dist/builders/spacing.d.ts +14 -14
- package/dist/builders/spacing.d.ts.map +1 -1
- package/dist/builders/transition.d.ts +6 -6
- package/dist/builders/typography.d.ts +10 -10
- package/dist/defineThemeVariables.test.d.ts +1 -1
- package/dist/factories/lib.d.ts +88 -88
- package/dist/factories/lib.d.ts.map +1 -1
- package/dist/helper.d.ts +38 -38
- package/dist/helper.d.ts.map +1 -1
- package/dist/index.cjs.js +918 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +128 -128
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +886 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.story.d.ts +18 -25
- package/dist/index.story.d.ts.map +1 -1
- package/dist/index.test.d.ts +1 -1
- package/dist/internals/index.d.ts +41 -41
- package/dist/storyHelper.d.ts +9 -0
- package/dist/storyHelper.d.ts.map +1 -0
- package/dist/util.d.ts +100 -100
- package/dist/util.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/builders/border.ts +1 -1
- package/src/builders/colors.ts +1 -1
- package/src/builders/o.ts +1 -8
- package/src/builders/outline.ts +1 -1
- package/src/builders/size.ts +1 -1
- package/src/builders/spacing.ts +2 -2
- package/src/index.story.tsx +1 -18
- package/src/index.test.tsx +2 -1
- package/src/index.ts +1 -12
- package/src/storyHelper.ts +18 -0
- package/src/util.ts +1 -1
- package/dist/index.cjs +0 -1174
- package/dist/index.cjs.map +0 -1
- package/dist/index.modern.js +0 -989
- package/dist/index.modern.js.map +0 -1
- package/dist/index.module.js +0 -1157
- package/dist/index.module.js.map +0 -1
package/src/builders/o.ts
CHANGED
|
@@ -13,7 +13,6 @@ import typography from './typography'
|
|
|
13
13
|
* `theme(o => [...])` の `o` の部分を構築する
|
|
14
14
|
*
|
|
15
15
|
* @param theme テーマオブジェクト
|
|
16
|
-
* @param DO_NOTHING_IT_IS_JUST_CALLED_FOR_TYPE_INFERENCE 型推論のためだけに使う場合にランタイムコストをゼロにするフラグ
|
|
17
16
|
*/
|
|
18
17
|
export default function createO<T extends CharcoalAbstractTheme>(
|
|
19
18
|
theme: {
|
|
@@ -22,14 +21,8 @@ export default function createO<T extends CharcoalAbstractTheme>(
|
|
|
22
21
|
gradientColor: T['gradientColor']
|
|
23
22
|
border: T['border']
|
|
24
23
|
outline: T['outline']
|
|
25
|
-
} & Omit<T, 'color' | 'gradientColor' | 'border' | 'outline'
|
|
26
|
-
DO_NOTHING_IT_IS_JUST_CALLED_FOR_TYPE_INFERENCE = false
|
|
24
|
+
} & Omit<T, 'color' | 'gradientColor' | 'border' | 'outline'>
|
|
27
25
|
) {
|
|
28
|
-
if (DO_NOTHING_IT_IS_JUST_CALLED_FOR_TYPE_INFERENCE) {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
30
|
-
return {} as never
|
|
31
|
-
}
|
|
32
|
-
|
|
33
26
|
return objectAssign(
|
|
34
27
|
colors(theme),
|
|
35
28
|
typography(theme),
|
package/src/builders/outline.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '../factories/lib'
|
|
11
11
|
|
|
12
12
|
export const outlineType = ['focus'] as const
|
|
13
|
-
type OutlineType = typeof outlineType[number]
|
|
13
|
+
type OutlineType = (typeof outlineType)[number]
|
|
14
14
|
|
|
15
15
|
const outlineCss = (weight: number, color: string) => ({
|
|
16
16
|
boxShadow: `0 0 0 ${px(weight)} ${color}`,
|
package/src/builders/size.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Internal, createInternal } from '../internals'
|
|
|
5
5
|
import { defineProperties, defineConstantProperties } from '../factories/lib'
|
|
6
6
|
|
|
7
7
|
export const fixedProperties = ['width', 'height'] as const
|
|
8
|
-
type FixedProperty = typeof fixedProperties[number]
|
|
8
|
+
type FixedProperty = (typeof fixedProperties)[number]
|
|
9
9
|
|
|
10
10
|
export const createFixedPxCss =
|
|
11
11
|
<T extends CharcoalAbstractTheme>(theme: T) =>
|
package/src/builders/spacing.ts
CHANGED
|
@@ -14,8 +14,8 @@ export const spacingDirections = [
|
|
|
14
14
|
'horizontal',
|
|
15
15
|
'all',
|
|
16
16
|
] as const
|
|
17
|
-
type SpacingProperty = typeof spacingProperties[number]
|
|
18
|
-
type SpacingDirection = typeof spacingDirections[number]
|
|
17
|
+
type SpacingProperty = (typeof spacingProperties)[number]
|
|
18
|
+
type SpacingDirection = (typeof spacingDirections)[number]
|
|
19
19
|
|
|
20
20
|
function spacingProperty(
|
|
21
21
|
property: SpacingProperty,
|
package/src/index.story.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import styled, { CSSProp, DefaultTheme, ThemeProvider } from 'styled-components'
|
|
3
|
-
import { CharcoalTheme } from '@charcoal-ui/theme'
|
|
4
|
-
import { Material } from '@charcoal-ui/foundation'
|
|
5
3
|
import { createTheme, ThemeProp, defineThemeVariables } from '.'
|
|
6
4
|
import { disabledSelector } from '@charcoal-ui/utils'
|
|
5
|
+
import { MyTheme, myTheme } from './storyHelper'
|
|
7
6
|
|
|
8
7
|
export default {
|
|
9
8
|
title: 'styled',
|
|
@@ -15,22 +14,6 @@ declare module 'react' {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
type MyTheme = CharcoalTheme & {
|
|
19
|
-
color: {
|
|
20
|
-
mycolor: Material
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function myTheme(theme: CharcoalTheme): MyTheme {
|
|
25
|
-
return {
|
|
26
|
-
...theme,
|
|
27
|
-
color: {
|
|
28
|
-
...theme.color,
|
|
29
|
-
mycolor: '#ff9e8c',
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
17
|
declare module 'styled-components' {
|
|
35
18
|
export interface DefaultTheme extends MyTheme {}
|
|
36
19
|
}
|
package/src/index.test.tsx
CHANGED
|
@@ -4,7 +4,8 @@ import 'jest-styled-components'
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import renderder from 'react-test-renderer'
|
|
6
6
|
import { ThemeProvider } from 'styled-components'
|
|
7
|
-
import { Example,
|
|
7
|
+
import { Example, TailwindLike } from './index.story'
|
|
8
|
+
import { myTheme } from './storyHelper'
|
|
8
9
|
|
|
9
10
|
function render(children: JSX.Element) {
|
|
10
11
|
return renderder
|
package/src/index.ts
CHANGED
|
@@ -40,18 +40,7 @@ const nonBlank = <T>(value: T): value is T extends Blank ? never : T =>
|
|
|
40
40
|
export function createTheme<T extends CharcoalAbstractTheme>(
|
|
41
41
|
_styled?: ThemedStyledInterface<T>
|
|
42
42
|
) {
|
|
43
|
-
|
|
44
|
-
* 本当は `type Builder = ReturnType<createO<T>>` みたいな型を作って、それを o の型にしたい。
|
|
45
|
-
* が、styled がつくられた時点の TypeScript ではこういうジェネリクスの使い方ができなかった
|
|
46
|
-
* なので代わりに特に意味のない `createO` の呼び出しをやっている
|
|
47
|
-
*/
|
|
48
|
-
const type_O = createO<T>(
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
50
|
-
{} as any,
|
|
51
|
-
/** DO_NOTHING_IT_IS_JUST_CALLED_FOR_TYPE_INFERENCE = */ true
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
type Builder = typeof type_O
|
|
43
|
+
type Builder = ReturnType<typeof createO<T>>
|
|
55
44
|
|
|
56
45
|
// ランタイムの `theme(o => [...])` のインターフェースを構築する
|
|
57
46
|
return function theme(
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Material } from '@charcoal-ui/foundation'
|
|
2
|
+
import { CharcoalTheme } from '@charcoal-ui/theme'
|
|
3
|
+
|
|
4
|
+
export type MyTheme = CharcoalTheme & {
|
|
5
|
+
color: {
|
|
6
|
+
mycolor: Material
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function myTheme(theme: CharcoalTheme): MyTheme {
|
|
11
|
+
return {
|
|
12
|
+
...theme,
|
|
13
|
+
color: {
|
|
14
|
+
...theme.color,
|
|
15
|
+
mycolor: '#ff9e8c',
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/util.ts
CHANGED
|
@@ -90,7 +90,7 @@ export function objectAssign<T extends any[]>(...sources: T) {
|
|
|
90
90
|
*/
|
|
91
91
|
export function keyof<
|
|
92
92
|
// このジェネリクスは必須(書かないと返り値が `never[]` になる )
|
|
93
|
-
T,
|
|
93
|
+
T extends Record<never, unknown>,
|
|
94
94
|
// このジェネリクスは書かなくて良い、obj の内容から推論される( T と矛盾してはいけない )
|
|
95
95
|
_ extends T = T
|
|
96
96
|
>(obj: _) {
|