@purpurds/action 3.0.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.
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json",
3
+ "disableBuildCacheForProject": false,
4
+ "operationSettings": [
5
+ {
6
+ "operationName": "build",
7
+ "outputFolderNames": [
8
+ "dist",
9
+ "types"
10
+ ]
11
+ },
12
+ {
13
+ "operationName": "ci:build",
14
+ "outputFolderNames": [
15
+ "dist",
16
+ "types"
17
+ ]
18
+ }
19
+ ],
20
+ "incrementalBuildIgnoredGlobs": [
21
+ "CHANGELOG.json",
22
+ "CHANGELOG.md"
23
+ ]
24
+ }
@@ -0,0 +1 @@
1
+ No third parties dependencies
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={PRIMARY:"primary",PRIMARY_NEGATIVE:"primary-negative",SECONDARY:"secondary",SECONDARY_NEGATIVE:"secondary-negative",EXPRESSIVE:"expressive",EXPRESSIVE_NEGATIVE:"expressive-negative"},t=Object.values(e),s={SM:"sm",MD:"md",LG:"lg"},E=Object.values(s);exports.SIZE=s;exports.VARIANT=e;exports.sizes=E;exports.variants=t;
2
+ //# sourceMappingURL=action.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.cjs.js","sources":["../src/action.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n PRIMARY_NEGATIVE: \"primary-negative\",\n SECONDARY: \"secondary\",\n SECONDARY_NEGATIVE: \"secondary-negative\",\n EXPRESSIVE: \"expressive\",\n EXPRESSIVE_NEGATIVE: \"expressive-negative\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n children?: ReactNode;\n className?: string;\n [\"data-testid\"]?: string;\n fullWidth?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n"],"names":["VARIANT","variants","SIZE","sizes"],"mappings":"gFAEO,MAAMA,EAAU,CACrB,QAAS,UACT,iBAAkB,mBAClB,UAAW,YACX,mBAAoB,qBACpB,WAAY,aACZ,oBAAqB,qBACvB,EAEaC,EAAW,OAAO,OAAOD,CAAO,EAGhCE,EAAO,CAClB,GAAI,KACJ,GAAI,KACJ,GAAI,IACN,EAEaC,EAAQ,OAAO,OAAOD,CAAI"}
@@ -0,0 +1,38 @@
1
+ import { ReactNode } from "react";
2
+ export declare const VARIANT: {
3
+ readonly PRIMARY: "primary";
4
+ readonly PRIMARY_NEGATIVE: "primary-negative";
5
+ readonly SECONDARY: "secondary";
6
+ readonly SECONDARY_NEGATIVE: "secondary-negative";
7
+ readonly EXPRESSIVE: "expressive";
8
+ readonly EXPRESSIVE_NEGATIVE: "expressive-negative";
9
+ };
10
+ export declare const variants: ("primary" | "primary-negative" | "secondary" | "secondary-negative" | "expressive" | "expressive-negative")[];
11
+ export type Variant = (typeof VARIANT)[keyof typeof VARIANT];
12
+ export declare const SIZE: {
13
+ readonly SM: "sm";
14
+ readonly MD: "md";
15
+ readonly LG: "lg";
16
+ };
17
+ export declare const sizes: ("sm" | "md" | "lg")[];
18
+ export type Size = (typeof SIZE)[keyof typeof SIZE];
19
+ type DefaultProps<TVariant, T = object> = {
20
+ children?: ReactNode;
21
+ className?: string;
22
+ ["data-testid"]?: string;
23
+ fullWidth?: boolean;
24
+ size?: Size;
25
+ variant: TVariant | Variant;
26
+ } & T;
27
+ export type UnionParams<TVariant> = DefaultProps<TVariant, {
28
+ iconOnly: boolean;
29
+ ["aria-label"]: string;
30
+ }> | DefaultProps<TVariant, {
31
+ ["aria-label"]?: string;
32
+ }>;
33
+ type UnionKeys<T> = T extends T ? keyof T : never;
34
+ type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
35
+ type StrictUnion<T> = StrictUnionHelper<T, T>;
36
+ export type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;
37
+ export {};
38
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../src/action.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,eAAO,MAAM,QAAQ,gHAAyB,CAAC;AAC/C,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,eAAO,MAAM,IAAI;;;;CAIP,CAAC;AAEX,eAAO,MAAM,KAAK,wBAAsB,CAAC;AACzC,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,OAAO,IAAI,CAAC,CAAC;AAEpD,KAAK,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,IAAI;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,GAAG,CAAC,CAAC;AAEN,MAAM,MAAM,WAAW,CAAC,QAAQ,IAC5B,YAAY,CAAC,QAAQ,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,YAAY,CAAC,QAAQ,EAAE;IAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAExD,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC;AAElD,KAAK,iBAAiB,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,SAAS,GAAG,GAC3C,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAC7D,KAAK,CAAC;AAEV,KAAK,WAAW,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9C,MAAM,MAAM,WAAW,CAAC,QAAQ,SAAS,MAAM,GAAG,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ const e = {
2
+ PRIMARY: "primary",
3
+ PRIMARY_NEGATIVE: "primary-negative",
4
+ SECONDARY: "secondary",
5
+ SECONDARY_NEGATIVE: "secondary-negative",
6
+ EXPRESSIVE: "expressive",
7
+ EXPRESSIVE_NEGATIVE: "expressive-negative"
8
+ }, E = Object.values(e), s = {
9
+ SM: "sm",
10
+ MD: "md",
11
+ LG: "lg"
12
+ }, a = Object.values(s);
13
+ export {
14
+ s as SIZE,
15
+ e as VARIANT,
16
+ a as sizes,
17
+ E as variants
18
+ };
19
+ //# sourceMappingURL=action.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.es.js","sources":["../src/action.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nexport const VARIANT = {\n PRIMARY: \"primary\",\n PRIMARY_NEGATIVE: \"primary-negative\",\n SECONDARY: \"secondary\",\n SECONDARY_NEGATIVE: \"secondary-negative\",\n EXPRESSIVE: \"expressive\",\n EXPRESSIVE_NEGATIVE: \"expressive-negative\",\n} as const;\n\nexport const variants = Object.values(VARIANT);\nexport type Variant = (typeof VARIANT)[keyof typeof VARIANT];\n\nexport const SIZE = {\n SM: \"sm\",\n MD: \"md\",\n LG: \"lg\",\n} as const;\n\nexport const sizes = Object.values(SIZE);\nexport type Size = (typeof SIZE)[keyof typeof SIZE];\n\ntype DefaultProps<TVariant, T = object> = {\n children?: ReactNode;\n className?: string;\n [\"data-testid\"]?: string;\n fullWidth?: boolean;\n size?: Size;\n variant: TVariant | Variant;\n} & T;\n\nexport type UnionParams<TVariant> =\n | DefaultProps<TVariant, { iconOnly: boolean; [\"aria-label\"]: string }>\n | DefaultProps<TVariant, { [\"aria-label\"]?: string }>;\n\ntype UnionKeys<T> = T extends T ? keyof T : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StrictUnionHelper<T, TAll> = T extends any\n ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>\n : never;\n\ntype StrictUnion<T> = StrictUnionHelper<T, T>;\n\nexport type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;\n"],"names":["VARIANT","variants","SIZE","sizes"],"mappings":"AAEO,MAAMA,IAAU;AAAA,EACrB,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,qBAAqB;AACvB,GAEaC,IAAW,OAAO,OAAOD,CAAO,GAGhCE,IAAO;AAAA,EAClB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEaC,IAAQ,OAAO,OAAOD,CAAI;"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@purpurds/action",
3
+ "version": "3.0.0",
4
+ "license": "AGPL-3.0-only",
5
+ "main": "./dist/action.cjs.js",
6
+ "types": "./dist/action.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/action.cjs.js",
10
+ "systemjs": "./dist/action.system.js",
11
+ "types": "./dist/action.d.ts",
12
+ "default": "./dist/action.es.js"
13
+ },
14
+ "./src/action.scss": "./src/action.scss"
15
+ },
16
+ "source": "src/action.tsx",
17
+ "dependencies": {
18
+ "@purpurds/tokens": "3.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "@rushstack/eslint-patch": "~1.7.0",
22
+ "@storybook/blocks": "~7.6.0",
23
+ "@storybook/react": "~7.6.0",
24
+ "@telia/base-rig": "~8.2.0",
25
+ "@telia/react-rig": "~3.2.0",
26
+ "@testing-library/dom": "~9.3.3",
27
+ "@testing-library/jest-dom": "~6.3.0",
28
+ "@testing-library/react": "~14.1.2",
29
+ "@types/node": "18",
30
+ "@types/react-dom": "~18.2.17",
31
+ "@types/react": "~18.2.42",
32
+ "eslint-plugin-testing-library": "~6.2.0",
33
+ "eslint": "~8.56.0",
34
+ "jsdom": "~22.1.0",
35
+ "lint-staged": "~10.5.3",
36
+ "prettier": "~2.8.8",
37
+ "react-dom": "~18.2.0",
38
+ "react": "~18.2.0",
39
+ "typescript": "~5.2.2",
40
+ "vite": "~5.0.6",
41
+ "vitest": "~1.2.0",
42
+ "@purpurds/component-rig": "1.0.0"
43
+ },
44
+ "scripts": {
45
+ "build:dev": "vite",
46
+ "build:watch": "vite build --watch",
47
+ "build": "vite build",
48
+ "ci:build": "rushx build",
49
+ "coverage": "vitest run --coverage",
50
+ "lint:fix": "eslint . --fix",
51
+ "lint": "lint-staged --no-stash 2>&1",
52
+ "sbdev": "rush sbdev",
53
+ "test:unit": "vitest run --passWithNoTests",
54
+ "test:watch": "vitest --watch",
55
+ "test": "rushx test:unit",
56
+ "typecheck": "tsc -p ./tsconfig.json"
57
+ }
58
+ }
@@ -0,0 +1,156 @@
1
+ @mixin action {
2
+ $root: &;
3
+
4
+ align-items: center;
5
+ border-radius: var(--purpur-border-radius-full);
6
+ border-width: 0;
7
+ cursor: pointer;
8
+ display: inline-flex;
9
+ font-size: var(--purpur-typography-scale-100);
10
+ font-family: var(--purpur-typography-family-default), Helvetica, Arial, "Lucida Grande",
11
+ sans-serif;
12
+ font-weight: var(--purpur-typography-weight-medium);
13
+ gap: var(--purpur-spacing-100);
14
+ justify-content: center;
15
+ line-height: var(--purpur-spacing-300);
16
+ outline: 0;
17
+ position: relative;
18
+ text-decoration: none;
19
+ transition: all var(--purpur-motion-duration-100) ease;
20
+ width: auto;
21
+
22
+ &:focus {
23
+ &::before {
24
+ border-radius: var(--purpur-border-radius-full);
25
+ box-shadow: 0 0 0 var(--purpur-border-width-sm) var(--purpur-color-border-interactive-focus);
26
+ content: "";
27
+ display: block;
28
+ inset: calc(var(--purpur-spacing-25) * -1);
29
+ position: absolute;
30
+ }
31
+
32
+ &:not(:focus-visible) {
33
+ &::before {
34
+ box-shadow: none;
35
+ }
36
+ }
37
+ }
38
+
39
+ svg {
40
+ display: block;
41
+ }
42
+
43
+ &--sm {
44
+ padding: var(--purpur-spacing-100) var(--purpur-spacing-250);
45
+
46
+ &#{$root}--icon-only {
47
+ padding: var(--purpur-spacing-100);
48
+ }
49
+ }
50
+
51
+ &--md {
52
+ padding: var(--purpur-spacing-150) var(--purpur-spacing-300);
53
+
54
+ &#{$root}--icon-only {
55
+ padding: var(--purpur-spacing-150);
56
+ }
57
+ }
58
+
59
+ &--lg {
60
+ padding: var(--purpur-spacing-200) var(--purpur-spacing-400);
61
+
62
+ &#{$root}--icon-only {
63
+ padding: var(--purpur-spacing-200);
64
+ }
65
+ }
66
+
67
+ &--full-width {
68
+ width: 100%;
69
+ }
70
+
71
+ &--primary {
72
+ background-color: var(--purpur-color-background-interactive-primary);
73
+ color: var(--purpur-color-text-interactive-on-primary);
74
+
75
+ &:hover:not(#{$root}--disabled) {
76
+ background-color: var(--purpur-color-background-interactive-primary-hover);
77
+ }
78
+
79
+ &:active:not(#{$root}--disabled) {
80
+ background-color: var(--purpur-color-background-interactive-primary-active);
81
+ }
82
+ }
83
+
84
+ &--primary-negative {
85
+ background-color: var(--purpur-color-background-interactive-primary-negative);
86
+ color: var(--purpur-color-text-interactive-on-primary-negative);
87
+
88
+ &:hover:not(#{$root}--disabled) {
89
+ background-color: var(--purpur-color-background-interactive-primary-negative-hover);
90
+ border-color: var(--purpur-color-background-interactive-primary-negative-hover);
91
+ }
92
+
93
+ &:active:not(#{$root}--disabled) {
94
+ background-color: var(--purpur-color-background-interactive-primary-negative-active);
95
+ border-color: var(--purpur-color-background-interactive-primary-negative-active);
96
+ }
97
+ }
98
+
99
+ &--secondary {
100
+ background-color: var(--purpur-color-background-interactive-transparent);
101
+ box-shadow: inset 0 0 0 var(--purpur-border-width-xs)
102
+ var(--purpur-color-border-interactive-primary);
103
+ color: var(--purpur-color-text-interactive-primary);
104
+
105
+ &:hover:not(#{$root}--disabled) {
106
+ background-color: var(--purpur-color-background-interactive-transparent-hover);
107
+ }
108
+
109
+ &:active:not(#{$root}--disabled) {
110
+ background-color: var(--purpur-color-background-interactive-transparent-active);
111
+ }
112
+ }
113
+
114
+ &--secondary-negative {
115
+ background-color: var(--purpur-color-background-interactive-transparent);
116
+ box-shadow: inset 0 0 0 var(--purpur-border-width-xs)
117
+ var(--purpur-color-border-interactive-primary-negative);
118
+ color: var(--purpur-color-text-interactive-primary-negative);
119
+
120
+ &:hover:not(#{$root}--disabled) {
121
+ background-color: var(--purpur-color-background-interactive-transparent-negative-hover);
122
+ }
123
+
124
+ &:active:not(#{$root}--disabled) {
125
+ background-color: var(--purpur-color-background-interactive-transparent-negative-active);
126
+ }
127
+ }
128
+
129
+ &--expressive {
130
+ background-color: var(--purpur-color-background-interactive-expressive);
131
+ color: var(--purpur-color-text-interactive-on-expressive);
132
+
133
+ &:hover:not(#{$root}--disabled) {
134
+ background-color: var(--purpur-color-background-interactive-expressive-hover);
135
+ }
136
+
137
+ &:active:not(#{$root}--disabled) {
138
+ background-color: var(--purpur-color-background-interactive-expressive-active);
139
+ }
140
+ }
141
+
142
+ &--expressive-negative {
143
+ background-color: var(--purpur-color-background-interactive-expressive-negative);
144
+ color: var(--purpur-color-text-interactive-on-expressive-negative);
145
+
146
+ &:hover:not(#{$root}--disabled) {
147
+ background-color: var(--purpur-color-background-interactive-expressive-negative-hover);
148
+ color: var(--purpur-color-text-interactive-on-expressive-negative-hover);
149
+ }
150
+
151
+ &:active:not(#{$root}--disabled) {
152
+ background-color: var(--purpur-color-background-interactive-expressive-negative-active);
153
+ color: var(--purpur-color-text-interactive-on-expressive-negative-active);
154
+ }
155
+ }
156
+ }
package/src/action.tsx ADDED
@@ -0,0 +1,45 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export const VARIANT = {
4
+ PRIMARY: "primary",
5
+ PRIMARY_NEGATIVE: "primary-negative",
6
+ SECONDARY: "secondary",
7
+ SECONDARY_NEGATIVE: "secondary-negative",
8
+ EXPRESSIVE: "expressive",
9
+ EXPRESSIVE_NEGATIVE: "expressive-negative",
10
+ } as const;
11
+
12
+ export const variants = Object.values(VARIANT);
13
+ export type Variant = (typeof VARIANT)[keyof typeof VARIANT];
14
+
15
+ export const SIZE = {
16
+ SM: "sm",
17
+ MD: "md",
18
+ LG: "lg",
19
+ } as const;
20
+
21
+ export const sizes = Object.values(SIZE);
22
+ export type Size = (typeof SIZE)[keyof typeof SIZE];
23
+
24
+ type DefaultProps<TVariant, T = object> = {
25
+ children?: ReactNode;
26
+ className?: string;
27
+ ["data-testid"]?: string;
28
+ fullWidth?: boolean;
29
+ size?: Size;
30
+ variant: TVariant | Variant;
31
+ } & T;
32
+
33
+ export type UnionParams<TVariant> =
34
+ | DefaultProps<TVariant, { iconOnly: boolean; ["aria-label"]: string }>
35
+ | DefaultProps<TVariant, { ["aria-label"]?: string }>;
36
+
37
+ type UnionKeys<T> = T extends T ? keyof T : never;
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ type StrictUnionHelper<T, TAll> = T extends any
40
+ ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>>
41
+ : never;
42
+
43
+ type StrictUnion<T> = StrictUnionHelper<T, T>;
44
+
45
+ export type ActionProps<TVariant extends string = Variant> = StrictUnion<UnionParams<TVariant>>;
@@ -0,0 +1,4 @@
1
+ declare module "*.scss" {
2
+ const styles: { [className: string]: string };
3
+ export default styles;
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@purpurds/component-rig",
3
+ "compilerOptions": {
4
+ "rootDir": "src"
5
+ },
6
+ "include": ["src"]
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@purpurds/component-rig/tsconfig.types.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist"
6
+ },
7
+ "include": ["src"],
8
+ "exclude": ["**/*.test.*", "**/*.stories.*"]
9
+ }
@@ -0,0 +1,5 @@
1
+ import { defineConfig } from "vite";
2
+ import { getConfig } from "@purpurds/component-rig/vite.config";
3
+ import pkg from "./package.json";
4
+
5
+ export default defineConfig(getConfig(pkg));